java.lang.Object
io.jenetics.internal.util.SerialIO
Helper methods needed for implementing the Java serializations.
- Since:
- 5.0
- Version:
- 5.0
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Object reader interfacestatic interface
Object writer interface. -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
static char[]
Read anchar[]
array from the data input.static double[]
Read adouble[]
array from the data input.static int
Reads an int value from the given data input.static int[]
Read anint[]
array from the data input.static long
Reads a long value from the given data input.static long[]
Read along[]
array from the data input.static <T> T
readNullable
(SerialIO.Reader<? extends T> reader, DataInput in) Reads a possiblenull
value from the given data input.static String
Reads a, possiblenull
, string value from the given data input.static Object[]
Read anObject[]
array from the data input.static <T> List<T>
reads
(SerialIO.Reader<? extends T> reader, DataInput in) Reads a list of elements from the given data input.static String
readString
(DataInput in) Reads a string value from the given data input.static void
writeBytes
(byte[] bytes, DataOutput out) static void
writeCharArray
(char[] values, DataOutput out) Write the givenchar[]
array to the given data output.static void
writeDoubleArray
(double[] values, DataOutput out) Write the givendouble[]
array to the given data output.static void
writeInt
(int value, DataOutput out) Writes an int value to a series of bytes.static void
writeIntArray
(int[] values, DataOutput out) Write the givenint[]
array to the given data output.static void
writeLong
(long value, DataOutput out) Writes a long value to a series of bytes.static void
writeLongArray
(long[] values, DataOutput out) Write the givenlong[]
array to the given data output.static <T> void
writeNullable
(T value, SerialIO.Writer<? super T> writer, DataOutput out) Write the given, possiblenull
,value
to the data output using the givenwriter
.static void
writeNullableString
(String value, DataOutput out) Write the given string, possiblenull
,value
to the given data output.static void
writeObjectArray
(Object[] values, ObjectOutput out) Write the givenObject[]
array to the given data output.static <T> void
writes
(Collection<? extends T> elements, SerialIO.Writer<? super T> writer, DataOutput out) Write the given elements to the data output.static void
writeString
(String value, DataOutput out) Write the given stringvalue
to the given data output.
-
Method Details
-
writeNullable
public static <T> void writeNullable(T value, SerialIO.Writer<? super T> writer, DataOutput out) throws IOException Write the given, possiblenull
,value
to the data output using the givenwriter
.- Type Parameters:
T
- the object type- Parameters:
value
- the, possiblenull
, value to writewriter
- the object writerout
- the data output- Throws:
NullPointerException
- if thewriter
or data output isnull
IOException
- if an I/O error occurs
-
readNullable
public static <T> T readNullable(SerialIO.Reader<? extends T> reader, DataInput in) throws IOException Reads a possiblenull
value from the given data input.- Type Parameters:
T
- the object type- Parameters:
reader
- the object readerin
- the data input- Returns:
- the read object
- Throws:
NullPointerException
- if one of the given arguments isnull
IOException
- if an I/O error occurs
-
writeString
Write the given stringvalue
to the given data output.- Parameters:
value
- the string value to writeout
- the data output- Throws:
NullPointerException
- if one of the given arguments isnull
IOException
- if an I/O error occurs
-
readString
Reads a string value from the given data input.- Parameters:
in
- the data input- Returns:
- the read string value
- Throws:
NullPointerException
- if one of the given arguments isnull
IOException
- if an I/O error occurs
-
writeNullableString
Write the given string, possiblenull
,value
to the given data output.- Parameters:
value
- the string value to writeout
- the data output- Throws:
NullPointerException
- if the given data output isnull
IOException
- if an I/O error occurs
-
readNullableString
Reads a, possiblenull
, string value from the given data input.- Parameters:
in
- the data input- Returns:
- the read string value
- Throws:
NullPointerException
- if one of the given arguments isnull
IOException
- if an I/O error occurs
-
writes
public static <T> void writes(Collection<? extends T> elements, SerialIO.Writer<? super T> writer, DataOutput out) throws IOException Write the given elements to the data output.- Type Parameters:
T
- the element type- Parameters:
elements
- the elements to writewriter
- the element writerout
- the data output- Throws:
NullPointerException
- if one of the given arguments isnull
IOException
- if an I/O error occurs
-
reads
public static <T> List<T> reads(SerialIO.Reader<? extends T> reader, DataInput in) throws IOException Reads a list of elements from the given data input.- Type Parameters:
T
- the element type- Parameters:
reader
- the element readerin
- the data input- Returns:
- the read element list
- Throws:
NullPointerException
- if one of the given arguments isnull
IOException
- if an I/O error occurs
-
writeBytes
- Throws:
IOException
-
readBytes
- Throws:
IOException
-
writeInt
Writes an int value to a series of bytes. The values are written using variable-length zig-zag coding. Eachint
value is written in 1 to 5 bytes.- Parameters:
value
- the integer value to writeout
- the data output the integer value is written to- Throws:
NullPointerException
- if the given data output isnull
IOException
- if an I/O error occurs- See Also:
-
readInt
Reads an int value from the given data input. The integer value must have been written by thewriteInt(int, DataOutput)
before.- Parameters:
in
- the data input where the integer value is read from- Returns:
- the read integer value
- Throws:
NullPointerException
- if the given data input isnull
IOException
- if an I/O error occurs- See Also:
-
writeLong
Writes a long value to a series of bytes. The values are written using variable-length zig-zag coding. Eachlong
value is written in 1 to 10 bytes.- Parameters:
value
- the long value to writeout
- the data output the integer value is written to- Throws:
NullPointerException
- if the given data output isnull
IOException
- if an I/O error occurs- See Also:
-
readLong
Reads a long value from the given data input. The integer value must have been written by thewriteInt(int, DataOutput)
before.- Parameters:
in
- the data input where the integer value is read from- Returns:
- the read long value
- Throws:
NullPointerException
- if the given data input isnull
IOException
- if an I/O error occurs- See Also:
-
writeIntArray
Write the givenint[]
array to the given data output.- Parameters:
values
- the values to writeout
- the data sink- Throws:
IOException
- if an I/O error occurs
-
writeCharArray
Write the givenchar[]
array to the given data output.- Parameters:
values
- the values to writeout
- the data sink- Throws:
IOException
- if an I/O error occurs
-
writeLongArray
Write the givenlong[]
array to the given data output.- Parameters:
values
- the values to writeout
- the data sink- Throws:
IOException
- if an I/O error occurs
-
writeDoubleArray
Write the givendouble[]
array to the given data output.- Parameters:
values
- the values to writeout
- the data sink- Throws:
IOException
- if an I/O error occurs
-
readCharArray
Read anchar[]
array from the data input.- Parameters:
in
- the data source- Returns:
- the read values
- Throws:
IOException
- if an I/O error occurs
-
readIntArray
Read anint[]
array from the data input.- Parameters:
in
- the data source- Returns:
- the read values
- Throws:
IOException
- if an I/O error occurs
-
readLongArray
Read along[]
array from the data input.- Parameters:
in
- the data source- Returns:
- the read values
- Throws:
IOException
- if an I/O error occurs
-
readDoubleArray
Read adouble[]
array from the data input.- Parameters:
in
- the data source- Returns:
- the read values
- Throws:
IOException
- if an I/O error occurs
-
writeObjectArray
Write the givenObject[]
array to the given data output.- Parameters:
values
- the values to writeout
- the data sink- Throws:
IOException
- if an I/O error occurs
-
readObjectArray
Read anObject[]
array from the data input.- Parameters:
in
- the data source- Returns:
- the read values
- Throws:
IOException
- if an I/O error occursClassNotFoundException
- if the class can't be loaded
-