Interface ObjectEncoder
- All Known Implementing Classes:
BinaryObjectEncoder
,XmlObjectEncoder
public interface ObjectEncoder
Interface to abstract away the difference between serializing
xml and binary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
writeBooleanContents
(boolean v) Writes the value in-line.void
writeBooleanField
(String fieldName, boolean v) Writes a boolean.void
writeByteArrayContents
(byte[] v) Special case for byte [] that uses base64 encoding for XMLvoid
writeByteContents
(byte v) Writes the value in-line.void
writeClassContents
(Class<?> v) Writes the value in-line.void
writeClassField
(String fieldName, Class<?> v) Writes a Class.void
writeDoubleContents
(double v) Writes the value in-line.void
writeDoubleField
(String fieldName, double v) Writes a double.void
writeFloatContents
(float v) Writes the value in-line.void
writeFloatField
(String fieldName, float v) Writes a float.void
writeIntContents
(int v) Writes the value in-line.void
writeIntField
(String fieldName, int v) Writes an int.void
writeLongContents
(long v) Writes the value in-line.void
writeLongField
(String fieldName, long v) Writes a long.void
Writes a sub-objectvoid
writeObjectField
(String fieldName, Object object, boolean inline) Writes an object using the appropriate serializer for that objectvoid
Writes the value in-line.void
writeStringField
(String fieldName, String v) Writes a String.
-
Method Details
-
writeObjectField
Writes an object using the appropriate serializer for that object- Parameters:
fieldName
- A hint of the field name. Ignored for binary serialization. Becomes the subelement name for xml serializationobject
- The object to serializeinline
- Ignore for binary serialization. For xml serialization, this causes us not to have a sub-element. When inlining, polymorphic typing is not supported.
-
writeBooleanField
Writes a boolean.- Parameters:
fieldName
- A hint of the field name. Ignored for binary serialization. Becomes the attribute name for xml serializationv
- The value to serialize
-
writeIntField
Writes an int.- Parameters:
fieldName
- A hint of the field name. Ignored for binary serialization. Becomes the attribute name for xml serializationv
- The value to serialize
-
writeLongField
Writes a long.- Parameters:
fieldName
- A hint of the field name. Ignored for binary serialization. Becomes the attribute name for xml serializationv
- The value to serialize
-
writeFloatField
Writes a float.- Parameters:
fieldName
- A hint of the field name. Ignored for binary serialization. Becomes the attribute name for xml serializationv
- The value to serialize
-
writeDoubleField
Writes a double.- Parameters:
fieldName
- A hint of the field name. Ignored for binary serialization. Becomes the attribute name for xml serializationv
- The value to serialize
-
writeClassField
Writes a Class.- Parameters:
fieldName
- A hint of the field name. Ignored for binary serialization. Becomes the attribute name for xml serializationv
- The value to serialize
-
writeStringField
Writes a String.- Parameters:
fieldName
- A hint of the field name. Ignored for binary serialization. Becomes the attribute name for xml serializationv
- The value to serialize
-
writeStringContents
Writes the value in-line. -
writeBooleanContents
void writeBooleanContents(boolean v) Writes the value in-line. -
writeIntContents
void writeIntContents(int v) Writes the value in-line. -
writeLongContents
void writeLongContents(long v) Writes the value in-line. -
writeFloatContents
void writeFloatContents(float v) Writes the value in-line. -
writeDoubleContents
void writeDoubleContents(double v) Writes the value in-line. -
writeByteContents
void writeByteContents(byte v) Writes the value in-line. -
writeByteArrayContents
void writeByteArrayContents(byte[] v) Special case for byte [] that uses base64 encoding for XML -
writeClassContents
Writes the value in-line. -
writeObjectContents
Writes a sub-object- Parameters:
o
- The object to write
-