Package org.nustaq.serialization
Class FSTObjectInput
java.lang.Object
org.nustaq.serialization.FSTObjectInput
- All Implemented Interfaces:
java.io.DataInput,java.io.ObjectInput,java.lang.AutoCloseable
- Direct Known Subclasses:
FSTObjectInputNoShared
public class FSTObjectInput
extends java.lang.Object
implements java.io.ObjectInput
replacement of ObjectInputStream
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classFSTObjectInput.CallbackEntrystatic interfaceFSTObjectInput.ConditionalCallbackprotected static classFSTObjectInput.MyObjectStream -
Field Summary
Fields Modifier and Type Field Description protected java.util.ArrayList<FSTObjectInput.CallbackEntry>callbacksprotected FSTClazzInfoRegistryclInfoRegistryprotected booleanclosedprotected FSTDecodercodecprotected FSTObjectInput.ConditionalCallbackconditionalCallbackprotected FSTConfigurationconfprotected intcurDepthprotected java.util.Stack<java.lang.String>debugStackstatic java.io.ByteArrayInputStreamemptyStreamprotected FSTObjectInput.MyObjectStreamfakeWrapperprotected booleanignoreAnnotationsprotected FSTClazzInfo.FSTFieldInfoinfoCacheprotected booleanisCrossPlatformprotected FSTObjectRegistryobjectsprotected intreadExternalReadAHeadstatic booleanREGISTER_ENUMS_READprotected VersionConflictListenerversionConflictListener -
Constructor Summary
Constructors Constructor Description FSTObjectInput()FSTObjectInput(java.io.InputStream in)Creates a FSTObjectInput that uses the specified underlying InputStream.FSTObjectInput(java.io.InputStream in, FSTConfiguration conf)Creates a FSTObjectInput that uses the specified underlying InputStream.FSTObjectInput(FSTConfiguration conf) -
Method Summary
Modifier and Type Method Description intavailable()voidclose()voiddefaultReadObject(FSTClazzInfo.FSTFieldInfo referencee, FSTClazzInfo serializationInfo, java.lang.Object newObj)java.lang.ClassgetClassForName(java.lang.String name)protected FSTClazzInfogetClazzInfo(java.lang.Class c, FSTClazzInfo.FSTFieldInfo referencee)FSTDecodergetCodec()FSTObjectInput.ConditionalCallbackgetConditionalCallback()FSTConfigurationgetConf()protected java.io.ObjectInputStreamgetObjectInputStream(java.lang.Class cl, FSTClazzInfo clInfo, FSTClazzInfo.FSTFieldInfo referencee, java.lang.Object toRead)intgetReadExternalReadAHead()VersionConflictListenergetVersionConflictListener()protected java.lang.ObjecthandleReadRessolve(FSTClazzInfo serializationInfo, java.lang.Object newObj)protected voidinitRegistries(FSTConfiguration conf)protected java.lang.ObjectinstantiateAndReadNoSer(java.lang.Class c, FSTClazzInfo clzSerInfo, FSTClazzInfo.FSTFieldInfo referencee, int readPos)protected java.lang.ObjectinstantiateAndReadWithSer(java.lang.Class c, FSTObjectSerializer ser, FSTClazzInfo clzSerInfo, FSTClazzInfo.FSTFieldInfo referencee, int readPos)protected java.lang.ObjectinstantiateArray(FSTClazzInfo.FSTFieldInfo referencee, int readPos)protected java.lang.ObjectinstantiateBigInt()protected java.lang.ObjectinstantiateEnum(FSTClazzInfo.FSTFieldInfo referencee, int readPos)protected java.lang.ObjectinstantiateHandle(FSTClazzInfo.FSTFieldInfo referencee)protected java.lang.ObjectinstantiateSpecialTag(FSTClazzInfo.FSTFieldInfo referencee, int readPos, byte code)booleanisClosed()protected voidoldVersionRead(java.lang.Object newObj)protected voidprocessValidation()protected voidpushBack(int i)intread()intread(byte[] b)intread(byte[] b, int off, int len)protected java.lang.ObjectreadArray(FSTClazzInfo.FSTFieldInfo referencee, int pos)protected java.lang.ObjectreadArrayNoHeader(FSTClazzInfo.FSTFieldInfo referencee, int pos, java.lang.Class arrCl)booleanreadBoolean()bytereadByte()charreadChar()FSTClazzInforeadClass()protected voidreadCompatibleObjectFields(FSTClazzInfo.FSTFieldInfo referencee, FSTClazzInfo serializationInfo, FSTClazzInfo.FSTFieldInfo[] fieldInfo, java.util.Map res)doublereadDouble()protected voidreadFieldsMapBased(FSTClazzInfo.FSTFieldInfo referencee, FSTClazzInfo serializationInfo, java.lang.Object newObj)intreadFInt()floatreadFloat()voidreadFully(byte[] b)voidreadFully(byte[] b, int off, int len)intreadInt()java.lang.StringreadLine()longreadLong()java.lang.ObjectreadObject()java.lang.ObjectreadObject(java.lang.Class... possibles)protected java.lang.ObjectreadObjectCompatible(FSTClazzInfo.FSTFieldInfo referencee, FSTClazzInfo serializationInfo, java.lang.Object newObj)protected voidreadObjectCompatibleRecursive(FSTClazzInfo.FSTFieldInfo referencee, java.lang.Object toRead, FSTClazzInfo serializationInfo, java.lang.Class cl)protected voidreadObjectFields(FSTClazzInfo.FSTFieldInfo referencee, FSTClazzInfo serializationInfo, FSTClazzInfo.FSTFieldInfo[] fieldInfo, java.lang.Object newObj, int startIndex, int version)java.lang.ObjectreadObjectInternal(java.lang.Class... expected)java.lang.ObjectreadObjectWithHeader(FSTClazzInfo.FSTFieldInfo referencee)shortreadShort()java.lang.StringreadStringAsc()len < 127 !!!!!java.lang.StringreadStringUTF()intreadUnsignedByte()intreadUnsignedShort()java.lang.StringreadUTF()voidregisterObject(java.lang.Object o, int streamPosition, FSTClazzInfo info, FSTClazzInfo.FSTFieldInfo referencee)voidreset()protected voidresetAndClearRefs()voidresetForReuse(java.io.InputStream in)voidresetForReuseCopyArray(byte[] bytes, int off, int len)voidresetForReuseUseArray(byte[] bytes)voidresetForReuseUseArray(byte[] bytes, int len)protected voidsetCodec(FSTDecoder codec)voidsetConditionalCallback(FSTObjectInput.ConditionalCallback conditionalCallback)voidsetReadExternalReadAHead(int readExternalReadAHead)since the stock readXX methods on InputStream are final, i can't ensure sufficient readAhead on the inputStream before calling readExternal.voidsetVersionConflictListener(VersionConflictListener versionConflictListener)see @Version annotationlongskip(long n)intskipBytes(int n)protected booleanskipConditional(java.lang.Object newObj, int conditional, FSTClazzInfo.FSTFieldInfo subInfo)
-
Field Details
-
REGISTER_ENUMS_READ
public static boolean REGISTER_ENUMS_READ -
emptyStream
public static java.io.ByteArrayInputStream emptyStream -
codec
-
objects
-
debugStack
protected java.util.Stack<java.lang.String> debugStack -
curDepth
protected int curDepth -
callbacks
-
ignoreAnnotations
protected boolean ignoreAnnotations -
clInfoRegistry
-
conditionalCallback
-
readExternalReadAHead
protected int readExternalReadAHead -
versionConflictListener
-
conf
-
isCrossPlatform
protected boolean isCrossPlatform -
infoCache
-
closed
protected boolean closed -
fakeWrapper
-
-
Constructor Details
-
FSTObjectInput
public FSTObjectInput() throws java.io.IOException- Throws:
java.io.IOException
-
FSTObjectInput
-
FSTObjectInput
public FSTObjectInput(java.io.InputStream in) throws java.io.IOExceptionCreates a FSTObjectInput that uses the specified underlying InputStream.- Parameters:
in- the specified input stream- Throws:
java.io.IOException
-
FSTObjectInput
Creates a FSTObjectInput that uses the specified underlying InputStream. Don't create a FSTConfiguration with each stream, just create one global static configuration and reuseit. FSTConfiguration is threadsafe.- Parameters:
in- the specified input stream
-
-
Method Details
-
getConf
-
readFully
public void readFully(byte[] b) throws java.io.IOException- Specified by:
readFullyin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readFully
public void readFully(byte[] b, int off, int len) throws java.io.IOException- Specified by:
readFullyin interfacejava.io.DataInput- Throws:
java.io.IOException
-
skipBytes
public int skipBytes(int n) throws java.io.IOException- Specified by:
skipBytesin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readBoolean
public boolean readBoolean() throws java.io.IOException- Specified by:
readBooleanin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readByte
public byte readByte() throws java.io.IOException- Specified by:
readBytein interfacejava.io.DataInput- Throws:
java.io.IOException
-
readUnsignedByte
public int readUnsignedByte() throws java.io.IOException- Specified by:
readUnsignedBytein interfacejava.io.DataInput- Throws:
java.io.IOException
-
readShort
public short readShort() throws java.io.IOException- Specified by:
readShortin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readUnsignedShort
public int readUnsignedShort() throws java.io.IOException- Specified by:
readUnsignedShortin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readChar
public char readChar() throws java.io.IOException- Specified by:
readCharin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readInt
public int readInt() throws java.io.IOException- Specified by:
readIntin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readLong
public long readLong() throws java.io.IOException- Specified by:
readLongin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readFloat
public float readFloat() throws java.io.IOException- Specified by:
readFloatin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readDouble
public double readDouble() throws java.io.IOException- Specified by:
readDoublein interfacejava.io.DataInput- Throws:
java.io.IOException
-
readLine
public java.lang.String readLine() throws java.io.IOException- Specified by:
readLinein interfacejava.io.DataInput- Throws:
java.io.IOException
-
readUTF
public java.lang.String readUTF() throws java.io.IOException- Specified by:
readUTFin interfacejava.io.DataInput- Throws:
java.io.IOException
-
getCodec
-
setCodec
-
isClosed
public boolean isClosed() -
getClassForName
public java.lang.Class getClassForName(java.lang.String name) throws java.lang.ClassNotFoundException- Throws:
java.lang.ClassNotFoundException
-
initRegistries
-
getConditionalCallback
-
setConditionalCallback
-
getReadExternalReadAHead
public int getReadExternalReadAHead() -
setReadExternalReadAHead
public void setReadExternalReadAHead(int readExternalReadAHead)since the stock readXX methods on InputStream are final, i can't ensure sufficient readAhead on the inputStream before calling readExternal. Default value is 16000 bytes. If you make use of the externalizable interfac and write larger Objects a) cast the ObjectInput in readExternal to FSTObjectInput and call ensureReadAhead on this in your readExternal method b) set a sufficient maximum using this method before serializing.- Parameters:
readExternalReadAHead-
-
readObject
public java.lang.Object readObject() throws java.lang.ClassNotFoundException, java.io.IOException- Specified by:
readObjectin interfacejava.io.ObjectInput- Throws:
java.lang.ClassNotFoundExceptionjava.io.IOException
-
read
public int read() throws java.io.IOException- Specified by:
readin interfacejava.io.ObjectInput- Throws:
java.io.IOException
-
read
public int read(byte[] b) throws java.io.IOException- Specified by:
readin interfacejava.io.ObjectInput- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException- Specified by:
readin interfacejava.io.ObjectInput- Throws:
java.io.IOException
-
skip
public long skip(long n) throws java.io.IOException- Specified by:
skipin interfacejava.io.ObjectInput- Throws:
java.io.IOException
-
available
public int available() throws java.io.IOException- Specified by:
availablein interfacejava.io.ObjectInput- Throws:
java.io.IOException
-
processValidation
protected void processValidation() throws java.io.InvalidObjectException- Throws:
java.io.InvalidObjectException
-
readObject
public java.lang.Object readObject(java.lang.Class... possibles) throws java.lang.Exception- Throws:
java.lang.Exception
-
readObjectInternal
public java.lang.Object readObjectInternal(java.lang.Class... expected) throws java.lang.ClassNotFoundException, java.io.IOException, java.lang.IllegalAccessException, java.lang.InstantiationException- Throws:
java.lang.ClassNotFoundExceptionjava.io.IOExceptionjava.lang.IllegalAccessExceptionjava.lang.InstantiationException
-
readObjectWithHeader
public java.lang.Object readObjectWithHeader(FSTClazzInfo.FSTFieldInfo referencee) throws java.lang.Exception- Throws:
java.lang.Exception
-
instantiateSpecialTag
protected java.lang.Object instantiateSpecialTag(FSTClazzInfo.FSTFieldInfo referencee, int readPos, byte code) throws java.lang.Exception- Throws:
java.lang.Exception
-
getClazzInfo
-
instantiateHandle
protected java.lang.Object instantiateHandle(FSTClazzInfo.FSTFieldInfo referencee) throws java.io.IOException- Throws:
java.io.IOException
-
instantiateArray
protected java.lang.Object instantiateArray(FSTClazzInfo.FSTFieldInfo referencee, int readPos) throws java.lang.Exception- Throws:
java.lang.Exception
-
instantiateEnum
protected java.lang.Object instantiateEnum(FSTClazzInfo.FSTFieldInfo referencee, int readPos) throws java.io.IOException, java.lang.ClassNotFoundException- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
instantiateBigInt
protected java.lang.Object instantiateBigInt() throws java.io.IOException- Throws:
java.io.IOException
-
instantiateAndReadWithSer
protected java.lang.Object instantiateAndReadWithSer(java.lang.Class c, FSTObjectSerializer ser, FSTClazzInfo clzSerInfo, FSTClazzInfo.FSTFieldInfo referencee, int readPos) throws java.lang.Exception- Throws:
java.lang.Exception
-
instantiateAndReadNoSer
protected java.lang.Object instantiateAndReadNoSer(java.lang.Class c, FSTClazzInfo clzSerInfo, FSTClazzInfo.FSTFieldInfo referencee, int readPos) throws java.lang.Exception- Throws:
java.lang.Exception
-
readObjectCompatible
protected java.lang.Object readObjectCompatible(FSTClazzInfo.FSTFieldInfo referencee, FSTClazzInfo serializationInfo, java.lang.Object newObj) throws java.lang.Exception- Throws:
java.lang.Exception
-
handleReadRessolve
protected java.lang.Object handleReadRessolve(FSTClazzInfo serializationInfo, java.lang.Object newObj) throws java.lang.IllegalAccessException- Throws:
java.lang.IllegalAccessException
-
readObjectCompatibleRecursive
protected void readObjectCompatibleRecursive(FSTClazzInfo.FSTFieldInfo referencee, java.lang.Object toRead, FSTClazzInfo serializationInfo, java.lang.Class cl) throws java.lang.Exception- Throws:
java.lang.Exception
-
defaultReadObject
public void defaultReadObject(FSTClazzInfo.FSTFieldInfo referencee, FSTClazzInfo serializationInfo, java.lang.Object newObj) -
readObjectFields
protected void readObjectFields(FSTClazzInfo.FSTFieldInfo referencee, FSTClazzInfo serializationInfo, FSTClazzInfo.FSTFieldInfo[] fieldInfo, java.lang.Object newObj, int startIndex, int version) throws java.lang.Exception- Throws:
java.lang.Exception
-
getVersionConflictListener
-
setVersionConflictListener
see @Version annotation- Parameters:
versionConflictListener-
-
oldVersionRead
protected void oldVersionRead(java.lang.Object newObj) -
readFieldsMapBased
protected void readFieldsMapBased(FSTClazzInfo.FSTFieldInfo referencee, FSTClazzInfo serializationInfo, java.lang.Object newObj) throws java.lang.Exception- Throws:
java.lang.Exception
-
skipConditional
protected boolean skipConditional(java.lang.Object newObj, int conditional, FSTClazzInfo.FSTFieldInfo subInfo) -
readCompatibleObjectFields
protected void readCompatibleObjectFields(FSTClazzInfo.FSTFieldInfo referencee, FSTClazzInfo serializationInfo, FSTClazzInfo.FSTFieldInfo[] fieldInfo, java.util.Map res) throws java.lang.Exception- Throws:
java.lang.Exception
-
readStringUTF
public java.lang.String readStringUTF() throws java.io.IOException- Throws:
java.io.IOException
-
readStringAsc
public java.lang.String readStringAsc() throws java.io.IOExceptionlen < 127 !!!!!- Returns:
- Throws:
java.io.IOException
-
readArray
protected java.lang.Object readArray(FSTClazzInfo.FSTFieldInfo referencee, int pos) throws java.lang.Exception- Throws:
java.lang.Exception
-
readArrayNoHeader
protected java.lang.Object readArrayNoHeader(FSTClazzInfo.FSTFieldInfo referencee, int pos, java.lang.Class arrCl) throws java.lang.Exception- Throws:
java.lang.Exception
-
registerObject
public void registerObject(java.lang.Object o, int streamPosition, FSTClazzInfo info, FSTClazzInfo.FSTFieldInfo referencee) -
readClass
- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
resetAndClearRefs
protected void resetAndClearRefs() -
reset
public void reset() throws java.io.IOException- Throws:
java.io.IOException
-
resetForReuse
public void resetForReuse(java.io.InputStream in) throws java.io.IOException- Throws:
java.io.IOException
-
resetForReuseCopyArray
public void resetForReuseCopyArray(byte[] bytes, int off, int len) throws java.io.IOException- Throws:
java.io.IOException
-
resetForReuseUseArray
public void resetForReuseUseArray(byte[] bytes) throws java.io.IOException- Throws:
java.io.IOException
-
resetForReuseUseArray
public void resetForReuseUseArray(byte[] bytes, int len) throws java.io.IOException- Throws:
java.io.IOException
-
readFInt
public final int readFInt() throws java.io.IOException- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.ObjectInput- Throws:
java.io.IOException
-
getObjectInputStream
protected java.io.ObjectInputStream getObjectInputStream(java.lang.Class cl, FSTClazzInfo clInfo, FSTClazzInfo.FSTFieldInfo referencee, java.lang.Object toRead) throws java.io.IOException- Throws:
java.io.IOException
-
pushBack
protected void pushBack(int i)
-