|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.planx.xmlstore.io.Streamers
public final class Streamers
Tools for Streamers and writing to DataOutput and reading
from DataInput.
| Method Summary | ||
|---|---|---|
static
|
fromByteArray(byte[] b,
Streamer<E> streamer)
|
|
static
|
getPolymorphicStreamer(Class<E> cls)
Returns a PolymorphicStreamer for the specified class. |
|
static
|
readList(DataInput in,
Streamer<E> s)
Reads an immutable List of objects, where the specified
Streamer is capable of reading each object in the list. |
|
static int[] |
readPosArray(DataInput in)
Reads data written by writePosArray(java.io.DataOutput, int[]). |
|
static int |
readShortInt(DataInput in)
Reads an int written by the writeShortInt
method. |
|
static String |
readUTF(DataInput in)
Reads a String written by
writeUTF(DataOutput,String). |
|
static String |
readUTF(DataInput in,
int utflen)
Reads a String written by
writeUTF(DataOutput,String,int). |
|
static int |
shortIntSize(int i)
Returns the number of bytes that will be written by the writeShortInt(java.io.DataOutput, int) method for the specified int. |
|
static Streamer<String> |
stringStreamer()
|
|
static
|
toByteArray(E obj,
Streamer<E> streamer)
|
|
static boolean |
unwrapNull(DataInput in)
Reads a truth value written by wrapNull(java.io.DataOutput, java.lang.Object) and returns it. |
|
static int |
utfSize(String s)
Return the number of bytes that will be written by the writeUTF(java.io.DataOutput, java.lang.String) method
for the specified String. |
|
static boolean |
wrapNull(DataOutput out,
Object o)
Writes false to the output if the object was
null and true if the object was
non-null. |
|
static
|
writeList(DataOutput out,
List<E> l,
Streamer<E> s)
Writes a list of objects where the specified Streamer is
capable of writing each object contained in the List. |
|
static void |
writePosArray(DataOutput out,
int[] arr)
The ints in the array must be positive, and if an
int is smaller than 128, only a single byte is written
to represent it. |
|
static void |
writeShortInt(DataOutput out,
int i)
Writes an int. |
|
static void |
writeUTF(DataOutput out,
String s)
Writes a String of any size in Java modified UTF format. |
|
static void |
writeUTF(DataOutput out,
String s,
int utflen)
Writes a String of any size in Java modified UTF format. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static <E> PolymorphicStreamer<E> getPolymorphicStreamer(Class<E> cls)
PolymorphicStreamer for the specified class.
This is useful for maintaining the ability to stream the subtypes
of various implementations of classes. Each implementation should
make sure to register its sub-classes with the
PolymorphicStreamer of the appropriate super class
before any other part of the system needs to stream its sub-classes.
public static Streamer<String> stringStreamer()
public static int utfSize(String s)
writeUTF(java.io.DataOutput, java.lang.String) method
for the specified String.
public static void writeUTF(DataOutput out,
String s)
throws IOException
String of any size in Java modified UTF format.
Note, that DataOutput.writeUTF(java.lang.String) has a maximum UTF size of
65535 bytes.
IOException
public static void writeUTF(DataOutput out,
String s,
int utflen)
throws IOException
String of any size in Java modified UTF format.
Note, that DataOutput.writeUTF(java.lang.String) has a maximum UTF size of
65535 bytes.
IOException
public static String readUTF(DataInput in)
throws IOException
String written by
writeUTF(DataOutput,String).
IOException
public static String readUTF(DataInput in,
int utflen)
throws IOException
String written by
writeUTF(DataOutput,String,int).
IOException
public static <E> byte[] toByteArray(E obj,
Streamer<E> streamer)
throws IOException
IOException
public static <E> E fromByteArray(byte[] b,
Streamer<E> streamer)
throws IOException
IOExceptionpublic static int shortIntSize(int i)
writeShortInt(java.io.DataOutput, int) method for the specified int.
public static void writeShortInt(DataOutput out,
int i)
throws IOException
int. If 0 <= i < 128 then only
a single byte is written. If i >= 128 4 bytes are
written. If i < 0 an IllegalArgumentException
is thrown.
IOException
public static int readShortInt(DataInput in)
throws IOException
int written by the writeShortInt
method.
IOException
public static void writePosArray(DataOutput out,
int[] arr)
throws IOException
ints in the array must be positive, and if an
int is smaller than 128, only a single byte is written
to represent it.
IOException
public static int[] readPosArray(DataInput in)
throws IOException
writePosArray(java.io.DataOutput, int[]).
IOException
public static <E> void writeList(DataOutput out,
List<E> l,
Streamer<E> s)
throws IOException
Streamer is
capable of writing each object contained in the List.
A NullPointerException is thrown if the list is
null.
IOException
public static <E> List<E> readList(DataInput in,
Streamer<E> s)
throws IOException
List of objects, where the specified
Streamer is capable of reading each object in the list.
IOException
public static boolean wrapNull(DataOutput out,
Object o)
throws IOException
false to the output if the object was
null and true if the object was
non-null.
IOException
public static boolean unwrapNull(DataInput in)
throws IOException
wrapNull(java.io.DataOutput, java.lang.Object) and returns it.
If false is returned the object was null and
should therefore not be read from the input.
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||