public interface OdinReader
extends java.io.Closeable
Modifier and Type | Method and Description |
---|---|
boolean |
hasNext()
Indicates whether there is any data left in the current object.
If comments is present before the next data, it will be skipped. |
<T> T |
read()
Read value from the current object without any generic type, if no type definition is present before the value in the stream a simple Class<Object> is used as type, so only
null, primitives, Object, Object[] or recursive object can be return.
If a type definition is present the reader will use it |
OdinArray |
readArray()
Read Odin Array and all extra if present
|
boolean |
readBoolean()
Read next element as a boolean
|
byte |
readByte()
Read next element as a byte
|
char |
readChar()
Read next element as a char
|
double |
readDouble()
Read next element as a double
|
OdinFieldReader |
readField(java.lang.String name)
Read field with the given name, this method add in cache the field to read and return an
OdinFieldReader in order to set listener.All listener of an object are called after the adapter process, or in case of main reader, when the close method is called. Other read methods doesn't known if the next element is a field and try to read it as a value, so the following code does not work : |
float |
readFloat()
Read next element as a float
|
int |
readInt()
Read next element as a int
|
java.lang.String |
readKey()
Read next element as a key
|
long |
readLong()
Read next element as a long
|
java.lang.String |
readNextKey()
Read all next elements until the next key, this method return null if the object contains no more key
|
OdinNode |
readNode()
Read Odin Node and all extra if present
|
<T> OdinObject<T> |
readObject()
Read Odin object and it's extra if present
|
OdinRowReader |
readRow()
This method return a
OdinRowReader in order to read row values.A row need to have at least one value, you can use OdinRowReader.hasRowNext() to test if there are remaining values in the current row. |
short |
readShort()
Read next element as a short
|
java.lang.String |
readString()
Read next element as a String
|
void |
readSubContent(IOConsumer<OdinReader> subReader)
Use a consumer to read content of a sub object.
|
<T> T |
readTo(T o)
Read value to a given object instance, if a type definition is present in the input stream it will be skip to use the given instance type.
This method is not recursive, so all object fields are set with new object instances according to the stream content. If the object is null this method do the same as read() .If the field is a primitive, this method return his new value. If the object use a inline or a immutable adapter, this method return a new object instance |
<T> T |
readTo(T o,
AnyType<T> type)
Read value to a given object instance, if a type definition is present in the input stream it will be skip to use the given instance type.
This method is not recursive, so all object fields are set with new object instances according to the stream content. If the object is null this method do the same as readTyped(AnyType) and use the given type.If the field is a primitive, this method return his new value. If the object use a inline or a immutable adapter, this method return a new object instance. |
<T> T |
readTo(T o,
java.lang.reflect.Type type)
Read value to a given object instance, if a type definition is present in the input stream it will be skip to use the given instance type.
This method is not recursive, so all object fields are set with new object instances according to the stream content. If the object is null this method do the same as readTyped(Type) and use the given type.If the field is a primitive, this method return his new value. If the object use a inline or a immutable adapter, this method return a new object instance. |
<T> T |
readTyped(AnyType<T> type)
Read value using given generic type, if a type definition is present in the input stream it will be used as object type.
This method take a odin type to be use inside adapter by using ObjectType.getField(String) or all other field getter and
TypeField.getType() |
<T> T |
readTyped(java.lang.reflect.Type type)
Read value using given generic type, if a type definition is present in the input stream it will be used as object type.
Custom type can be created to add generic argument ( can be useful for collection ) using TypeBuilder . |
OdinNode readNode() throws java.io.IOException
java.io.IOException
- if an IO exception occurOdinFormatException
- if the reader reach an invalid element delimiter or wrong element formatOdinTypeException
- if the type adapter can not be build for an objectOdinAdapterException
- if a runtime exception is throw by an adapter when reading the objectOdinArray readArray() throws java.io.IOException
java.io.IOException
- if a IO exception occurOdinFormatException
- if the reader reach an invalid element delimiter or wrong element formatOdinTypeException
- if the type adapter can not be build for an objectOdinAdapterException
- if a runtime exception is throw by an adapter when reading the object<T> OdinObject<T> readObject() throws java.io.IOException
T
- the object content typejava.io.IOException
- if IO exception occurOdinFormatException
- if the reader reach an invalid element delimiter or wrong element formatOdinTypeException
- if the type adapter can not be build for an objectOdinAdapterException
- if a runtime exception is throw by an adapter when reading the objectboolean hasNext() throws java.io.IOException
java.io.IOException
- if an IO exception occurjava.lang.String readKey() throws java.io.IOException
java.io.IOException
- if an IO exception occurOdinFormatException
- if next element is not an field keyjava.lang.String readNextKey() throws java.io.IOException
java.io.IOException
- if an IO exception occurboolean readBoolean() throws java.io.IOException
java.io.IOException
- if an IO exception occurOdinFormatException
- if next element was not a valid booleanbyte readByte() throws java.io.IOException
java.io.IOException
- if an IO exception occurOdinFormatException
- if next element was not a valid numbershort readShort() throws java.io.IOException
java.io.IOException
- if an IO exception occurOdinFormatException
- if next element was not a valid numberint readInt() throws java.io.IOException
java.io.IOException
- if an IO exception occurOdinFormatException
- if next element was not a valid numberlong readLong() throws java.io.IOException
java.io.IOException
- if an IO exception occurOdinFormatException
- if next element was not a valid numberfloat readFloat() throws java.io.IOException
java.io.IOException
- if an IO exception occurOdinFormatException
- if next element was not a valid numberdouble readDouble() throws java.io.IOException
java.io.IOException
- if an IO exception occurOdinFormatException
- if next element was not a valid numberchar readChar() throws java.io.IOException
java.io.IOException
- if an IO exception occurOdinFormatException
- if next element was not a valid charjava.lang.String readString() throws java.io.IOException
java.io.IOException
- if an IO exception occurOdinFormatException
- if next element was not a valid String<T> T read() throws java.io.IOException
T
- object typejava.io.IOException
- if an IO exception occurOdinFormatException
- if the reader reach an invalid element delimiter or wrong element formatOdinTypeException
- if the type adapter can not be build for an objectOdinAdapterException
- if a runtime exception is throw by an adapter when reading the object<T> T readTo(T o) throws java.io.IOException
read()
.T
- object typeo
- object instancejava.io.IOException
- if an IO exception occurOdinFormatException
- if the reader reach an invalid element delimiter or wrong element formatOdinTypeException
- if the type adapter can not be build for an objectOdinAdapterException
- if a runtime exception is throw by an adapter when reading the object<T> T readTo(T o, AnyType<T> type) throws java.io.IOException
readTyped(AnyType)
and use the given type.readTo(Object)
by his security for null object case, if the object is null and the input stream doesn't contains the type definition, the given type is used
instead of Object classT
- object typeo
- object instancetype
- object typejava.io.IOException
- if an IO exception occurOdinFormatException
- if the reader reach an invalid element delimiter or wrong element formatOdinTypeException
- if the type adapter can not be build for an objectOdinAdapterException
- if a runtime exception is throw by an adapter when reading the object<T> T readTo(T o, java.lang.reflect.Type type) throws java.io.IOException
readTyped(Type)
and use the given type.readTo(Object)
by his security for null object case, if the object is null and the input stream doesn't contains the type definition, the given type is used
instead of Object classT
- object typeo
- object instancetype
- object typejava.io.IOException
- if an IO exception occurOdinFormatException
- if the reader reach an invalid element delimiter or wrong element formatOdinTypeException
- if the type adapter can not be build for an objectOdinAdapterException
- if a runtime exception is throw by an adapter when reading the object<T> T readTyped(AnyType<T> type) throws java.io.IOException
ObjectType.getField(String)
or all other field getter and
TypeField.getType()
T
- object typetype
- generic typejava.io.IOException
- if an IO exception occurOdinFormatException
- if the reader reach an invalid element delimiter or wrong element formatOdinTypeException
- if the type adapter can not be build for an objectOdinAdapterException
- if a runtime exception is throw by an adapter when reading the object<T> T readTyped(java.lang.reflect.Type type) throws java.io.IOException
TypeBuilder
.T
- object typetype
- generic typejava.io.IOException
- if an IO exception occurOdinFormatException
- if the reader reach an invalid element delimiter or wrong element formatOdinTypeException
- if the type adapter can not be buildOdinAdapterException
- if a runtime exception is throw by an adapter when reading the objectvoid readSubContent(IOConsumer<OdinReader> subReader) throws java.io.IOException
subReader
- the sub reader consumerjava.io.IOException
- if an IO exception occurOdinFieldReader readField(java.lang.String name)
OdinFieldReader
in order to set listener. {
key = 1
10
}
reader.readField("key").getInt((Integer i) -> this.v = i);
reader.readInt(); // trying to read "key" as a int and throw an IllegalStateException
In general, never mix field and value inside an object.name
- field nameOdinRowReader readRow() throws java.io.IOException
OdinRowReader
in order to read row values.OdinRowReader.hasRowNext()
to test if there are remaining values in the current row.java.io.IOException
- if an IO exception occur