public class FSTObjectOutput extends Object implements ObjectOutput
Modifier and Type | Field and Description |
---|---|
static byte |
ARRAY |
static byte |
BIG_BOOLEAN_FALSE |
static byte |
BIG_BOOLEAN_TRUE |
static byte |
BIG_INT |
static byte |
BIG_LONG |
protected boolean |
closed |
protected FSTEncoder |
codec |
protected FSTConfiguration |
conf |
protected int |
curDepth |
static byte |
DIRECT_ARRAY_OBJECT |
static byte |
DIRECT_OBJECT |
protected boolean |
dontShare |
protected static ByteArrayOutputStream |
empty |
static byte |
ENUM |
static byte |
HANDLE |
protected boolean |
isCrossPlatform |
protected FSTSerialisationListener |
listener |
static byte |
NULL |
static Object |
NULL_PLACEHOLDER |
static byte |
OBJECT |
protected FSTObjectRegistry |
objects |
static byte |
ONE_OF |
protected ThreadLocal<FSTClazzInfo.FSTFieldInfo[]> |
refsLocal |
static byte |
SPECIAL_COMPATIBILITY_OBJECT_TAG |
static byte |
STRING |
protected FSTClazzInfo |
stringInfo |
protected int[] |
tmp |
static byte |
TYPED |
protected int |
writeExternalWriteAhead |
Constructor and Description |
---|
FSTObjectOutput()
serialize without an underlying stream, the resulting byte array of writing to
this FSTObjectOutput can be accessed using getBuffer(), the size using getWritten().
|
FSTObjectOutput(FSTConfiguration conf)
serialize without an underlying stream, the resulting byte array of writing to
this FSTObjectOutput can be accessed using getBuffer(), the size using getWritten().
|
FSTObjectOutput(OutputStream out)
Creates a new FSTObjectOutput stream to write data to the specified
underlying output stream.
|
FSTObjectOutput(OutputStream out,
FSTConfiguration conf)
Creates a new FSTObjectOutput stream to write data to the specified
underlying output stream.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
defaultWriteObject(Object toWrite,
FSTClazzInfo serializationInfo) |
void |
ensureFree(int bytes) |
void |
flush()
Flushes this data output stream.
|
byte[] |
getBuffer() |
protected FSTClazzInfo.FSTFieldInfo |
getCachedFI(Class... possibles) |
FSTClazzInfoRegistry |
getClassInfoRegistry() |
FSTEncoder |
getCodec() |
FSTConfiguration |
getConf() |
byte[] |
getCopyOfWrittenBuffer() |
protected FSTClazzInfo |
getFstClazzInfo(FSTClazzInfo.FSTFieldInfo referencee,
Class clazz)
if class is same as last referenced, returned cached clzinfo, else do a lookup
|
FSTSerialisationListener |
getListener() |
FSTObjectRegistry |
getObjectMap() |
ObjectOutputStream |
getObjectOutputStream(Class cl,
FSTClazzInfo clinfo,
FSTClazzInfo.FSTFieldInfo referencee,
Object toWrite) |
int |
getWriteExternalWriteAhead()
since the stock writeXX methods on InputStream are final, i can't ensure sufficient bufferSize on the output buffer
before calling writeExternal.
|
int |
getWritten() |
protected void |
objectHasBeenWritten(Object obj,
int oldStreamPosition,
int streamPosition)
hook for debugging profiling.
|
protected void |
objectWillBeWritten(Object obj,
int streamPosition)
hook for debugging profiling.
|
protected void |
resetAndClearRefs() |
void |
resetForReUse()
reset keeping the last used byte[] buffer
|
void |
resetForReUse(byte[] out) |
void |
resetForReUse(OutputStream out)
if out == null => automatically create/reuse a bytebuffer
|
protected void |
setCodec(FSTEncoder codec) |
void |
setListener(FSTSerialisationListener listener)
note this might slow down serialization significantly
* @param listener
|
void |
setWriteExternalWriteAhead(int writeExternalWriteAhead)
since the stock writeXX methods on InputStream are final, i can't ensure sufficient bufferSize on the output buffer
before calling writeExternal.
|
void |
write(byte[] b) |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
protected void |
writeArray(FSTClazzInfo.FSTFieldInfo referencee,
Object array) |
void |
writeBoolean(boolean v) |
void |
writeByte(int v) |
void |
writeBytes(String s) |
void |
writeChar(int v) |
void |
writeChars(String s) |
void |
writeClassTag(Class aClass) |
protected void |
writeCompatibleObjectFields(Object toWrite,
Map fields,
FSTClazzInfo.FSTFieldInfo[] fieldInfo) |
void |
writeDouble(double v) |
protected FSTClazzInfo |
writeEnum(FSTClazzInfo.FSTFieldInfo referencee,
Object toWrite) |
void |
writeFloat(float v) |
protected boolean |
writeHandleIfApplicable(Object toWrite,
FSTClazzInfo serializationInfo) |
void |
writeInt(int v) |
void |
writeLong(long v) |
void |
writeObject(Object obj) |
void |
writeObject(Object obj,
Class... possibles) |
protected void |
writeObjectCompatible(FSTClazzInfo.FSTFieldInfo referencee,
Object toWrite,
FSTClazzInfo serializationInfo) |
protected void |
writeObjectCompatibleRecursive(FSTClazzInfo.FSTFieldInfo referencee,
Object toWrite,
FSTClazzInfo serializationInfo,
Class cl) |
protected void |
writeObjectFields(Object toWrite,
FSTClazzInfo serializationInfo,
FSTClazzInfo.FSTFieldInfo[] fieldInfo,
int startIndex,
int version) |
protected boolean |
writeObjectHeader(FSTClazzInfo clsInfo,
FSTClazzInfo.FSTFieldInfo referencee,
Object toWrite) |
FSTClazzInfo |
writeObjectInternal(Object obj,
FSTClazzInfo ci,
Class... possibles) |
protected FSTClazzInfo |
writeObjectWithContext(FSTClazzInfo.FSTFieldInfo referencee,
Object toWrite) |
protected FSTClazzInfo |
writeObjectWithContext(FSTClazzInfo.FSTFieldInfo referencee,
Object toWrite,
FSTClazzInfo ci) |
void |
writeShort(int v) |
void |
writeStringUTF(String str) |
void |
writeUTF(String s) |
public static Object NULL_PLACEHOLDER
public static final byte SPECIAL_COMPATIBILITY_OBJECT_TAG
public static final byte ONE_OF
public static final byte BIG_BOOLEAN_FALSE
public static final byte BIG_BOOLEAN_TRUE
public static final byte BIG_LONG
public static final byte BIG_INT
public static final byte DIRECT_ARRAY_OBJECT
public static final byte HANDLE
public static final byte ENUM
public static final byte ARRAY
public static final byte STRING
public static final byte TYPED
public static final byte DIRECT_OBJECT
public static final byte NULL
public static final byte OBJECT
protected FSTEncoder codec
protected FSTConfiguration conf
protected FSTObjectRegistry objects
protected int curDepth
protected int writeExternalWriteAhead
protected FSTSerialisationListener listener
protected boolean dontShare
protected final FSTClazzInfo stringInfo
protected boolean isCrossPlatform
protected ThreadLocal<FSTClazzInfo.FSTFieldInfo[]> refsLocal
protected static ByteArrayOutputStream empty
protected boolean closed
protected int[] tmp
public FSTObjectOutput(OutputStream out)
public FSTObjectOutput(OutputStream out, FSTConfiguration conf)
written
is
set to zero.
Don't create a FSTConfiguration with each stream, just create one global static configuration and reuse it.
FSTConfiguration is threadsafe.out
- the underlying output stream, to be saved for later
use.public FSTObjectOutput(FSTConfiguration conf)
conf
- IOException
public FSTObjectOutput()
IOException
public void flush() throws IOException
flush
method of DataOutputStream
calls the flush
method of its underlying output stream.flush
in interface ObjectOutput
IOException
- if an I/O error occurs.FilterOutputStream.out
,
OutputStream.flush()
public void close() throws IOException
close
in interface ObjectOutput
close
in interface AutoCloseable
IOException
public int getWriteExternalWriteAhead()
public void setWriteExternalWriteAhead(int writeExternalWriteAhead)
writeExternalWriteAhead
- public void ensureFree(int bytes) throws IOException
IOException
public void writeObject(Object obj) throws IOException
writeObject
in interface ObjectOutput
IOException
public void write(int b) throws IOException
write
in interface DataOutput
write
in interface ObjectOutput
IOException
public void write(byte[] b) throws IOException
write
in interface DataOutput
write
in interface ObjectOutput
IOException
public void write(byte[] b, int off, int len) throws IOException
write
in interface DataOutput
write
in interface ObjectOutput
IOException
public void writeBoolean(boolean v) throws IOException
writeBoolean
in interface DataOutput
IOException
public void writeByte(int v) throws IOException
writeByte
in interface DataOutput
IOException
public void writeShort(int v) throws IOException
writeShort
in interface DataOutput
IOException
public void writeChar(int v) throws IOException
writeChar
in interface DataOutput
IOException
public void writeInt(int v) throws IOException
writeInt
in interface DataOutput
IOException
public void writeLong(long v) throws IOException
writeLong
in interface DataOutput
IOException
public void writeFloat(float v) throws IOException
writeFloat
in interface DataOutput
IOException
public void writeDouble(double v) throws IOException
writeDouble
in interface DataOutput
IOException
public void writeBytes(String s) throws IOException
writeBytes
in interface DataOutput
IOException
public void writeChars(String s) throws IOException
writeChars
in interface DataOutput
IOException
public void writeUTF(String s) throws IOException
writeUTF
in interface DataOutput
IOException
public void writeObject(Object obj, Class... possibles) throws IOException
IOException
protected FSTClazzInfo.FSTFieldInfo getCachedFI(Class... possibles)
public FSTClazzInfo writeObjectInternal(Object obj, FSTClazzInfo ci, Class... possibles) throws IOException
obj
- ci
- possibles
- IOException
public FSTSerialisationListener getListener()
public void setListener(FSTSerialisationListener listener)
protected void objectWillBeWritten(Object obj, int streamPosition)
obj
- streamPosition
- protected void objectHasBeenWritten(Object obj, int oldStreamPosition, int streamPosition)
obj
- oldStreamPosition
- streamPosition
- protected FSTClazzInfo writeObjectWithContext(FSTClazzInfo.FSTFieldInfo referencee, Object toWrite) throws IOException
IOException
protected FSTClazzInfo writeObjectWithContext(FSTClazzInfo.FSTFieldInfo referencee, Object toWrite, FSTClazzInfo ci) throws IOException
IOException
protected FSTClazzInfo writeEnum(FSTClazzInfo.FSTFieldInfo referencee, Object toWrite) throws IOException
IOException
protected boolean writeHandleIfApplicable(Object toWrite, FSTClazzInfo serializationInfo) throws IOException
IOException
protected FSTClazzInfo getFstClazzInfo(FSTClazzInfo.FSTFieldInfo referencee, Class clazz)
public void defaultWriteObject(Object toWrite, FSTClazzInfo serializationInfo) throws IOException
IOException
protected void writeObjectCompatible(FSTClazzInfo.FSTFieldInfo referencee, Object toWrite, FSTClazzInfo serializationInfo) throws IOException
IOException
protected void writeObjectCompatibleRecursive(FSTClazzInfo.FSTFieldInfo referencee, Object toWrite, FSTClazzInfo serializationInfo, Class cl) throws IOException
IOException
protected void writeObjectFields(Object toWrite, FSTClazzInfo serializationInfo, FSTClazzInfo.FSTFieldInfo[] fieldInfo, int startIndex, int version) throws IOException
IOException
protected void writeCompatibleObjectFields(Object toWrite, Map fields, FSTClazzInfo.FSTFieldInfo[] fieldInfo) throws IOException
IOException
protected boolean writeObjectHeader(FSTClazzInfo clsInfo, FSTClazzInfo.FSTFieldInfo referencee, Object toWrite) throws IOException
clsInfo
- referencee
- toWrite
- IOException
protected void writeArray(FSTClazzInfo.FSTFieldInfo referencee, Object array) throws IOException
IOException
public void writeStringUTF(String str) throws IOException
IOException
protected void resetAndClearRefs()
public void resetForReUse(OutputStream out)
out
- public void resetForReUse()
public void resetForReUse(byte[] out)
public FSTClazzInfoRegistry getClassInfoRegistry()
public ObjectOutputStream getObjectOutputStream(Class cl, FSTClazzInfo clinfo, FSTClazzInfo.FSTFieldInfo referencee, Object toWrite) throws IOException
cl
- - class or superclass of currently serialized obj, write declared fields of this class onlyclinfo
- referencee
- toWrite
- IOException
public FSTObjectRegistry getObjectMap()
public byte[] getBuffer()
public byte[] getCopyOfWrittenBuffer()
public FSTConfiguration getConf()
public int getWritten()
public void writeClassTag(Class aClass)
public FSTEncoder getCodec()
protected void setCodec(FSTEncoder codec)
Copyright © 2017. All rights reserved.