[erlang-questions] jinterface List vs. String

Michael Ossareh michael@REDACTED
Thu Dec 11 06:05:25 CET 2008


Hi Robert,

On Tue, Dec 9, 2008 at 1:54 AM, Robert Raschke <rtrlists@REDACTED> wrote:
> Hi,
>
> does anyone have a good idea on how I can distinguish between a list
> and a string in jinterface?

We've just written a jinterface layer to a jabber fsm we created, much
work in this space!

>
> Or, in other words, if jinterface has decided to receive an
> OtpErlangString (from a sent list like [1, 2, 3], for example), is
> there an easy way to convert it to an OtpErlangList? I know I can do
> it by hand, but that's ever so slightly icky.

The most awkward thing I've found is that a piece of data in our
erlang code that should be a string is a list when it has zero length.
This is where 90% of the errors we had with jinterface came from. The
simple test is

if ( sData instanceof OtpErlangString) { its a string } else { its a
string with 0 length || list }

In our case we do not care for lists so just leave the
java.lang.String that it would be assigned to null.

So, to summarize, im my experience thus far most of time you just have
to know what to expect. Check that it is the data type that you are
expecting (instanceof) and then provide a cleaner abstraction in
layers above.

>
> Thanks,
> Robby
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



-- 
god loves atheists, Fact: http://www.mrwiggleslovesyou.com/comics/rehab477.jpg



More information about the erlang-questions mailing list