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
Nested ClassesModifier and TypeClassDescriptionstatic interfaceObject reader interfacestatic interfaceObject 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 intReads an int value from the given data input.static int[]Read anint[]array from the data input.static longReads a long value from the given data input.static long[]Read along[]array from the data input.static <T> TreadNullable(SerialIO.Reader<? extends T> reader, DataInput in) Reads a possiblenullvalue from the given data input.static StringReads 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 StringreadString(DataInput in) Reads a string value from the given data input.static voidwriteBytes(byte[] bytes, DataOutput out) static voidwriteCharArray(char[] values, DataOutput out) Write the givenchar[]array to the given data output.static voidwriteDoubleArray(double[] values, DataOutput out) Write the givendouble[]array to the given data output.static voidwriteInt(int value, DataOutput out) Writes an int value to a series of bytes.static voidwriteIntArray(int[] values, DataOutput out) Write the givenint[]array to the given data output.static voidwriteLong(long value, DataOutput out) Writes a long value to a series of bytes.static voidwriteLongArray(long[] values, DataOutput out) Write the givenlong[]array to the given data output.static <T> voidwriteNullable(T value, SerialIO.Writer<? super T> writer, DataOutput out) Write the given, possiblenull,valueto the data output using the givenwriter.static voidwriteNullableString(String value, DataOutput out) Write the given string, possiblenull,valueto the given data output.static voidwriteObjectArray(Object[] values, ObjectOutput out) Write the givenObject[]array to the given data output.static <T> voidwrites(Collection<? extends T> elements, SerialIO.Writer<? super T> writer, DataOutput out) Write the given elements to the data output.static voidwriteString(String value, DataOutput out) Write the given stringvalueto 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,valueto 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 thewriteror data output isnullIOException- if an I/O error occurs
-
readNullable
public static <T> T readNullable(SerialIO.Reader<? extends T> reader, DataInput in) throws IOException Reads a possiblenullvalue 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 isnullIOException- if an I/O error occurs
-
writeString
Write the given stringvalueto the given data output.- Parameters:
value- the string value to writeout- the data output- Throws:
NullPointerException- if one of the given arguments isnullIOException- 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 isnullIOException- if an I/O error occurs
-
writeNullableString
Write the given string, possiblenull,valueto the given data output.- Parameters:
value- the string value to writeout- the data output- Throws:
NullPointerException- if the given data output isnullIOException- 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 isnullIOException- 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 isnullIOException- 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 isnullIOException- 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. Eachintvalue 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 isnullIOException- 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 isnullIOException- 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. Eachlongvalue 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 isnullIOException- 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 isnullIOException- 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
-