|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.joda.beans.ser.bin.JodaBeanBinWriter
public class JodaBeanBinWriter
Provides the ability for a Joda-Bean to be written to a binary format.
This class contains mutable state and cannot be used from multiple threads.
The binary format is based on MessagePack v2.0. Each bean is output as a map using the property name.
Most simple types, defined by Joda-Convert, are output as MessagePack strings. However, MessagePack nil, boolean, float, integral and bin types are also used for null, byte[] and the Java numeric primitive types (excluding char).
Beans are output using MessagePack maps where the key is the property name. Collections are output using MessagePack maps or arrays. Multisets are output as a map of value to count.
If a collection contains a collection then addition meta-type information is written to aid with deserialization. At this level, the data read back may not be identical to that written.
Where necessary, the Java type is sent using an 'ext' entity. Three 'ext' types are used, one each for beans, meta-type and simple. The class name is passed as the 'ext' data. The 'ext' value is sent as an additional key-value pair for beans, with the 'ext' as the key and 'nil' as the value. Where the additional type information is not about a bean, a tuple is written using a size 1 map where the key is the 'ext' data and the value is the data being annotated.
Type names are shortened by the package of the root type if possible. Certain basic types are also handled, such as String, Integer, File and URI.
| Constructor Summary | |
|---|---|
JodaBeanBinWriter(JodaBeanSer settings)
Creates an instance. |
|
| Method Summary | |
|---|---|
byte[] |
write(Bean bean)
Writes the bean to an array of bytes. |
byte[] |
write(Bean bean,
boolean rootType)
Writes the bean to an array of bytes. |
void |
write(Bean bean,
boolean rootType,
OutputStream output)
Writes the bean to the OutputStream. |
void |
write(Bean bean,
OutputStream output)
Writes the bean to the OutputStream. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public JodaBeanBinWriter(JodaBeanSer settings)
settings - the settings to use, not null| Method Detail |
|---|
public byte[] write(Bean bean)
The type of the bean will be set in the message.
bean - the bean to output, not null
public byte[] write(Bean bean,
boolean rootType)
bean - the bean to output, not nullrootType - true to output the root type
public void write(Bean bean,
OutputStream output)
throws IOException
OutputStream.
The type of the bean will be set in the message.
bean - the bean to output, not nulloutput - the output stream, not null
IOException
public void write(Bean bean,
boolean rootType,
OutputStream output)
throws IOException
OutputStream.
bean - the bean to output, not nullrootType - true to output the root typeoutput - the output stream, not null
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||