private BigCouchUpdateSequence(final String encodedVector, final String packedSeqs) { this.since = encodedVector; final byte[] bytes = new Base64(true).decode(packedSeqs); final OtpInputStream stream = new OtpInputStream(bytes); try { final OtpErlangList list = (OtpErlangList) stream.read_any(); for (int i = 0, arity = list.arity(); i < arity; i++) { final OtpErlangTuple tuple = (OtpErlangTuple) list.elementAt(i); final OtpErlangObject node = tuple.elementAt(0); final OtpErlangObject range = tuple.elementAt(1); final OtpErlangObject seq_obj = tuple.elementAt(2); final OtpErlangLong node_seq; if (seq_obj instanceof OtpErlangLong) { node_seq = (OtpErlangLong) seq_obj; } else if (seq_obj instanceof OtpErlangTuple) { node_seq = (OtpErlangLong) ((OtpErlangTuple)seq_obj).elementAt(0); } else { throw new IllegalArgumentException("could not decode seq"); } vector.put(node + "-" + range, node_seq.longValue()); } } catch (final OtpErlangDecodeException e) { throw new IllegalArgumentException(encodedVector + " not valid."); } }
arity = keywordValueErlangLong.intValue(); } catch (OtpErlangRangeException e) { arity = null;
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."); } }
case OtpExternal.smallBigTag: case OtpExternal.largeBigTag: return new OtpErlangLong(this);
public static long extractLong(OtpErlangObject value) { return ((OtpErlangLong)value).longValue(); } }
values[i] = l.intValue();
/** * Get this number as a short. * * @return the value of this number, as a short. * * @exception OtpErlangRangeException * if the value is too large to be represented as a short. */ public short shortValue() throws OtpErlangRangeException { final long l = longValue(); final short i = (short) l; if (i != l) { throw new OtpErlangRangeException("Value too large for short: " + val); } return i; }
/** * Get this number as a char. * * @return the char value of this number. * * @exception OtpErlangRangeException * if the value is too large to be represented as a char. */ public char charValue() throws OtpErlangRangeException { final long l = longValue(); final char i = (char) l; if (i != l) { throw new OtpErlangRangeException("Value too large for char: " + val); } return i; }
/** * Get this number as an int. * * @return the value of this number, as an int. * * @exception OtpErlangRangeException * if the value is too large to be represented as an int. */ public int intValue() throws OtpErlangRangeException { final long l = longValue(); final int i = (int) l; if (i != l) { throw new OtpErlangRangeException("Value too large for int: " + val); } return i; }
/** * Get this number as a byte. * * @return the byte value of this number. * * @exception OtpErlangRangeException * if the value is too large to be represented as a byte. */ public byte byteValue() throws OtpErlangRangeException { final long l = longValue(); final byte i = (byte) l; if (i != l) { throw new OtpErlangRangeException("Value too large for byte: " + val); } return i; }
/** * Get this number as a non-negative short. * * @return the value of this number, as a short. * * @exception OtpErlangRangeException * if the value is too large to be represented as a short, or * if the value is negative. */ public short uShortValue() throws OtpErlangRangeException { final long l = longValue(); final short i = (short) l; if (i != l) { throw new OtpErlangRangeException("Value too large for short: " + val); } else if (i < 0) { throw new OtpErlangRangeException("Value not positive: " + val); } return i; }
/** * Get this number as a non-negative int. * * @return the value of this number, as an int. * * @exception OtpErlangRangeException * if the value is too large to be represented as an int, or * if the value is negative. */ public int uIntValue() throws OtpErlangRangeException { final long l = longValue(); final int i = (int) l; if (i != l) { throw new OtpErlangRangeException("Value too large for int: " + val); } else if (i < 0) { throw new OtpErlangRangeException("Value not positive: " + val); } return i; }
return ((OtpErlangInt) erlangObject).intValue(); } else if (erlangObject instanceof OtpErlangLong) { return ((OtpErlangLong) erlangObject).longValue(); } else if (erlangObject instanceof OtpErlangShort) { return ((OtpErlangShort) erlangObject).shortValue();
tag = (int) ((OtpErlangLong) head.elementAt(0)).longValue();