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 class
WrapperBufferInput.VersionAwareBufferInput
A 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 ReadBuffer
getBuffer()
Get the ReadBuffer object that this BufferInput is reading from.DataInput
getDataInput()
Obtain the underlying object providing the DataInput interface that this object is delegating to.Object
getObjectInputFilter()
Returns an ObjectInputFilter (or null) that should be used by the caller to confirm / deny deserialization of a class encoded in this input stream.int
getOffset()
Determine the current offset of this BufferInput within the underlying ReadBuffer.ReadBuffer
readBuffer(int cb)
Readcb
bytes and return them as a ReadBuffer object.int
readPackedInt()
Read an int value using a variable-length storage format as described byWriteBuffer.BufferOutput.writePackedInt(int)
.long
readPackedLong()
Read a long value using a variable-length storage format as described byWriteBuffer.BufferOutput.writePackedLong(long)
.String
readSafeUTF()
Read a variable-length encoded UTF packed String.void
setObjectInputFilter(Object filter)
Set theObjectInputFilter
for this stream.void
setOffset(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:
getBuffer
in 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:
readSafeUTF
in interfaceReadBuffer.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 byWriteBuffer.BufferOutput.writePackedInt(int)
.- Specified by:
readPackedInt
in interfaceReadBuffer.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 byWriteBuffer.BufferOutput.writePackedLong(long)
.- Specified by:
readPackedLong
in interfaceReadBuffer.BufferInput
- Returns:
- a long value
- Throws:
IOException
- if an I/O error occurs
-
readBuffer
public ReadBuffer readBuffer(int cb) throws IOException
Readcb
bytes and return them as a ReadBuffer object.- Specified by:
readBuffer
in interfaceReadBuffer.BufferInput
- Parameters:
cb
- the number of bytes to read- Returns:
- a ReadBuffer object composed of
cb
bytes 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:
getOffset
in 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:
setOffset
in interfaceReadBuffer.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 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.BufferInput
Set theObjectInputFilter
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 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:
getDataInput
in classWrapperDataInputStream
- Returns:
- the underlying DataInput
-
-