public interface OdinWriter
extends java.io.Closeable
Modifier and Type | Method and Description |
---|---|
void |
compressSubObjects()
Say to current writer that all sub objects need to be written using inline format.
If this writer is already an inline or a compressed writer, this method do nothing. Inline format use ', ' and ' = ' as separator : |
void |
indentSubObjects()
Say to current writer that all sub object can be rewritten using indented format, this method can be call after
compressSubObjects() to reset format.If this writer is not an indented writer, this method do nothing |
void |
write(java.lang.Object o)
Write an object, if object is not a primitive or a
Object , the type definition is added before the object. |
void |
writeArray(OdinArray array)
Write Odin array, if writer is indented all odin
OdinExtra are write before elements |
void |
writeBoolean(boolean value)
Write a boolean
|
void |
writeByte(byte value)
Write a byte
|
void |
writeChar(char value)
Write a char
|
void |
writeComment(java.util.List<java.lang.String> comments)
Write multiple comment lines, if this writer use compressed output, this method do nothing.
|
void |
writeComment(java.lang.String comment)
Write a comment line, if this writer use compressed output, this method do nothing.
|
void |
writeComment(java.lang.String[] comments)
Write multiple comment lines, if this writer use compressed output, this method do nothing.
|
void |
writeDouble(double value)
Write a double
|
OdinFieldWriter |
writeField(java.lang.String name)
Write a new field with the given field name
|
void |
writeFloat(float value)
Write a float
|
void |
writeInt(int value)
Write a int
|
void |
writeLong(long value)
Write a long
|
void |
writeNode(OdinNode node)
Write Odin node, if writer is indented all odin
OdinExtra are write before elements |
void |
writeObject(OdinObject object)
Write Odin object, if writer is indented odin
OdinExtra was write before this object |
OdinRowWriter |
writeRow()
Write a new row, while there are no new call to this method, all value added using
OdinRowWriter is write to same row |
void |
writeShort(short value)
Write a short
|
void |
writeString(java.lang.String value)
Write a String
|
void |
writeSubContent(IOConsumer<OdinWriter> subWriter)
Use a consumer to write content to a sub object.
|
void |
writeTyped(java.lang.Object o,
java.lang.reflect.Type type)
Write an object, odin get the
AnyType associated to the given type, if the object class is not the same than type class, like implementation,
the type definition is added before the object.Custom type can be created to add generic argument ( can be useful for collection ) using TypeBuilder . |
<T> void |
writeTyped(T o,
AnyType<T> type)
Write an object, if the object class is not the same than type class, like implementation, the type definition is added before the object.
This method take a odin type to be use inside adapter by using ObjectType.getField(String) or all other field getter and
TypeField.getType() |
void compressSubObjects()
{node = {a bool = true, a int = 10}, a char = 'c'}
void indentSubObjects()
compressSubObjects()
to reset format.void writeComment(java.lang.String comment) throws java.io.IOException
comment
- comment to addjava.io.IOException
- if an IO exception occurvoid writeComment(java.lang.String[] comments) throws java.io.IOException
comments
- comments to addjava.io.IOException
- if an IO exception occurvoid writeComment(java.util.List<java.lang.String> comments) throws java.io.IOException
comments
- comments to addjava.io.IOException
- if an IO exception occurvoid writeNode(OdinNode node) throws java.io.IOException
OdinExtra
are write before elementsnode
- node to writejava.io.IOException
- if an IO exception occurOdinFormatException
- if node or a sub node contains an invalid field key ( key can not contains the following delimiter ,:={}[]<>'" )OdinTypeException
- if the type adapter can not be build for an objectOdinAdapterException
- if a runtime exception is throw by an adapter when writing the objectvoid writeArray(OdinArray array) throws java.io.IOException
OdinExtra
are write before elementsarray
- array to writejava.io.IOException
- if an IO exception occurOdinFormatException
- if a sub node contains an invalid field key ( key can not contains the following delimiter ,:={}[]<>'" )OdinTypeException
- if the type adapter can not be build for an objectOdinAdapterException
- if a runtime exception is throw by an adapter when writing the objectvoid writeObject(OdinObject object) throws java.io.IOException
OdinExtra
was write before this objectobject
- object to writejava.io.IOException
- if an IO exception occurOdinFormatException
- if an invalid field key is write by an adapter ( key can not contains the following delimiter ,:={}[]<>'" )OdinTypeException
- if the type adapter can not be build for an objectOdinAdapterException
- if a runtime exception is throw by an adapter when writing the objectvoid writeBoolean(boolean value) throws java.io.IOException
value
- boolean to writejava.io.IOException
- if an IO exception occurvoid writeByte(byte value) throws java.io.IOException
value
- byte to writejava.io.IOException
- if an IO exception occurvoid writeShort(short value) throws java.io.IOException
value
- short to writejava.io.IOException
- if an IO exception occurvoid writeInt(int value) throws java.io.IOException
value
- int to writejava.io.IOException
- if an IO exception occurvoid writeLong(long value) throws java.io.IOException
value
- long to writejava.io.IOException
- if an IO exception occurvoid writeFloat(float value) throws java.io.IOException
value
- float to writejava.io.IOException
- if an IO exception occurvoid writeDouble(double value) throws java.io.IOException
value
- double to writejava.io.IOException
- if an IO exception occurvoid writeChar(char value) throws java.io.IOException
value
- char to writejava.io.IOException
- if an IO exception occurvoid writeString(java.lang.String value) throws java.io.IOException
value
- String to writejava.io.IOException
- if an IO exception occurvoid write(java.lang.Object o) throws java.io.IOException
Object
, the type definition is added before the object.o
- object to writejava.io.IOException
- if an IO exception occurOdinTypeException
- if the type adapter can not be build for this object.
Sub object type error is placed as cause of a OdinAdapterException
OdinAdapterException
- if a runtime exception is throw by an adapter when writing the object<T> void writeTyped(T o, AnyType<T> type) throws java.io.IOException
ObjectType.getField(String)
or all other field getter and
TypeField.getType()
T
- object generic typeo
- object to writetype
- object generic typejava.io.IOException
- if an IO exception occurOdinTypeException
- if the type adapter can not be build for this object.
Sub object type error is placed as cause of a OdinAdapterException
OdinAdapterException
- if a runtime exception is throw by an adapter when writing the objectvoid writeTyped(java.lang.Object o, java.lang.reflect.Type type) throws java.io.IOException
AnyType
associated to the given type, if the object class is not the same than type class, like implementation,
the type definition is added before the object.TypeBuilder
.o
- object to writetype
- object typejava.io.IOException
- if an IO exception occurOdinTypeException
- if the type adapter can not be build for this object.
Sub object type error is placed as cause of a OdinAdapterException
OdinAdapterException
- if a runtime exception is throw by an adapter when writing the objectvoid writeSubContent(IOConsumer<OdinWriter> subWriter) throws java.io.IOException
subWriter
- the sub writer consumerjava.io.IOException
- if an IO exception occurOdinFieldWriter writeField(java.lang.String name) throws java.io.IOException
name
- field namejava.io.IOException
- if an IO exception occurOdinFormatException
- if the name contains invalid characters ( ,:={}[]<>'" )OdinRowWriter writeRow() throws java.io.IOException
OdinRowWriter
is write to same rowjava.io.IOException
- if an IO exception occur