protected static byte[] inflateFrom(byte[] contents, int index) { byte firstByte = contents[index]; if (firstByte == BinaryOutputCapsule.NULL_OBJECT) return ByteUtils.convertToBytes(BinaryOutputCapsule.NULL_OBJECT); else if (firstByte == BinaryOutputCapsule.DEFAULT_OBJECT) return ByteUtils.convertToBytes(BinaryOutputCapsule.DEFAULT_OBJECT); else if (firstByte == 0) return new byte[0]; else { byte[] rVal = new byte[firstByte]; for (int x = 0; x < rVal.length; x++) rVal[x] = contents[x + 1 + index]; return rVal; } }
public static byte[] convertToBytes(double n) { long bits = Double.doubleToLongBits(n); return convertToBytes(bits); }
public static byte[] convertToBytes(float f) { int temp = Float.floatToIntBits(f); return convertToBytes(temp); }
protected void write(short value) throws IOException { baos.write(ByteUtils.convertToBytes(value)); }
protected void write(double value) throws IOException { baos.write(ByteUtils.convertToBytes(value)); }
/** * Writes a double out to an OutputStream. * * @param outputStream * The OutputStream the double will be written to * @param value * The double to write * @throws IOException * Thrown if there is a problem writing to the OutputStream */ public static void writeDouble(OutputStream outputStream, double value) throws IOException { byte[] byteArray = convertToBytes(value); outputStream.write(byteArray); return; }
protected void write(boolean value) throws IOException { baos.write(ByteUtils.convertToBytes(value)); }
protected void write(float value) throws IOException { baos.write(ByteUtils.convertToBytes(value)); }
/** * Writes a short out to an OutputStream. * * @param outputStream * The OutputStream the short will be written to * @param value * The short to write * @throws IOException * Thrown if there is a problem writing to the OutputStream */ public static void writeShort(OutputStream outputStream, short value) throws IOException { byte[] byteArray = convertToBytes(value); outputStream.write(byteArray); return; }
/** * Writes a long out to an OutputStream. * * @param outputStream * The OutputStream the long will be written to * @param value * The long to write * @throws IOException * Thrown if there is a problem writing to the OutputStream */ public static void writeLong(OutputStream outputStream, long value) throws IOException { byte[] byteArray = convertToBytes(value); outputStream.write(byteArray); return; }
/** * Writes a float out to an OutputStream. * * @param outputStream * The OutputStream the float will be written to * @param fVal * The float to write * @throws IOException * Thrown if there is a problem writing to the OutputStream */ public static void writeFloat(OutputStream outputStream, float fVal) throws IOException { byte[] byteArray = convertToBytes(fVal); outputStream.write(byteArray); return; }
/** * Writes an integer out to an OutputStream. * * @param outputStream * The OutputStream the integer will be written to * @param integer * The integer to write * @throws IOException * Thrown if there is a problem writing to the OutputStream */ public static void writeInt(OutputStream outputStream, int integer) throws IOException { byte[] byteArray = convertToBytes(integer); outputStream.write(byteArray); return; }
/** * Writes a boolean out to an OutputStream. * * @param outputStream * The OutputStream the boolean will be written to * @param bVal * The boolean to write * @throws IOException * Thrown if there is a problem writing to the OutputStream */ public static void writeBoolean(OutputStream outputStream, boolean bVal) throws IOException { byte[] byteArray = convertToBytes(bVal); outputStream.write(byteArray); return; }
protected void write(int value) throws IOException { baos.write(deflate(ByteUtils.convertToBytes(value))); }
protected void write(long value) throws IOException { baos.write(deflate(ByteUtils.convertToBytes(value))); }
os.write(ByteUtils.convertToBytes(FormatVersion.SIGNATURE)); os.write(ByteUtils.convertToBytes(FormatVersion.VERSION)); os.write(ByteUtils.convertToBytes(classNum)); for (String key : classes.keySet()) { BinaryClassObject bco = classes.get(key); os.write(ByteUtils.convertToBytes(version)); os.write(ByteUtils.convertToBytes(classBytes.length)); os.write(classBytes); classTableSize += 4 + classBytes.length; os.write(ByteUtils.convertToBytes(bco.nameFields.size())); for (String fieldName : bco.nameFields.keySet()) { BinaryClassField bcf = bco.nameFields.get(fieldName); os.write(ByteUtils.convertToBytes(fNameBytes.length)); os.write(fNameBytes); classTableSize += 2 + 4 + fNameBytes.length; location += aliasSize; BinaryOutputCapsule cap = contentTable.get(savable).getContent(); out.write(ByteUtils.convertToBytes(cap.bytes.length)); location += 4; // length of bytes out.write(cap.bytes); os.write(ByteUtils.convertToBytes(numLocations)); int locationTableSize = 0;
protected void write(short value) throws IOException { baos.write(ByteUtils.convertToBytes(value)); }
public static byte[] convertToBytes(double n) { long bits = Double.doubleToLongBits(n); return convertToBytes(bits); }
protected void write(float value) throws IOException { baos.write(ByteUtils.convertToBytes(value)); }
protected void write(long value) throws IOException { baos.write(deflate(ByteUtils.convertToBytes(value))); }