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 FSTEncoder |
codec |
protected FSTConfiguration |
conf |
protected int |
curDepth |
static byte |
DIRECT_ARRAY_OBJECT |
static byte |
DIRECT_OBJECT |
static byte |
ENUM |
static byte |
HANDLE |
protected FSTSerialisationListener |
listener |
static byte |
NULL |
static Object |
NULL_PLACEHOLDER |
static byte |
OBJECT |
protected FSTObjectRegistry |
objects |
static byte |
ONE_OF |
static byte |
SPECIAL_COMPATIBILITY_OBJECT_TAG |
static byte |
STRING |
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() |
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.
|
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) |
void |
writeDouble(double v) |
void |
writeFloat(float v) |
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 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 final FSTConfiguration conf
protected FSTObjectRegistry objects
protected int curDepth
protected int writeExternalWriteAhead
protected FSTSerialisationListener listener
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 - IOExceptionpublic FSTObjectOutput()
IOExceptionpublic void flush()
throws IOException
flush method of DataOutputStream
calls the flush method of its underlying output stream.flush in interface ObjectOutputIOException - if an I/O error occurs.FilterOutputStream.out,
OutputStream.flush()public void close()
throws IOException
close in interface ObjectOutputclose in interface AutoCloseableIOExceptionpublic int getWriteExternalWriteAhead()
public void setWriteExternalWriteAhead(int writeExternalWriteAhead)
writeExternalWriteAhead - public void ensureFree(int bytes)
throws IOException
IOExceptionpublic void writeObject(Object obj) throws IOException
writeObject in interface ObjectOutputIOExceptionpublic void write(int b)
throws IOException
write in interface DataOutputwrite in interface ObjectOutputIOExceptionpublic void write(byte[] b)
throws IOException
write in interface DataOutputwrite in interface ObjectOutputIOExceptionpublic void write(byte[] b,
int off,
int len)
throws IOException
write in interface DataOutputwrite in interface ObjectOutputIOExceptionpublic void writeBoolean(boolean v)
throws IOException
writeBoolean in interface DataOutputIOExceptionpublic void writeByte(int v)
throws IOException
writeByte in interface DataOutputIOExceptionpublic void writeShort(int v)
throws IOException
writeShort in interface DataOutputIOExceptionpublic void writeChar(int v)
throws IOException
writeChar in interface DataOutputIOExceptionpublic void writeInt(int v)
throws IOException
writeInt in interface DataOutputIOExceptionpublic void writeLong(long v)
throws IOException
writeLong in interface DataOutputIOExceptionpublic void writeFloat(float v)
throws IOException
writeFloat in interface DataOutputIOExceptionpublic void writeDouble(double v)
throws IOException
writeDouble in interface DataOutputIOExceptionpublic void writeBytes(String s) throws IOException
writeBytes in interface DataOutputIOExceptionpublic void writeChars(String s) throws IOException
writeChars in interface DataOutputIOExceptionpublic void writeUTF(String s) throws IOException
writeUTF in interface DataOutputIOExceptionpublic void writeObject(Object obj, Class... possibles) throws IOException
IOExceptionpublic FSTClazzInfo writeObjectInternal(Object obj, FSTClazzInfo ci, Class... possibles) throws IOException
obj - ci - possibles - IOExceptionpublic 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
IOExceptionprotected FSTClazzInfo writeObjectWithContext(FSTClazzInfo.FSTFieldInfo referencee, Object toWrite, FSTClazzInfo ci) throws IOException
IOExceptionprotected FSTClazzInfo getFstClazzInfo(FSTClazzInfo.FSTFieldInfo referencee, Class clazz)
public void defaultWriteObject(Object toWrite, FSTClazzInfo serializationInfo) throws IOException
IOExceptionprotected void writeObjectCompatible(FSTClazzInfo.FSTFieldInfo referencee, Object toWrite, FSTClazzInfo serializationInfo) throws IOException
IOExceptionprotected boolean writeObjectHeader(FSTClazzInfo clsInfo, FSTClazzInfo.FSTFieldInfo referencee, Object toWrite) throws IOException
clsInfo - referencee - toWrite - IOExceptionprotected void writeArray(FSTClazzInfo.FSTFieldInfo referencee, Object array) throws IOException
IOExceptionpublic void writeStringUTF(String str) throws IOException
IOExceptionpublic 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 - IOExceptionpublic 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 © 2015. All rights reserved.