Class WrapperBufferInput

All Implemented Interfaces:
com.oracle.coherence.common.io.InputStreaming, InputStreaming, ReadBuffer.BufferInput, Closeable, DataInput, AutoCloseable
Direct Known Subclasses:
WrapperBufferInput.VersionAwareBufferInput

public class WrapperBufferInput extends WrapperDataInputStream implements ReadBuffer.BufferInput
This is an imitation BufferInput implementation that provides the BufferInput interface by delegating to an object that implements the DataInput interface. Primarily, this is intended as a base class for building specific-purpose DataInput wrappers.
Author:
jh 2007.11.17
  • Constructor Details

    • WrapperBufferInput

      public WrapperBufferInput(DataInput in)
      Construct a WrapperBufferInput that will read from the specified object implementing the DataInput interface.
      Parameters:
      in - an object implementing DataInput to read from
    • WrapperBufferInput

      public WrapperBufferInput(DataInput in, ClassLoader loader)
      Construct a WrapperBufferInput that will read from the specified object implementing the DataInput interface.
      Parameters:
      in - an object implementing DataInput to read from
      loader - the ClassLoader to use
  • Method Details

    • getBuffer

      public ReadBuffer getBuffer()
      Get the ReadBuffer object that this BufferInput is reading from.
      Specified by:
      getBuffer in interface ReadBuffer.BufferInput
      Returns:
      the underlying ReadBuffer object
    • readSafeUTF

      public String readSafeUTF() throws IOException
      Read a variable-length encoded UTF packed String. The major differences between this implementation and DataInput is that this supports null String values and is not limited to 64KB UTF-encoded values.
      Specified by:
      readSafeUTF in interface ReadBuffer.BufferInput
      Returns:
      a String value; may be null
      Throws:
      IOException - if an I/O error occurs
    • readPackedInt

      public int readPackedInt() throws IOException
      Read an int value using a variable-length storage format as described by WriteBuffer.BufferOutput.writePackedInt(int).
      Specified by:
      readPackedInt in interface ReadBuffer.BufferInput
      Returns:
      an int value
      Throws:
      IOException - if an I/O error occurs
    • readPackedLong

      public long readPackedLong() throws IOException
      Read a long value using a variable-length storage format as described by WriteBuffer.BufferOutput.writePackedLong(long).
      Specified by:
      readPackedLong in interface ReadBuffer.BufferInput
      Returns:
      a long value
      Throws:
      IOException - if an I/O error occurs
    • readBuffer

      public ReadBuffer readBuffer(int cb) throws IOException
      Read cb bytes and return them as a ReadBuffer object.
      Specified by:
      readBuffer in interface ReadBuffer.BufferInput
      Parameters:
      cb - the number of bytes to read
      Returns:
      a ReadBuffer object composed of cb bytes read from the BufferInput
      Throws:
      IOException - if an I/O error occurs
    • getOffset

      public int getOffset()
      Determine the current offset of this BufferInput within the underlying ReadBuffer.
      Specified by:
      getOffset in interface ReadBuffer.BufferInput
      Returns:
      the offset of the next byte to read from the ReadBuffer
    • setOffset

      public void setOffset(int of)
      Specify the offset of the next byte to read from the underlying ReadBuffer.
      Specified by:
      setOffset in interface ReadBuffer.BufferInput
      Parameters:
      of - the offset of the next byte to read from the ReadBuffer
    • getObjectInputFilter

      public Object getObjectInputFilter()
      Description copied from interface: ReadBuffer.BufferInput
      Returns an ObjectInputFilter (or null) that should be used by the caller to confirm / deny deserialization of a class encoded in this input stream.

      Note: the return type is agnostic of the ObjectInputFilter to support various JDK versions.

      Specified by:
      getObjectInputFilter in interface ReadBuffer.BufferInput
      Returns:
      null or an ObjectInputFilter that will permit (or not) the constructor of a class encoded in this stream.
      See Also:
    • setObjectInputFilter

      public void setObjectInputFilter(Object filter)
      Description copied from interface: ReadBuffer.BufferInput
      Set the ObjectInputFilter for this stream.

      The filter's checkInput method is expected to be called for each class and reference deserialized in the stream.

      Specified by:
      setObjectInputFilter in interface ReadBuffer.BufferInput
      Parameters:
      filter - an ObjectInputFilter instance as an Object to enable running with Java version 8 or higher, may be null
    • getDataInput

      public DataInput getDataInput()
      Obtain the underlying object providing the DataInput interface that this object is delegating to.
      Overrides:
      getDataInput in class WrapperDataInputStream
      Returns:
      the underlying DataInput