private static Object deepCopyObject(Object o) { if (o instanceof TBase) { return ((TBase)o).deepCopy(); } else if (o instanceof ByteBuffer) { return TBaseHelper.copyBinary((ByteBuffer)o); } else if (o instanceof List) { return deepCopyList((List)o); } else if (o instanceof Set) { return deepCopySet((Set)o); } else if (o instanceof Map) { return deepCopyMap((Map)o); } else { return o; } }
/** * Returns v, with the bit at position set to 1 or 0 depending on value. */ public static final byte setBit(byte v, int position, boolean value) { return (byte)setBit((int)v, position, value); }
/** * Deserialize only a boolean field (addressed by recursively using field id) * from a byte record. * @param bytes The serialized object to read from * @param fieldIdPathFirst First of the FieldId's that define a path to a boolean field * @param fieldIdPathRest The rest FieldId's that define a path to a boolean field * @throws TException */ public Boolean partialDeserializeBool(byte[] bytes, TFieldIdEnum fieldIdPathFirst, TFieldIdEnum ... fieldIdPathRest) throws TException { return (Boolean) partialDeserializeField(TType.BOOL, bytes, fieldIdPathFirst, fieldIdPathRest); }
@Override public String readString() throws TException { try { return readJSONString(false).toString("UTF-8"); } catch (UnsupportedEncodingException ex) { throw new TException("JVM DOES NOT SUPPORT UTF-8"); } }
/** * Returns v, with the bit at position set to zero. */ public static final byte clearBit(byte v, int position) { return (byte)clearBit((int)v, position); }
/** * Bitfield utilities. * Returns true if the bit at position is set in v. */ public static final boolean testBit(byte v, int position) { return testBit((int)v, position); }
/** * Read a struct begin. There's nothing on the wire for this, but it is our * opportunity to push a new struct begin marker onto the field stack. */ public TStruct readStructBegin() throws TException { lastField_.push(lastFieldId_); lastFieldId_ = 0; return ANONYMOUS_STRUCT; }
/** * Output the contents of the memory buffer as a String, using the supplied * encoding * @param enc the encoding to use * @return the contents of the memory buffer as a String */ public String toString(String enc) throws UnsupportedEncodingException { return arr_.toString(enc); }
public void push(short pushed) { if (vector.length == top + 1) { grow(); } vector[++top] = pushed; }
public void setFieldValue(F fieldId, Object value) { checkType(fieldId, value); setField_ = fieldId; value_ = value; }
/** * Decode a series of 4 bytes from <code>buf</code>, starting at position 0, * and interpret them as an integer. * * @param buf * The buffer to read from. * @return An integer, as read from the buffer. */ public static final int decodeBigEndian(final byte[] buf) { return decodeBigEndian(buf, 0); }
private static Object deepCopyObject(Object o) { if (o instanceof TBase) { return ((TBase)o).deepCopy(); } else if (o instanceof ByteBuffer) { return TBaseHelper.copyBinary((ByteBuffer)o); } else if (o instanceof List) { return deepCopyList((List)o); } else if (o instanceof Set) { return deepCopySet((Set)o); } else if (o instanceof Map) { return deepCopyMap((Map)o); } else { return o; } }
/** * Returns v, with the bit at position set to 1 or 0 depending on value. */ public static final byte setBit(byte v, int position, boolean value) { return (byte)setBit((int)v, position, value); }
public static final int setBit(int v, int position, boolean value) { if(value) return v | (1 << position); else return clearBit(v, position); }
/** * Deserialize only a byte field (addressed by recursively using field id) * from a byte record. * @param bytes The serialized object to read from * @param fieldIdPathFirst First of the FieldId's that define a path to a byte field * @param fieldIdPathRest The rest FieldId's that define a path to a byte field * @throws TException */ public Byte partialDeserializeByte(byte[] bytes, TFieldIdEnum fieldIdPathFirst, TFieldIdEnum ... fieldIdPathRest) throws TException { return (Byte) partialDeserializeField(TType.BYTE, bytes, fieldIdPathFirst, fieldIdPathRest); }
/** * Write a struct begin. This doesn't actually put anything on the wire. We * use it as an opportunity to put special placeholder markers on the field * stack so we can get the field id deltas correct. */ public void writeStructBegin(TStruct struct) throws TException { lastField_.push(lastFieldId_); lastFieldId_ = 0; }
/** * Deserialize only an i16 field (addressed by recursively using field id) * from a byte record. * @param bytes The serialized object to read from * @param fieldIdPathFirst First of the FieldId's that define a path to an i16 field * @param fieldIdPathRest The rest FieldId's that define a path to an i16 field * @throws TException */ public Short partialDeserializeI16(byte[] bytes, TFieldIdEnum fieldIdPathFirst, TFieldIdEnum ... fieldIdPathRest) throws TException { return (Short) partialDeserializeField(TType.I16, bytes, fieldIdPathFirst, fieldIdPathRest); }
/** * Deserialize only an i32 field (addressed by recursively using field id) * from a byte record. * @param bytes The serialized object to read from * @param fieldIdPathFirst First of the FieldId's that define a path to an i32 field * @param fieldIdPathRest The rest FieldId's that define a path to an i32 field * @throws TException */ public Integer partialDeserializeI32(byte[] bytes, TFieldIdEnum fieldIdPathFirst, TFieldIdEnum ... fieldIdPathRest) throws TException { return (Integer) partialDeserializeField(TType.I32, bytes, fieldIdPathFirst, fieldIdPathRest); }
/** * Deserialize only a double field (addressed by recursively using field id) * from a byte record. * @param bytes The serialized object to read from * @param fieldIdPathFirst First of the FieldId's that define a path to a double field * @param fieldIdPathRest The rest FieldId's that define a path to a double field * @throws TException */ public Double partialDeserializeDouble(byte[] bytes, TFieldIdEnum fieldIdPathFirst, TFieldIdEnum ... fieldIdPathRest) throws TException { return (Double) partialDeserializeField(TType.DOUBLE, bytes, fieldIdPathFirst, fieldIdPathRest); }
/** * Deserialize only an i64 field (addressed by recursively using field id) * from a byte record. * @param bytes The serialized object to read from * @param fieldIdPathFirst First of the FieldId's that define a path to an i64 field * @param fieldIdPathRest The rest FieldId's that define a path to an i64 field * @throws TException */ public Long partialDeserializeI64(byte[] bytes, TFieldIdEnum fieldIdPathFirst, TFieldIdEnum ... fieldIdPathRest) throws TException { return (Long) partialDeserializeField(TType.I64, bytes, fieldIdPathFirst, fieldIdPathRest); }