|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.planx.io.Streamers
public final class Streamers
Tools for Streamers and writing to DataOutput and reading
from DataInput.
| Method Summary | ||
|---|---|---|
static Streamer<byte[]> |
byteArrayStreamer()
|
|
static int |
compactIntSize(int i)
Returns the number of bytes that will be written by the writeCompactInt(java.io.DataOutput, int) method for the specified int. |
|
static int |
compactLongSize(long i)
Returns the number of bytes that will be written by the writeCompactLong(java.io.DataOutput, long) method for the specified long. |
|
static
|
fromByteArray(byte[] b,
Streamer<E> streamer)
|
|
static
|
getPolymorphicStreamer(Class<E> cls)
Returns a PolymorphicStreamer for the specified class. |
|
static Streamer<Long> |
longStreamer()
|
|
static
|
mapStreamer(SizeStreamer<K> keyStreamer,
SizeStreamer<V> valueStreamer,
Class<M> mapCls)
|
|
static int |
readCompactInt(DataInput in)
Reads a variable sized int written by the
writeCompactInt(java.io.DataOutput, int) method. |
|
static long |
readCompactLong(DataInput in)
Reads a variable sized long written by the
writeCompactLong(java.io.DataOutput, long) method. |
|
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 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 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 void |
writeCompactInt(DataOutput out,
int i)
Writes a variable sized int. |
|
static void |
writeCompactLong(DataOutput out,
long i)
Writes a variable sized long. |
|
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 |
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 |
|---|
equals, 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 Streamer<Long> longStreamer()
public static Streamer<byte[]> byteArrayStreamer()
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 compactIntSize(int i)
writeCompactInt(java.io.DataOutput, int) method for the specified int.
public static void writeCompactInt(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 readCompactInt(DataInput in)
throws IOException
int written by the
writeCompactInt(java.io.DataOutput, int) method.
IOExceptionpublic static int compactLongSize(long i)
writeCompactLong(java.io.DataOutput, long) method for the specified long.
public static void writeCompactLong(DataOutput out,
long i)
throws IOException
long. If 0 <= i < 128
then only a single byte is written. If i >= 128 8 bytes are
written. If i < 0 an IllegalArgumentException
is thrown.
IOException
public static long readCompactLong(DataInput in)
throws IOException
long written by the
writeCompactLong(java.io.DataOutput, long) 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 <K,V,M extends Map<K,V>> SizeStreamer<Map<K,V>> mapStreamer(SizeStreamer<K> keyStreamer,
SizeStreamer<V> valueStreamer,
Class<M> mapCls)
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 | |||||||||