public class JavaBinCodec extends Object
JavaBinCodec has built in support many commonly used types. This includes primitive types (boolean, byte,
short, double, int, long, float), common Java containers/utilities (Date, Map, Collection, Iterator, String,
Object[], byte[]), and frequently used Solr types (NamedList
, SolrDocument
,
SolrDocumentList
). Each of the above types has a pair of associated methods which read and write
that type to a stream.
Classes that aren't supported natively can still be serialized/deserialized by providing
an JavaBinCodec.ObjectResolver
object that knows how to work with the unsupported class.
This allows JavaBinCodec
to be used to marshall/unmarshall arbitrary content.
NOTE -- JavaBinCodec
instances cannot be reused for more than one marshall or unmarshall operation.
Modifier and Type | Class and Description |
---|---|
static interface |
JavaBinCodec.ObjectResolver
Allows extension of
JavaBinCodec to support serialization of arbitrary data types. |
static class |
JavaBinCodec.StringBytes |
static class |
JavaBinCodec.StringCache |
static interface |
JavaBinCodec.WritableDocFields |
Modifier and Type | Field and Description |
---|---|
static byte |
ARR |
static byte |
BOOL_FALSE |
static byte |
BOOL_TRUE |
static byte |
BYTE |
static byte |
BYTEARR |
protected FastOutputStream |
daos |
static byte |
DATE |
static byte |
DOUBLE |
static byte |
END |
protected static Object |
END_OBJ |
static byte |
ENUM_FIELD_VALUE |
static byte |
EXTERN_STRING |
static byte |
FLOAT |
static byte |
INT |
static byte |
ITERATOR |
static byte |
LONG |
static byte |
MAP |
static byte |
MAP_ENTRY |
static byte |
NAMED_LST |
static byte |
NULL |
static byte |
ORDERED_MAP |
static byte |
SHORT |
static byte |
SINT |
static byte |
SLONG |
static byte |
SOLRDOC |
static byte |
SOLRDOCLST |
static byte |
SOLRINPUTDOC |
static byte |
SOLRINPUTDOC_CHILDS |
static byte |
STR |
static byte |
TAG_AND_LEN |
protected byte |
tagByte |
Constructor and Description |
---|
JavaBinCodec() |
JavaBinCodec(JavaBinCodec.ObjectResolver resolver) |
JavaBinCodec(JavaBinCodec.ObjectResolver resolver,
JavaBinCodec.StringCache stringCache) |
public static final byte NULL
public static final byte BOOL_TRUE
public static final byte BOOL_FALSE
public static final byte BYTE
public static final byte SHORT
public static final byte DOUBLE
public static final byte INT
public static final byte LONG
public static final byte FLOAT
public static final byte DATE
public static final byte MAP
public static final byte SOLRDOC
public static final byte SOLRDOCLST
public static final byte BYTEARR
public static final byte ITERATOR
public static final byte END
public static final byte SOLRINPUTDOC
public static final byte SOLRINPUTDOC_CHILDS
public static final byte ENUM_FIELD_VALUE
public static final byte MAP_ENTRY
public static final byte TAG_AND_LEN
public static final byte STR
public static final byte SINT
public static final byte SLONG
public static final byte ARR
public static final byte ORDERED_MAP
public static final byte NAMED_LST
public static final byte EXTERN_STRING
protected FastOutputStream daos
protected static final Object END_OBJ
protected byte tagByte
public JavaBinCodec()
public JavaBinCodec(JavaBinCodec.ObjectResolver resolver)
public JavaBinCodec(JavaBinCodec.ObjectResolver resolver, JavaBinCodec.StringCache stringCache)
public JavaBinCodec setWritableDocFields(JavaBinCodec.WritableDocFields writableDocFields)
public JavaBinCodec.ObjectResolver getResolver()
public void marshal(Object nl, OutputStream os) throws IOException
IOException
public void init(FastOutputStream os)
public Object unmarshal(InputStream is) throws IOException
IOException
public SimpleOrderedMap<Object> readOrderedMap(DataInputInputStream dis) throws IOException
IOException
public NamedList<Object> readNamedList(DataInputInputStream dis) throws IOException
IOException
public void writeNamedList(NamedList<?> nl) throws IOException
IOException
public void writeVal(Object val) throws IOException
IOException
public Object readVal(DataInputInputStream dis) throws IOException
IOException
public boolean writeKnownType(Object val) throws IOException
IOException
public void writeTag(byte tag) throws IOException
IOException
public void writeTag(byte tag, int size) throws IOException
IOException
public void writeByteArray(byte[] arr, int offset, int len) throws IOException
IOException
public byte[] readByteArray(DataInputInputStream dis) throws IOException
IOException
public void writeSolrDocument(SolrDocument doc) throws IOException
IOException
protected boolean toWrite(String key)
public SolrDocument readSolrDocument(DataInputInputStream dis) throws IOException
IOException
public SolrDocumentList readSolrDocumentList(DataInputInputStream dis) throws IOException
IOException
public void writeSolrDocumentList(SolrDocumentList docs) throws IOException
IOException
public SolrInputDocument readSolrInputDocument(DataInputInputStream dis) throws IOException
IOException
public void writeSolrInputDocument(SolrInputDocument sdoc) throws IOException
IOException
public Map<Object,Object> readMap(DataInputInputStream dis) throws IOException
IOException
public void writeIterator(Iterator iter) throws IOException
IOException
public List<Object> readIterator(DataInputInputStream fis) throws IOException
IOException
public void writeArray(List l) throws IOException
IOException
public void writeArray(Collection coll) throws IOException
IOException
public void writeArray(Object[] arr) throws IOException
IOException
public List<Object> readArray(DataInputInputStream dis) throws IOException
IOException
public void writeEnumFieldValue(EnumFieldValue enumFieldValue) throws IOException
EnumFieldValue
as tag+int value+string valueenumFieldValue
- to writeIOException
public void writeMapEntry(Map.Entry<Object,Object> val) throws IOException
IOException
public EnumFieldValue readEnumFieldValue(DataInputInputStream dis) throws IOException
EnumFieldValue
(int+string) from input streamdis
- data input streamEnumFieldValue
IOException
public Map.Entry<Object,Object> readMapEntry(DataInputInputStream dis) throws IOException
IOException
public void writeStr(String s) throws IOException
IOException
public String readStr(DataInputInputStream dis) throws IOException
IOException
public String readStr(DataInputInputStream dis, JavaBinCodec.StringCache stringCache) throws IOException
IOException
public void writeInt(int val) throws IOException
IOException
public int readSmallInt(DataInputInputStream dis) throws IOException
IOException
public void writeLong(long val) throws IOException
IOException
public long readSmallLong(DataInputInputStream dis) throws IOException
IOException
public void writeFloat(float val) throws IOException
IOException
public boolean writePrimitive(Object val) throws IOException
IOException
public void writeMap(Map<?,?> val) throws IOException
IOException
public int readSize(DataInputInputStream in) throws IOException
IOException
public static void writeVInt(int i, FastOutputStream out) throws IOException
IOException
- If there is a low-level I/O error.public static int readVInt(DataInputInputStream in) throws IOException
writeVInt(int, FastOutputStream)
IOException
- If there is a low-level I/O error.public static void writeVLong(long i, FastOutputStream out) throws IOException
IOException
public static long readVLong(DataInputInputStream in) throws IOException
IOException
public void writeExternString(String s) throws IOException
IOException
public String readExternString(DataInputInputStream fis) throws IOException
IOException
Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.