Package org.nustaq.serialization.coders
Class FSTBytezEncoder
java.lang.Object
org.nustaq.serialization.coders.FSTBytezEncoder
- All Implemented Interfaces:
FSTEncoder
Created by ruedi on 08.11.2014.
Enables serialization to arbitrary byte oriented memory
no compression is applied, so writeFxx == writePlainXX
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
close and flush to underlying stream if present.void
ensureFree
(int bytes) void
externalEnd
(FSTClazzInfo clz) void
flush()
writes current buffer to underlying output and resets buffer.byte[]
getConf()
int
boolean
boolean
protected boolean
boolean
isPrimitiveArray
(Object array, Class<?> componentType) boolean
boolean
void
registerClass
(Class possible) void
reset
(byte[] out) void
setAutoResize
(boolean autoResize) void
setConf
(FSTConfiguration conf) void
setOutstream
(OutputStream outstream) if output stream is null, just encode into a byte arrayvoid
skip
(int i) void
boolean
writeAttributeName
(FSTClazzInfo.FSTFieldInfo subInfo, Object value) final void
writeClass
(Class cl) final void
writeClass
(FSTClazzInfo clInf) final void
writeFByte
(int v) void
writeFChar
(char c) void
writeFCharArr
(char[] arr, int off, int len) void
writeFDouble
(double value) void
writeFDoubleArr
(double[] arr, int off, int len) void
writeFFloat
(float value) Writes a 4 byte float.void
writeFFloatArr
(float[] arr, int off, int len) void
writeFieldsEnd
(FSTClazzInfo serializationInfo) void
writeFInt
(int anInt) void
writeFLong
(long anInt) void
writeFShort
(short c) void
writeFShortArr
(short[] arr, int off, int len) void
writeInt32At
(int position, int v) used to write uncompressed int (guaranteed length = 4) at a (eventually recent) positionvoid
writePrimitiveArray
(Object array, int off, int len) write prim array no len no tagvoid
writeRawBytes
(byte[] array, int start, int length) does not write length, just plain bytesvoid
writeStringUTF
(String str) boolean
writeTag
(byte tag, Object info, long somValue, Object toWrite, FSTObjectOutput oout) void
writeVersionTag
(int version)
-
Constructor Details
-
FSTBytezEncoder
-
-
Method Details
-
setConf
- Specified by:
setConf
in interfaceFSTEncoder
-
writeFFloatArr
- Throws:
IOException
-
writeFDoubleArr
- Throws:
IOException
-
writeFShortArr
- Throws:
IOException
-
writeFCharArr
- Throws:
IOException
-
writePrimitiveArray
write prim array no len no tag- Specified by:
writePrimitiveArray
in interfaceFSTEncoder
- Parameters:
array
-- Throws:
IOException
-
writeRawBytes
does not write length, just plain bytes- Specified by:
writeRawBytes
in interfaceFSTEncoder
- Parameters:
array
-length
-- Throws:
IOException
-
writeStringUTF
- Specified by:
writeStringUTF
in interfaceFSTEncoder
- Throws:
IOException
-
writeFShort
- Specified by:
writeFShort
in interfaceFSTEncoder
- Throws:
IOException
-
writeAttributeName
- Specified by:
writeAttributeName
in interfaceFSTEncoder
-
writeTag
public boolean writeTag(byte tag, Object info, long somValue, Object toWrite, FSTObjectOutput oout) throws IOException - Specified by:
writeTag
in interfaceFSTEncoder
- Throws:
IOException
-
writeFChar
- Specified by:
writeFChar
in interfaceFSTEncoder
- Throws:
IOException
-
writeFByte
- Specified by:
writeFByte
in interfaceFSTEncoder
- Throws:
IOException
-
writeFInt
- Specified by:
writeFInt
in interfaceFSTEncoder
- Throws:
IOException
-
writeFLong
- Specified by:
writeFLong
in interfaceFSTEncoder
- Throws:
IOException
-
writeFFloat
Writes a 4 byte float.- Specified by:
writeFFloat
in interfaceFSTEncoder
- Throws:
IOException
-
writeFDouble
- Specified by:
writeFDouble
in interfaceFSTEncoder
- Throws:
IOException
-
getWritten
public int getWritten()- Specified by:
getWritten
in interfaceFSTEncoder
-
close
close and flush to underlying stream if present. The stream is also closed- Specified by:
close
in interfaceFSTEncoder
- Throws:
IOException
-
reset
public void reset(byte[] out) - Specified by:
reset
in interfaceFSTEncoder
-
skip
public void skip(int i) - Specified by:
skip
in interfaceFSTEncoder
-
writeInt32At
public void writeInt32At(int position, int v) used to write uncompressed int (guaranteed length = 4) at a (eventually recent) position- Specified by:
writeInt32At
in interfaceFSTEncoder
- Parameters:
position
-v
-
-
setOutstream
if output stream is null, just encode into a byte array- Specified by:
setOutstream
in interfaceFSTEncoder
- Parameters:
outstream
-
-
flush
writes current buffer to underlying output and resets buffer.- Specified by:
flush
in interfaceFSTEncoder
- Throws:
IOException
-
ensureFree
- Specified by:
ensureFree
in interfaceFSTEncoder
- Throws:
IOException
-
isAutoResize
public boolean isAutoResize() -
setAutoResize
public void setAutoResize(boolean autoResize) -
getBuffer
public byte[] getBuffer()- Specified by:
getBuffer
in interfaceFSTEncoder
-
isPlainBAAccessible
protected boolean isPlainBAAccessible() -
registerClass
- Specified by:
registerClass
in interfaceFSTEncoder
-
writeClass
- Specified by:
writeClass
in interfaceFSTEncoder
-
writeClass
- Specified by:
writeClass
in interfaceFSTEncoder
-
externalEnd
- Specified by:
externalEnd
in interfaceFSTEncoder
-
isWritingAttributes
public boolean isWritingAttributes()- Specified by:
isWritingAttributes
in interfaceFSTEncoder
-
isPrimitiveArray
- Specified by:
isPrimitiveArray
in interfaceFSTEncoder
-
isTagMultiDimSubArrays
public boolean isTagMultiDimSubArrays()- Specified by:
isTagMultiDimSubArrays
in interfaceFSTEncoder
-
writeVersionTag
- Specified by:
writeVersionTag
in interfaceFSTEncoder
- Throws:
IOException
-
isByteArrayBased
public boolean isByteArrayBased()- Specified by:
isByteArrayBased
in interfaceFSTEncoder
-
writeArrayEnd
public void writeArrayEnd()- Specified by:
writeArrayEnd
in interfaceFSTEncoder
-
writeFieldsEnd
- Specified by:
writeFieldsEnd
in interfaceFSTEncoder
-
getConf
- Specified by:
getConf
in interfaceFSTEncoder
-