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
  • Field Details

  • Constructor Details

    • FSTObjectInput

      public FSTObjectInput() throws java.io.IOException
      Throws:
      java.io.IOException
    • FSTObjectInput

      public FSTObjectInput​(FSTConfiguration conf)
    • FSTObjectInput

      public FSTObjectInput​(java.io.InputStream in) throws java.io.IOException
      Creates a FSTObjectInput that uses the specified underlying InputStream.
      Parameters:
      in - the specified input stream
      Throws:
      java.io.IOException
    • FSTObjectInput

      public FSTObjectInput​(java.io.InputStream in, FSTConfiguration conf)
      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

      public FSTConfiguration getConf()
    • readFully

      public void readFully​(byte[] b) throws java.io.IOException
      Specified by:
      readFully in interface java.io.DataInput
      Throws:
      java.io.IOException
    • readFully

      public void readFully​(byte[] b, int off, int len) throws java.io.IOException
      Specified by:
      readFully in interface java.io.DataInput
      Throws:
      java.io.IOException
    • skipBytes

      public int skipBytes​(int n) throws java.io.IOException
      Specified by:
      skipBytes in interface java.io.DataInput
      Throws:
      java.io.IOException
    • readBoolean

      public boolean readBoolean() throws java.io.IOException
      Specified by:
      readBoolean in interface java.io.DataInput
      Throws:
      java.io.IOException
    • readByte

      public byte readByte() throws java.io.IOException
      Specified by:
      readByte in interface java.io.DataInput
      Throws:
      java.io.IOException
    • readUnsignedByte

      public int readUnsignedByte() throws java.io.IOException
      Specified by:
      readUnsignedByte in interface java.io.DataInput
      Throws:
      java.io.IOException
    • readShort

      public short readShort() throws java.io.IOException
      Specified by:
      readShort in interface java.io.DataInput
      Throws:
      java.io.IOException
    • readUnsignedShort

      public int readUnsignedShort() throws java.io.IOException
      Specified by:
      readUnsignedShort in interface java.io.DataInput
      Throws:
      java.io.IOException
    • readChar

      public char readChar() throws java.io.IOException
      Specified by:
      readChar in interface java.io.DataInput
      Throws:
      java.io.IOException
    • readInt

      public int readInt() throws java.io.IOException
      Specified by:
      readInt in interface java.io.DataInput
      Throws:
      java.io.IOException
    • readLong

      public long readLong() throws java.io.IOException
      Specified by:
      readLong in interface java.io.DataInput
      Throws:
      java.io.IOException
    • readFloat

      public float readFloat() throws java.io.IOException
      Specified by:
      readFloat in interface java.io.DataInput
      Throws:
      java.io.IOException
    • readDouble

      public double readDouble() throws java.io.IOException
      Specified by:
      readDouble in interface java.io.DataInput
      Throws:
      java.io.IOException
    • readLine

      public java.lang.String readLine() throws java.io.IOException
      Specified by:
      readLine in interface java.io.DataInput
      Throws:
      java.io.IOException
    • readUTF

      public java.lang.String readUTF() throws java.io.IOException
      Specified by:
      readUTF in interface java.io.DataInput
      Throws:
      java.io.IOException
    • getCodec

      public FSTDecoder getCodec()
    • setCodec

      protected void setCodec​(FSTDecoder codec)
    • isClosed

      public boolean isClosed()
    • getClassForName

      public java.lang.Class getClassForName​(java.lang.String name) throws java.lang.ClassNotFoundException
      Throws:
      java.lang.ClassNotFoundException
    • initRegistries

      protected void initRegistries​(FSTConfiguration conf)
    • getConditionalCallback

      public FSTObjectInput.ConditionalCallback getConditionalCallback()
    • setConditionalCallback

      public void setConditionalCallback​(FSTObjectInput.ConditionalCallback conditionalCallback)
    • 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:
      readObject in interface java.io.ObjectInput
      Throws:
      java.lang.ClassNotFoundException
      java.io.IOException
    • read

      public int read() throws java.io.IOException
      Specified by:
      read in interface java.io.ObjectInput
      Throws:
      java.io.IOException
    • read

      public int read​(byte[] b) throws java.io.IOException
      Specified by:
      read in interface java.io.ObjectInput
      Throws:
      java.io.IOException
    • read

      public int read​(byte[] b, int off, int len) throws java.io.IOException
      Specified by:
      read in interface java.io.ObjectInput
      Throws:
      java.io.IOException
    • skip

      public long skip​(long n) throws java.io.IOException
      Specified by:
      skip in interface java.io.ObjectInput
      Throws:
      java.io.IOException
    • available

      public int available() throws java.io.IOException
      Specified by:
      available in interface java.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.ClassNotFoundException
      java.io.IOException
      java.lang.IllegalAccessException
      java.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

      protected FSTClazzInfo getClazzInfo​(java.lang.Class c, FSTClazzInfo.FSTFieldInfo referencee)
    • 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.IOException
      java.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

      public VersionConflictListener getVersionConflictListener()
    • setVersionConflictListener

      public void setVersionConflictListener​(VersionConflictListener versionConflictListener)
      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.IOException
      len < 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

      public FSTClazzInfo readClass() throws java.io.IOException, java.lang.ClassNotFoundException
      Throws:
      java.io.IOException
      java.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:
      close in interface java.lang.AutoCloseable
      Specified by:
      close in interface java.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)