Package com.tangosol.io
Class WrapperBufferInput
- java.lang.Object
-
- java.io.InputStream
-
- com.tangosol.io.WrapperDataInputStream
-
- com.tangosol.io.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWrapperBufferInput.VersionAwareBufferInputA BufferInput implementation that in addition to delegating to the given DataInput provides an API to check whether the sender of the content of this BufferInput runs a version that supersedes (greater or equal to) the specified version.
-
Field Summary
-
Fields inherited from class com.tangosol.io.WrapperDataInputStream
m_in, m_loader
-
-
Constructor Summary
Constructors Constructor Description WrapperBufferInput(DataInput in)Construct a WrapperBufferInput that will read from the specified object implementing the DataInput interface.WrapperBufferInput(DataInput in, ClassLoader loader)Construct a WrapperBufferInput that will read from the specified object implementing the DataInput interface.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ReadBuffergetBuffer()Get the ReadBuffer object that this BufferInput is reading from.DataInputgetDataInput()Obtain the underlying object providing the DataInput interface that this object is delegating to.ObjectgetObjectInputFilter()Returns an ObjectInputFilter (or null) that should be used by the caller to confirm / deny deserialization of a class encoded in this input stream.intgetOffset()Determine the current offset of this BufferInput within the underlying ReadBuffer.ReadBufferreadBuffer(int cb)Readcbbytes and return them as a ReadBuffer object.intreadPackedInt()Read an int value using a variable-length storage format as described byWriteBuffer.BufferOutput.writePackedInt(int).longreadPackedLong()Read a long value using a variable-length storage format as described byWriteBuffer.BufferOutput.writePackedLong(long).StringreadSafeUTF()Read a variable-length encoded UTF packed String.voidsetObjectInputFilter(Object filter)Set theObjectInputFilterfor this stream.voidsetOffset(int of)Specify the offset of the next byte to read from the underlying ReadBuffer.-
Methods inherited from class com.tangosol.io.WrapperDataInputStream
available, close, getClassLoader, mark, markSupported, read, read, read, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, reset, setClassLoader, skip, skipBytes
-
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.oracle.coherence.common.io.InputStreaming
read, read, read, reset, skip
-
Methods inherited from interface com.tangosol.io.ReadBuffer.BufferInput
available, close, mark, markSupported, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, skipBytes
-
-
-
-
Constructor Detail
-
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 fromloader- the ClassLoader to use
-
-
Method Detail
-
getBuffer
public ReadBuffer getBuffer()
Get the ReadBuffer object that this BufferInput is reading from.- Specified by:
getBufferin interfaceReadBuffer.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:
readSafeUTFin interfaceReadBuffer.BufferInput- Returns:
- a String value; may be null
- Throws:
IOException- if an I/O error occurs
-
readPackedInt
public int readPackedInt() throws IOExceptionRead an int value using a variable-length storage format as described byWriteBuffer.BufferOutput.writePackedInt(int).- Specified by:
readPackedIntin interfaceReadBuffer.BufferInput- Returns:
- an int value
- Throws:
IOException- if an I/O error occurs
-
readPackedLong
public long readPackedLong() throws IOExceptionRead a long value using a variable-length storage format as described byWriteBuffer.BufferOutput.writePackedLong(long).- Specified by:
readPackedLongin interfaceReadBuffer.BufferInput- Returns:
- a long value
- Throws:
IOException- if an I/O error occurs
-
readBuffer
public ReadBuffer readBuffer(int cb) throws IOException
Readcbbytes and return them as a ReadBuffer object.- Specified by:
readBufferin interfaceReadBuffer.BufferInput- Parameters:
cb- the number of bytes to read- Returns:
- a ReadBuffer object composed of
cbbytes read from the BufferInput - Throws:
EOFException- if the stream is exhausted before the number of bytes indicated could be readIOException- if an I/O error occurs
-
getOffset
public int getOffset()
Determine the current offset of this BufferInput within the underlying ReadBuffer.- Specified by:
getOffsetin interfaceReadBuffer.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:
setOffsetin interfaceReadBuffer.BufferInput- Parameters:
of- the offset of the next byte to read from the ReadBuffer
-
getObjectInputFilter
public Object getObjectInputFilter()
Description copied from interface:ReadBuffer.BufferInputReturns 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:
getObjectInputFilterin interfaceReadBuffer.BufferInput- Returns:
- null or an ObjectInputFilter that will permit (or not) the constructor of a class encoded in this stream.
- See Also:
ReadBuffer.BufferInput.setObjectInputFilter(Object)
-
setObjectInputFilter
public void setObjectInputFilter(Object filter)
Description copied from interface:ReadBuffer.BufferInputSet theObjectInputFilterfor this stream.The filter's checkInput method is expected to be called for each class and reference deserialized in the stream.
- Specified by:
setObjectInputFilterin interfaceReadBuffer.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:
getDataInputin classWrapperDataInputStream- Returns:
- the underlying DataInput
-
-