/** * @return Value. */ public static BigDecimal doReadDecimal(BinaryInputStream in) { int scale = in.readInt(); byte[] mag = doReadByteArray(in); boolean negative = mag[0] < 0; if (negative) mag[0] &= 0x7F; BigInteger intVal = new BigInteger(mag); if (negative) intVal = intVal.negate(); return new BigDecimal(intVal, scale); }
/** {@inheritDoc} */ @Nullable @Override public byte[] readByteArray() throws BinaryObjectException { switch (checkFlag(BYTE_ARR)) { case NORMAL: return BinaryUtils.doReadByteArray(in); case HANDLE: return readHandleField(); default: return null; } }
/** * @param fieldId Field ID. * @return Binary object. * @throws BinaryObjectException In case of error. */ @Nullable BinaryObject readBinaryObject(int fieldId) throws BinaryObjectException { if (findFieldById(fieldId)) { if (checkFlag(BINARY_OBJ) == Flag.NULL) return null; return new BinaryObjectImpl(ctx, BinaryUtils.doReadByteArray(in), in.readInt()); } else return null; }
/** * @return Value. */ public static String doReadString(BinaryInputStream in) { if (!in.hasArray()) { byte[] arr = doReadByteArray(in); if (USE_STR_SERIALIZATION_VER_2) return utf8BytesToStr(arr, 0, arr.length); else return new String(arr, UTF_8); } int strLen = in.readInt(); int pos = in.position(); // String will copy necessary array part for us. String res; if (USE_STR_SERIALIZATION_VER_2) { res = utf8BytesToStr(in.array(), pos, strLen); } else { res = new String(in.array(), pos, strLen, UTF_8); } in.position(pos + strLen); return res; }
/** * @return Value. */ public static BinaryObject doReadBinaryObject(BinaryInputStream in, BinaryContext ctx, boolean detach) { if (in.offheapPointer() > 0) { int len = in.readInt(); int pos = in.position(); in.position(in.position() + len); int start = in.readInt(); return new BinaryObjectOffheapImpl(ctx, in.offheapPointer() + pos, start, len); } else { byte[] arr = doReadByteArray(in); int start = in.readInt(); BinaryObjectImpl binO = new BinaryObjectImpl(ctx, arr, start); if (detach) { binO.detachAllowed(true); return binO.detach(); } return binO; } }
obj = BinaryUtils.doReadByteArray(in);
return BinaryUtils.doReadByteArray(reader.in());
return doReadByteArray(in);
/** * @return Value. */ public static BigDecimal doReadDecimal(BinaryInputStream in) { int scale = in.readInt(); byte[] mag = doReadByteArray(in); boolean negative = mag[0] < 0; if (negative) mag[0] &= 0x7F; BigInteger intVal = new BigInteger(mag); if (negative) intVal = intVal.negate(); return new BigDecimal(intVal, scale); }
/** {@inheritDoc} */ @Nullable @Override public byte[] readByteArray() throws BinaryObjectException { switch (checkFlag(BYTE_ARR)) { case NORMAL: return BinaryUtils.doReadByteArray(in); case HANDLE: return readHandleField(); default: return null; } }
/** * @param fieldId Field ID. * @return Binary object. * @throws BinaryObjectException In case of error. */ @Nullable BinaryObject readBinaryObject(int fieldId) throws BinaryObjectException { if (findFieldById(fieldId)) { if (checkFlag(BINARY_OBJ) == Flag.NULL) return null; return new BinaryObjectImpl(ctx, BinaryUtils.doReadByteArray(in), in.readInt()); } else return null; }
/** * @return Value. */ public static String doReadString(BinaryInputStream in) { if (!in.hasArray()) { byte[] arr = doReadByteArray(in); if (USE_STR_SERIALIZATION_VER_2) return utf8BytesToStr(arr, 0, arr.length); else return new String(arr, UTF_8); } int strLen = in.readInt(); int pos = in.position(); // String will copy necessary array part for us. String res; if (USE_STR_SERIALIZATION_VER_2) { res = utf8BytesToStr(in.array(), pos, strLen); } else { res = new String(in.array(), pos, strLen, UTF_8); } in.position(pos + strLen); return res; }
/** * @return Value. */ public static BinaryObject doReadBinaryObject(BinaryInputStream in, BinaryContext ctx, boolean detach) { if (in.offheapPointer() > 0) { int len = in.readInt(); int pos = in.position(); in.position(in.position() + len); int start = in.readInt(); return new BinaryObjectOffheapImpl(ctx, in.offheapPointer() + pos, start, len); } else { byte[] arr = doReadByteArray(in); int start = in.readInt(); BinaryObjectImpl binO = new BinaryObjectImpl(ctx, arr, start); if (detach) { binO.detachAllowed(true); return binO.detach(); } return binO; } }
obj = BinaryUtils.doReadByteArray(in);
return BinaryUtils.doReadByteArray(reader.in());