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()
BinaryObjectSerializerflush in interface BinaryObjectSerializerpublic void close()
BinaryObjectSerializerclose in interface BinaryObjectSerializerpublic void writeObject(Object o)
BinaryObjectSerializerwriteObject in interface BinaryObjectSerializero - The object to write.for a list of supported types.public void writeBooleanContents(boolean v)
ObjectEncoderwriteBooleanContents in interface ObjectEncoderpublic void writeBooleanField(String fieldName, boolean v)
ObjectEncoderwriteBooleanField in interface ObjectEncoderfieldName - 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)
ObjectEncoderwriteByteContents in interface ObjectEncoderpublic void writeByteArrayContents(byte[] v)
ObjectEncoderwriteByteArrayContents in interface ObjectEncoderpublic void writeClassContents(Class<?> v)
ObjectEncoderwriteClassContents in interface ObjectEncoderpublic void writeClassField(String fieldName, Class<?> v)
ObjectEncoderwriteClassField in interface ObjectEncoderfieldName - 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)
ObjectEncoderwriteDoubleContents in interface ObjectEncoderpublic void writeDoubleField(String fieldName, double v)
ObjectEncoderwriteDoubleField in interface ObjectEncoderfieldName - 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)
ObjectEncoderwriteFloatContents in interface ObjectEncoderpublic void writeFloatField(String fieldName, float v)
ObjectEncoderwriteFloatField in interface ObjectEncoderfieldName - 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)
ObjectEncoderwriteIntContents in interface ObjectEncoderpublic void writeIntField(String fieldName, int v)
ObjectEncoderwriteIntField in interface ObjectEncoderfieldName - 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)
ObjectEncoderwriteLongContents in interface ObjectEncoderpublic void writeLongField(String fieldName, long v)
ObjectEncoderwriteLongField in interface ObjectEncoderfieldName - 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)
ObjectEncoderwriteObjectContents in interface ObjectEncoderobject - The object to writepublic void writeObjectField(String fieldName, Object object, boolean inline)
ObjectEncoderwriteObjectField in interface ObjectEncoderfieldName - 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)
ObjectEncoderwriteStringContents in interface ObjectEncoderpublic void writeStringField(String fieldName, String v)
ObjectEncoderwriteStringField in interface ObjectEncoderfieldName - 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.