TypeWriterpublic class TypeWriter extends Object Class for writing little-endian data and more. |
Methods Summary |
---|
public static int | writeToStream(java.io.OutputStream out, short n)Writes a two-byte value (short) to an output stream.
final int length = LittleEndian.SHORT_SIZE;
byte[] buffer = new byte[length];
LittleEndian.putShort(buffer, 0, n); // FIXME: unsigned
out.write(buffer, 0, length);
return length;
| public static int | writeToStream(java.io.OutputStream out, int n)Writes a four-byte value to an output stream.
final int l = LittleEndian.INT_SIZE;
final byte[] buffer = new byte[l];
LittleEndian.putInt(buffer, 0, n);
out.write(buffer, 0, l);
return l;
| public static int | writeToStream(java.io.OutputStream out, long n)Writes a eight-byte value to an output stream.
final int l = LittleEndian.LONG_SIZE;
final byte[] buffer = new byte[l];
LittleEndian.putLong(buffer, 0, n);
out.write(buffer, 0, l);
return l;
| public static int | writeToStream(java.io.OutputStream out, org.apache.poi.hpsf.ClassID n)Writes a 16-byte {@link ClassID} to an output stream.
byte[] b = new byte[16];
n.write(b, 0);
out.write(b, 0, b.length);
return b.length;
| public static void | writeToStream(java.io.OutputStream out, org.apache.poi.hpsf.Property[] properties, int codepage)Writes an array of {@link Property} instances to an output stream
according to the Horrible Property Stream Format.
/* If there are no properties don't write anything. */
if (properties == null)
return;
/* Write the property list. This is a list containing pairs of property
* ID and offset into the stream. */
for (int i = 0; i < properties.length; i++)
{
final Property p = properties[i];
writeUIntToStream(out, p.getID());
writeUIntToStream(out, p.getSize());
}
/* Write the properties themselves. */
for (int i = 0; i < properties.length; i++)
{
final Property p = properties[i];
long type = p.getType();
writeUIntToStream(out, type);
VariantSupport.write(out, (int) type, p.getValue(), codepage);
}
| public static int | writeToStream(java.io.OutputStream out, double n)Writes a double value value to an output stream.
final int l = LittleEndian.DOUBLE_SIZE;
final byte[] buffer = new byte[l];
LittleEndian.putDouble(buffer, 0, n);
out.write(buffer, 0, l);
return l;
| public static int | writeUIntToStream(java.io.OutputStream out, long n)Writes an unsigned four-byte value to an output stream.
long high = n & 0xFFFFFFFF00000000L;
if (high != 0 && high != 0xFFFFFFFF00000000L)
throw new IllegalPropertySetDataException
("Value " + n + " cannot be represented by 4 bytes.");
return writeToStream(out, (int) n);
| public static void | writeUShortToStream(java.io.OutputStream out, int n)Writes an unsigned two-byte value to an output stream.
int high = n & 0xFFFF0000;
if (high != 0)
throw new IllegalPropertySetDataException
("Value " + n + " cannot be represented by 2 bytes.");
writeToStream(out, (short) n);
|
|