/** * Create a list of Erlang integers representing Unicode codePoints. This * method does not check if the string contains valid code points. * * @param str * the characters from which to create the list. */ public OtpErlangList(final String str) { if (str == null || str.length() == 0) { elems = NO_ELEMENTS; } else { final int[] codePoints = OtpErlangString.stringToCodePoints(str); elems = new OtpErlangObject[codePoints.length]; for (int i = 0; i < elems.length; i++) { elems[i] = new OtpErlangInt(codePoints[i]); } } }
/** * Create an Erlang integer from a stream containing an integer encoded in * Erlang external format. * * @param buf * the stream containing the encoded value. * * @exception OtpErlangDecodeException * if the buffer does not contain a valid external * representation of an Erlang integer. * * @exception OtpErlangRangeException * if the value is too large to be represented as an int. */ public OtpErlangInt(final OtpInputStream buf) throws OtpErlangRangeException, OtpErlangDecodeException { super(buf); intValue(); } }
protected OtpErlangObject convertBasicTypeToErlang(Object obj) { if (obj instanceof byte[]) { return new OtpErlangBinary((byte[]) obj); } else if (obj instanceof Boolean) { return new OtpErlangBoolean((Boolean) obj); } else if (obj instanceof Byte) { return new OtpErlangByte((Byte) obj); } else if (obj instanceof Character) { return new OtpErlangChar((Character) obj); } else if (obj instanceof Double) { return new OtpErlangDouble((Double) obj); } else if (obj instanceof Float) { return new OtpErlangFloat((Float) obj); } else if (obj instanceof Integer) { return new OtpErlangInt((Integer) obj); } else if (obj instanceof Long) { return new OtpErlangLong((Long) obj); } else if (obj instanceof Short) { return new OtpErlangShort((Short) obj); } else if (obj instanceof String) { return new OtpErlangString((String) obj); } else { throw new ErlangConversionException( "Could not convert Java object of type [" + obj.getClass() + "] to an Erlang data type."); } }
return ((OtpErlangFloat) erlangObject).floatValue(); } else if (erlangObject instanceof OtpErlangInt) { return ((OtpErlangInt) erlangObject).intValue(); } else if (erlangObject instanceof OtpErlangLong) { return ((OtpErlangLong) erlangObject).longValue();