public class DefaultMslEncoderFactory extends MslEncoderFactory
Default MslEncoderFactory
implementation that supports the
following encoder formats:
org.json
.Constructor and Description |
---|
DefaultMslEncoderFactory() |
Modifier and Type | Method and Description |
---|---|
byte[] |
encodeObject(MslObject object,
MslEncoderFormat format)
Encode a
MslObject into the specified encoder format. |
protected MslTokenizer |
generateTokenizer(java.io.InputStream source,
MslEncoderFormat format)
Create a new
MslTokenizer of the specified encoder format. |
MslEncoderFormat |
getPreferredFormat(java.util.Set<MslEncoderFormat> formats)
Returns the most preferred encoder format from the provided set of
formats.
|
MslObject |
parseObject(byte[] encoding)
Parse a
MslObject from encoded data. |
createArray, createArray, createObject, createObject, createTokenizer, parseFormat
public MslEncoderFormat getPreferredFormat(java.util.Set<MslEncoderFormat> formats)
MslEncoderFactory
getPreferredFormat
in class MslEncoderFactory
formats
- the set of formats to choose from. May be null
or
empty.null
or empty.protected MslTokenizer generateTokenizer(java.io.InputStream source, MslEncoderFormat format) throws MslEncoderException
MslEncoderFactory
MslTokenizer
of the specified encoder format.generateTokenizer
in class MslEncoderFactory
source
- the binary data to tokenize.format
- the encoder format.MslTokenizer
.MslEncoderException
- if the encoder format is not supported.public MslObject parseObject(byte[] encoding) throws MslEncoderException
MslEncoderFactory
MslObject
from encoded data. The encoder format will be
determined by inspecting the byte stream identifier located in the first
byte.parseObject
in class MslEncoderFactory
encoding
- the encoded data to parse.MslObject
.MslEncoderException
- if the encoder format is not supported or
there is an error parsing the encoded data.public byte[] encodeObject(MslObject object, MslEncoderFormat format) throws MslEncoderException
MslEncoderFactory
MslObject
into the specified encoder format.encodeObject
in class MslEncoderFactory
object
- the MslObject
to encode.format
- the encoder format.MslEncoderException
- if the encoder format is not supported or
there is an error encoding the object.