public final class EncodingTools
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
INT_32_SIZE
The size of an INT_32 in bytes.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
readBoolean(byte[] in)
Read a boolean from a byte array.
|
static boolean |
readBoolean(byte[] in,
int offset)
Read a boolean from a byte array.
|
static boolean |
readBoolean(java.io.DataInput in)
Read a boolean from a DataInput.
|
static boolean |
readBoolean(java.io.InputStream in)
Read a boolean from an input stream.
|
static byte[] |
readBytes(int size,
java.io.DataInput in)
Read a fixed number of bytes from a DataInput into an array.
|
static byte[] |
readBytes(int size,
java.io.InputStream in)
Read a fixed number of bytes from an InputStream into an array.
|
static double |
readDouble(byte[] in)
Read a double from a byte array.
|
static double |
readDouble(byte[] in,
int offset)
Read a double from a byte array.
|
static double |
readDouble(java.io.DataInput in)
Read a double from a DataInput.
|
static double |
readDouble(java.io.InputStream in)
Read a double from an input stream.
|
static Entity |
readEntity(java.io.DataInput in)
Read an entity from a DataInput.
|
static Entity |
readEntity(java.io.InputStream in)
Read an entity from a stream.
|
static float |
readFloat32(java.io.DataInput in)
Read a 32-bit float from a DataInput.
|
static float |
readFloat32(java.io.InputStream in)
Read a 32-bit float from an input stream, big-endian style.
|
static int |
readInt32(byte[] in)
Read a 32-bit integer from a byte array, big-endian style.
|
static int |
readInt32(byte[] in,
int offset)
Read a 32-bit integer from a byte array, big-endian style.
|
static int |
readInt32(java.io.DataInput in)
Read a 32-bit integer from a DataInput.
|
static int |
readInt32(java.io.InputStream in)
Read a 32-bit integer from an input stream, big-endian style.
|
static int |
readInt32LE(java.io.InputStream in)
Read a 32-bit integer from an input stream, little-endian style.
|
static Message |
readMessage(java.io.DataInput in)
Read a message from a DataInput.
|
static Message |
readMessage(java.io.InputStream in)
Read a message from a stream.
|
static Property |
readProperty(java.io.DataInput in)
Read a property from a DataInput.
|
static Property |
readProperty(java.io.InputStream in)
Read a property from a stream.
|
static java.lang.String |
readString(byte[] in)
Read a String from a byte array.
|
static java.lang.String |
readString(byte[] in,
int offset)
Read a String from a byte array.
|
static java.lang.String |
readString(java.io.DataInput in)
Read a String from a DataInput.
|
static java.lang.String |
readString(java.io.InputStream in)
Read a String from an InputStream.
|
static void |
reallySkip(java.io.DataInput in,
int count)
Call DataInput.skip until exactly
count bytes have been
skipped. |
static void |
reallySkip(java.io.InputStream in,
long count)
Call InputStream.skip until exactly
count bytes have been
skipped. |
static void |
writeBoolean(boolean b,
byte[] out,
int offset)
Write a boolean to a byte array.
|
static void |
writeBoolean(boolean b,
java.io.DataOutput out)
Write a boolean to a DataOutput.
|
static void |
writeBoolean(boolean b,
java.io.OutputStream out)
Write a boolean to an OutputStream.
|
static void |
writeDouble(double d,
byte[] out,
int offset)
Write a double to a byte array.
|
static void |
writeDouble(double d,
java.io.DataOutput out)
Write a double to a DataOutput.
|
static void |
writeDouble(double d,
java.io.OutputStream out)
Write a double to an OutputStream.
|
static void |
writeEntity(Entity e,
java.io.DataOutput out)
Write an entity to a DataOutput.
|
static void |
writeEntity(Entity e,
java.io.OutputStream out)
Write an entity to a stream.
|
static void |
writeFloat32(float f,
byte[] out,
int offset)
Write a 32-bit float to a byte array, big-endian style.
|
static void |
writeFloat32(float f,
java.io.DataOutput out)
Write a 32-bit float to a DataOutput, big-endian style.
|
static void |
writeFloat32(float f,
java.io.OutputStream out)
Write a 32-bit float to an OutputStream, big-endian style.
|
static void |
writeInt32(int i,
byte[] out,
int offset)
Write a 32-bit integer to a byte array, big-endian style.
|
static void |
writeInt32(int i,
java.io.DataOutput out)
Write a 32-bit integer to a DataOutput, big-endian style.
|
static void |
writeInt32(int i,
java.io.OutputStream out)
Write a 32-bit integer to an OutputStream, big-endian style.
|
static void |
writeMessage(Message m,
java.io.DataOutput out)
Write a message to a DataOutput.
|
static void |
writeMessage(Message m,
java.io.OutputStream out)
Write a message to a stream.
|
static void |
writeProperty(Property p,
java.io.DataOutput out)
Write a property to a DataOutput.
|
static void |
writeProperty(Property p,
java.io.OutputStream out)
Write a property to a stream.
|
static void |
writeString(java.lang.String s,
byte[] out,
int offset)
Write a String to a byte array.
|
static void |
writeString(java.lang.String s,
java.io.DataOutput out)
Write a String to a DataOutput.
|
static void |
writeString(java.lang.String s,
java.io.OutputStream out)
Write a String to an OutputStream.
|
public static final int INT_32_SIZE
public static void writeInt32(int i, java.io.OutputStream out) throws java.io.IOException
i
- The integer to write.out
- The OutputStream to write it to.java.io.IOException
- If the OutputStream blows up.public static void writeInt32(int i, java.io.DataOutput out) throws java.io.IOException
i
- The integer to write.out
- The DataOutput to write it to.java.io.IOException
- If the DataOutput blows up.public static void writeInt32(int i, byte[] out, int offset)
i
- The integer to write.out
- The buffer to write it to.offset
- Where in the buffer to write it.public static int readInt32(java.io.InputStream in) throws java.io.IOException
in
- The InputStream to read from.java.io.IOException
- If the InputStream blows up.java.io.EOFException
- If the end of the stream is reached.public static int readInt32(java.io.DataInput in) throws java.io.IOException
in
- The DataInput to read from.java.io.IOException
- If the DataInput blows up.java.io.EOFException
- If the end of the stream is reached.public static int readInt32LE(java.io.InputStream in) throws java.io.IOException
in
- The InputStream to read from.java.io.IOException
- If the InputStream blows up.java.io.EOFException
- If the end of the stream is reached.public static int readInt32(byte[] in, int offset)
in
- The buffer to read from.offset
- Where to begin reading.public static int readInt32(byte[] in)
readInt32(in, 0)
.in
- The buffer to read from.public static void writeString(java.lang.String s, java.io.OutputStream out) throws java.io.IOException
s
- The String to write.out
- The OutputStream to write to.java.io.IOException
- If the OutputStream blows up.public static void writeString(java.lang.String s, java.io.DataOutput out) throws java.io.IOException
s
- The String to write.out
- The DataOutput to write to.java.io.IOException
- If the DataOutput blows up.public static void writeString(java.lang.String s, byte[] out, int offset)
s
- The String to write.out
- The byte array to write to. Make sure it's big enough!offset
- The index to start writing from.public static java.lang.String readString(java.io.InputStream in) throws java.io.IOException
in
- The InputStream to read.java.io.IOException
- If the InputStream blows up.java.io.EOFException
- If the end of the stream is reached.public static java.lang.String readString(java.io.DataInput in) throws java.io.IOException
in
- The DataInput to read.java.io.IOException
- If the DataInput blows up.java.io.EOFException
- If the end of the stream is reached.public static java.lang.String readString(byte[] in)
readString(in, 0)
.in
- The byte array to read.public static java.lang.String readString(byte[] in, int offset)
in
- The byte array to read.offset
- The index in the array to read from.public static byte[] readBytes(int size, java.io.InputStream in) throws java.io.IOException
size
- The number of bytes to read.in
- The InputStream to read from.java.io.IOException
- If the read operation fails.public static byte[] readBytes(int size, java.io.DataInput in) throws java.io.IOException
size
- The number of bytes to read.in
- The DataInput to read from.java.io.IOException
- If the read operation fails.public static void writeDouble(double d, java.io.OutputStream out) throws java.io.IOException
d
- The double to write.out
- The OutputStream to write it to.java.io.IOException
- If the OutputStream blows up.public static void writeDouble(double d, java.io.DataOutput out) throws java.io.IOException
d
- The double to write.out
- The DataOutput to write it to.java.io.IOException
- If the DataOutput blows up.public static void writeDouble(double d, byte[] out, int offset)
d
- The double to write.out
- The buffer to write it to.offset
- Where in the buffer to write it.public static double readDouble(java.io.InputStream in) throws java.io.IOException
in
- The InputStream to read from.java.io.IOException
- If the InputStream blows up.java.io.EOFException
- If the end of the stream is reached.public static double readDouble(java.io.DataInput in) throws java.io.IOException
in
- The DataInput to read from.java.io.IOException
- If the DataInput blows up.java.io.EOFException
- If the end of the stream is reached.public static double readDouble(byte[] in, int offset)
in
- The buffer to read from.offset
- Where to begin reading.public static double readDouble(byte[] in)
readDouble(in, 0)
.in
- The buffer to read from.public static void writeBoolean(boolean b, java.io.OutputStream out) throws java.io.IOException
b
- The boolean to write.out
- The OutputStream to write it to.java.io.IOException
- If the OutputStream blows up.public static void writeBoolean(boolean b, java.io.DataOutput out) throws java.io.IOException
b
- The boolean to write.out
- The DataOutput to write it to.java.io.IOException
- If the DataOutput blows up.public static void writeBoolean(boolean b, byte[] out, int offset)
b
- The boolean to write.out
- The buffer to write it to.offset
- Where in the buffer to write it.public static boolean readBoolean(java.io.InputStream in) throws java.io.IOException
in
- The InputStream to read from.java.io.IOException
- If the InputStream blows up.java.io.EOFException
- If the end of the stream is reached.public static boolean readBoolean(java.io.DataInput in) throws java.io.IOException
in
- The DataInput to read from.java.io.IOException
- If the DataInput blows up.java.io.EOFException
- If the end of the stream is reached.public static boolean readBoolean(byte[] in, int offset)
in
- The buffer to read from.offset
- Where to begin reading.public static boolean readBoolean(byte[] in)
readBoolean(in, 0)
.in
- The buffer to read from.public static void reallySkip(java.io.InputStream in, long count) throws java.io.IOException
count
bytes have been
skipped. If InputStream.skip ever returns a negative number then an
EOFException is thrown.in
- The InputStream to skip.count
- The number of bytes to skip.java.io.IOException
- If the bytes cannot be skipped for some reason.public static void reallySkip(java.io.DataInput in, int count) throws java.io.IOException
count
bytes have been
skipped. If DataInput.skip ever returns a negative number then an
EOFException is thrown.in
- The DataInput to skip.count
- The number of bytes to skip.java.io.IOException
- If the bytes cannot be skipped for some reason.public static void writeEntity(Entity e, java.io.OutputStream out) throws java.io.IOException
e
- The entity to write.out
- The OutputStream to write to.java.io.IOException
- If there is a problem writing to the stream.public static void writeEntity(Entity e, java.io.DataOutput out) throws java.io.IOException
e
- The entity to write.out
- The DataOutput to write to.java.io.IOException
- If there is a problem writing to the stream.public static Entity readEntity(java.io.InputStream in) throws java.io.IOException
in
- The InputStream to read from.java.io.IOException
- If there is a problem reading from the stream.public static Entity readEntity(java.io.DataInput in) throws java.io.IOException
in
- The DataInput to read from.java.io.IOException
- If there is a problem reading from the stream.public static void writeProperty(Property p, java.io.OutputStream out) throws java.io.IOException
p
- The property to write.out
- The OutputStream to write to.java.io.IOException
- If there is a problem writing to the stream.public static void writeProperty(Property p, java.io.DataOutput out) throws java.io.IOException
p
- The property to write.out
- The DataOutput to write to.java.io.IOException
- If there is a problem writing to the stream.public static Property readProperty(java.io.InputStream in) throws java.io.IOException
in
- The InputStream to read from.java.io.IOException
- If there is a problem reading from the stream.public static Property readProperty(java.io.DataInput in) throws java.io.IOException
in
- The DataInput to read from.java.io.IOException
- If there is a problem reading from the stream.public static void writeMessage(Message m, java.io.OutputStream out) throws java.io.IOException
m
- The message to write.out
- The OutputStream to write to.java.io.IOException
- If there is a problem writing to the stream.public static void writeMessage(Message m, java.io.DataOutput out) throws java.io.IOException
m
- The message to write.out
- The DataOutput to write to.java.io.IOException
- If there is a problem writing to the stream.public static Message readMessage(java.io.InputStream in) throws java.io.IOException
in
- The InputStream to read from.java.io.IOException
- If there is a problem reading from the stream.public static Message readMessage(java.io.DataInput in) throws java.io.IOException
in
- The DataInput to read from.java.io.IOException
- If there is a problem reading from the stream.public static float readFloat32(java.io.InputStream in) throws java.io.IOException
in
- The InputStream to read from.java.io.IOException
- If the InputStream blows up.java.io.EOFException
- If the end of the stream is reached.public static void writeFloat32(float f, java.io.OutputStream out) throws java.io.IOException
f
- The float to write.out
- The OutputStream to write it to.java.io.IOException
- If the OutputStream blows up.public static void writeFloat32(float f, java.io.DataOutput out) throws java.io.IOException
f
- The float to write.out
- The DataOutput to write it to.java.io.IOException
- If the DataOutput blows up.public static void writeFloat32(float f, byte[] out, int offset)
f
- The float to write.out
- The buffer to write it to.offset
- Where in the buffer to write it.public static float readFloat32(java.io.DataInput in) throws java.io.IOException
in
- The DataInput to read from.java.io.IOException
- If the DataInput blows up.java.io.EOFException
- If the end of the stream is reached.