public class BinaryObjectEncoder extends Object implements ObjectEncoder, BinaryObjectSerializer
Modifier and Type | Field and Description |
---|---|
static int |
ENCODING_VERSION
Version for the overall encoding - if we need to change anything in the
encoder, we will need to bump this and handle appropriately
|
static byte |
FIELD_TYPE_ANONYMOUS_FIELD |
static byte |
FIELD_TYPE_END_OBJECT |
static byte |
FIELD_TYPE_NAMED_FIELD |
static int |
OBJECT_MAGIC |
static byte |
OBJECT_TYPE_ARRAY |
static byte |
OBJECT_TYPE_CLASS |
static byte |
OBJECT_TYPE_NULL |
Constructor and Description |
---|
BinaryObjectEncoder(OutputStream output) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the underylying stream after first flushing it.
|
void |
flush()
Flushes the underlying stream.
|
void |
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 XML
|
void |
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 |
writeObject(Object o)
Writes the next object to the stream.
|
void |
writeObjectContents(Object object)
Writes a sub-object
|
void |
writeObjectField(String fieldName,
Object object,
boolean inline)
Writes an object using the appropriate serializer for that object
|
void |
writeStringContents(String str)
Writes the value in-line.
|
void |
writeStringField(String fieldName,
String v)
Writes a String.
|
public static final int ENCODING_VERSION
public static final int OBJECT_MAGIC
public static final byte OBJECT_TYPE_NULL
public static final byte OBJECT_TYPE_CLASS
public static final byte OBJECT_TYPE_ARRAY
public static final byte FIELD_TYPE_ANONYMOUS_FIELD
public static final byte FIELD_TYPE_NAMED_FIELD
public static final byte FIELD_TYPE_END_OBJECT
public BinaryObjectEncoder(OutputStream output)
public void flush()
BinaryObjectSerializer
flush
in interface BinaryObjectSerializer
public void close()
BinaryObjectSerializer
close
in interface BinaryObjectSerializer
public void writeObject(Object o)
BinaryObjectSerializer
writeObject
in interface BinaryObjectSerializer
o
- The object to write.for a list of supported types.
public void writeBooleanContents(boolean v)
ObjectEncoder
writeBooleanContents
in interface ObjectEncoder
public void writeBooleanField(String fieldName, boolean v)
ObjectEncoder
writeBooleanField
in interface ObjectEncoder
fieldName
- A hint of the field name. Ignored for binary
serialization. Becomes the attribute name for xml serializationv
- The value to serializepublic void writeByteContents(byte v)
ObjectEncoder
writeByteContents
in interface ObjectEncoder
public void writeByteArrayContents(byte[] v)
ObjectEncoder
writeByteArrayContents
in interface ObjectEncoder
public void writeClassContents(Class<?> v)
ObjectEncoder
writeClassContents
in interface ObjectEncoder
public void writeClassField(String fieldName, Class<?> v)
ObjectEncoder
writeClassField
in interface ObjectEncoder
fieldName
- A hint of the field name. Ignored for binary
serialization. Becomes the attribute name for xml serializationv
- The value to serializepublic void writeDoubleContents(double v)
ObjectEncoder
writeDoubleContents
in interface ObjectEncoder
public void writeDoubleField(String fieldName, double v)
ObjectEncoder
writeDoubleField
in interface ObjectEncoder
fieldName
- A hint of the field name. Ignored for binary
serialization. Becomes the attribute name for xml serializationv
- The value to serializepublic void writeFloatContents(float v)
ObjectEncoder
writeFloatContents
in interface ObjectEncoder
public void writeFloatField(String fieldName, float v)
ObjectEncoder
writeFloatField
in interface ObjectEncoder
fieldName
- A hint of the field name. Ignored for binary
serialization. Becomes the attribute name for xml serializationv
- The value to serializepublic void writeIntContents(int v)
ObjectEncoder
writeIntContents
in interface ObjectEncoder
public void writeIntField(String fieldName, int v)
ObjectEncoder
writeIntField
in interface ObjectEncoder
fieldName
- A hint of the field name. Ignored for binary
serialization. Becomes the attribute name for xml serializationv
- The value to serializepublic void writeLongContents(long v)
ObjectEncoder
writeLongContents
in interface ObjectEncoder
public void writeLongField(String fieldName, long v)
ObjectEncoder
writeLongField
in interface ObjectEncoder
fieldName
- A hint of the field name. Ignored for binary
serialization. Becomes the attribute name for xml serializationv
- The value to serializepublic void writeObjectContents(Object object)
ObjectEncoder
writeObjectContents
in interface ObjectEncoder
object
- The object to writepublic void writeObjectField(String fieldName, Object object, boolean inline)
ObjectEncoder
writeObjectField
in interface ObjectEncoder
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.public void writeStringContents(String str)
ObjectEncoder
writeStringContents
in interface ObjectEncoder
public void writeStringField(String fieldName, String v)
ObjectEncoder
writeStringField
in interface ObjectEncoder
fieldName
- A hint of the field name. Ignored for binary
serialization. Becomes the attribute name for xml serializationv
- The value to serializeCopyright © 2019. All rights reserved.