Skip navigation links

Oracle® Coherence Java API Reference
v3.5

E14977-01


com.tangosol.io
Interface ReadBuffer.BufferInput

All Superinterfaces:
java.io.DataInput, InputStreaming
All Known Implementing Classes:
AbstractByteArrayReadBuffer.ByteArrayBufferInput, AbstractReadBuffer.AbstractBufferInput, ByteBufferReadBuffer.ByteBufferInput, MultiBufferReadBuffer.MultiBufferInput, WrapperBufferInput
Enclosing interface:
ReadBuffer

public static interface ReadBuffer.BufferInput
extends InputStreaming, java.io.DataInput

The BufferInput interface represents a DataInputStream on top of a ReadBuffer.

Author:
cp 2005.01.18

Method Summary
 int available()
          Returns the number of bytes that can be read (or skipped over) from this input stream without causing a blocking I/O condition to occur.
 void close()
          Close the InputStream and release any system resources associated with it.
 ReadBuffer getBuffer()
          Get the ReadBuffer object that this BufferInput is reading from.
 int getOffset()
          Determine the current offset of this BufferInput within the underlying ReadBuffer.
 void mark(int cbReadLimit)
          Marks the current read position in the InputStream in order to support the stream to be later "rewound" (using the InputStreaming.reset() method) to the current position.
 boolean markSupported()
          Determine if this InputStream supports the mark(int) and InputStreaming.reset() methods.
 ReadBuffer readBuffer(int cb)
          Read cb bytes and return them as a ReadBuffer object.
 int readPackedInt()
          Read an int value using a variable-length storage format as described by WriteBuffer.BufferOutput.writePackedInt(int).
 long readPackedLong()
          Read a long value using a variable-length storage format as described by WriteBuffer.BufferOutput.writePackedLong(long).
 java.lang.String readSafeUTF()
          Read a variable-length encoded UTF packed String.
 void setOffset(int of)
          Specify the offset of the next byte to read from the underlying ReadBuffer.

 

Methods inherited from interface com.tangosol.io.InputStreaming
read, read, read, reset, skip

 

Methods inherited from interface java.io.DataInput
readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, skipBytes

 

Method Detail

available

int available()
              throws java.io.IOException
Returns the number of bytes that can be read (or skipped over) from this input stream without causing a blocking I/O condition to occur. This method reflects the assumed implementation of various buffering InputStreams, which can guarantee non-blocking reads up to the extent of their buffers, but beyond that the read operations will have to read from some underlying (and potentially blocking) source.

BufferInput implementations must implement this method to return the extent of the buffer that has not yet been read; in other words, the entire un-read portion of the buffer must be available.

Specified by:
available in interface InputStreaming
Returns:
the number of bytes that can be read from this InputStream without blocking
Throws:
java.io.IOException - if an I/O error occurs

close

void close()
           throws java.io.IOException
Close the InputStream and release any system resources associated with it.

BufferInput implementations do not pass this call down onto an underlying stream, if any.

Specified by:
close in interface InputStreaming
Throws:
java.io.IOException - if an I/O error occurs

mark

void mark(int cbReadLimit)
Marks the current read position in the InputStream in order to support the stream to be later "rewound" (using the InputStreaming.reset() method) to the current position. The caller passes in the maximum number of bytes that it expects to read before calling the InputStreaming.reset() method, thus indicating the upper bounds of the responsibility of the stream to be able to buffer what it has read in order to support this functionality.

BufferInput implementations ignore the cbReadLimit; they must support an unlimited read limit, since they appear to the user as an input stream on top of a fully realized read buffer.

Specified by:
mark in interface InputStreaming
Parameters:
cbReadLimit - the maximum number of bytes that caller expects the InputStream to be able to read before the mark position becomes invalid

markSupported

boolean markSupported()
Determine if this InputStream supports the mark(int) and InputStreaming.reset() methods.

BufferInput implementations must support the mark(int) and InputStreaming.reset() methods, so this method always returns true.

Specified by:
markSupported in interface InputStreaming
Returns:
true if this InputStream supports the mark and reset method; false otherwise

getBuffer

ReadBuffer getBuffer()
Get the ReadBuffer object that this BufferInput is reading from.
Returns:
the underlying ReadBuffer object

readSafeUTF

java.lang.String readSafeUTF()
                             throws java.io.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.
Returns:
a String value; may be null
Throws:
java.io.IOException - if an I/O error occurs

readPackedInt

int readPackedInt()
                  throws java.io.IOException
Read an int value using a variable-length storage format as described by WriteBuffer.BufferOutput.writePackedInt(int).
Returns:
an int value
Throws:
java.io.IOException - if an I/O error occurs

readPackedLong

long readPackedLong()
                    throws java.io.IOException
Read a long value using a variable-length storage format as described by WriteBuffer.BufferOutput.writePackedLong(long).
Returns:
a long value
Throws:
java.io.IOException - if an I/O error occurs

readBuffer

ReadBuffer readBuffer(int cb)
                      throws java.io.IOException
Read cb bytes and return them as a ReadBuffer object.
Parameters:
cb - the number of bytes to read
Returns:
a ReadBuffer object composed of cb bytes read from the BufferInput
Throws:
java.io.EOFException - if the stream is exhausted before the number of bytes indicated could be read
java.io.IOException - if an I/O error occurs

getOffset

int getOffset()
Determine the current offset of this BufferInput within the underlying ReadBuffer.
Returns:
the offset of the next byte to read from the ReadBuffer

setOffset

void setOffset(int of)
Specify the offset of the next byte to read from the underlying ReadBuffer.
Parameters:
of - the offset of the next byte to read from the ReadBuffer
Throws:
java.lang.IndexOutOfBoundsException - if of < 0 or of > getBuffer().length()

Skip navigation links

Oracle® Coherence Java API Reference
v3.5

E14977-01


Copyright © 2000, 2009, Oracle. All rights reserved.