IBM WebSphereTM eXtreme Scale, Release 8.6
API Specification

com.ibm.websphere.objectgrid.io
Class XsDataInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by com.ibm.websphere.objectgrid.io.XsDataInputStream
All Implemented Interfaces:
Closeable

public abstract class XsDataInputStream
extends InputStream

A random access, byte-oriented, portable stream for reading primitive types and string.
This stream combines the facilities of

This class is not intended as a base class for user code to extend. Instances of XsDataInputStream are provided solely by the WebSphere eXtreme Scale runtime for use by plug-ins.

Since:
7.1.1

Constructor Summary
XsDataInputStream()
           
 
Method Summary
abstract  ByteOrder getByteOrder()
          Gets the byte order for writing multi-byte data.
abstract  String getEncodingScheme()
          Gets canonical name of the current string encoding scheme.
abstract  boolean isClosed()
          Affirms if this stream has been closed.
abstract  int position()
          Gets the current position from where the next byte will be read.
abstract  XsDataInputStream position(int i)
          Positions this stream to read from the given position.
abstract  boolean readBoolean()
          Reads 1-byte as a boolean value at the current position in current byte order.
abstract  byte readByte()
          Reads 1-byte as a signed byte value at the current position in current byte order.
abstract  char readChar()
          Reads 2-byte as an signed integer value in the current position in current byte order.
abstract  void readChars(char[] c)
          Reads c.length characters as an array of 2-byte signed integer values in the current position in current byte order.
abstract  double readDouble()
          Reads a 8-byte floating point number at the current position in current byte order.
abstract  float readFloat()
          Reads a 4-byte floating point number at the current position in current byte order.
abstract  void readFully(byte[] b)
          Reads b.length bytes, if available.
abstract  void readFully(byte[] b, int off, int len)
          Reads b.length bytes, if available.
abstract  int readInt()
          Reads a 4-byte integer at the current position in current byte order.
abstract  long readLong()
          Reads a 8-byte integer number at the current position in current byte order.
abstract  short readShort()
          Reads a 2-byte signed integer number at the current position in current byte order.
abstract  String readString()
          Reads a string assuming that the number of bytes of the string to be read precedes the actual bytes as a 2-byte short number.
abstract  String readString(String encoding)
          Reads a string assuming that the number of bytes of the string to be read precedes the actual bytes as a 2-byte short number.
abstract  String readString(String encoding, boolean lengthPrepended, int L, boolean nullTerminated)
          Reads a string as a array of bytes with given parameter specifications.
abstract  String readStringAsNullTerminated()
          Reads a string assuming that the string to be read is terminated by a single bye of value 0.
abstract  String readStringAsNullTerminated(String encoding)
          Reads a string assuming that the string to be read is terminated by a single bye of value 0.
abstract  String readStringRaw(int L)
          Reads a string as a array of bytes of given length.
abstract  String readStringRaw(String encoding, int L)
          Reads a string as a array of bytes of given length.
abstract  int readUnsignedByte()
          Reads 1-byte as an unsigned byte value at the current position in current byte order.
abstract  int readUnsignedShort()
          Reads a 2-byte unsigned integer number at the current position in current byte order.
abstract  String readUTF8String()
          Reads a string as an array of bytes with the UTF-8 encoding The length is stored in a varint at the current position in the stream to indicate the number of UTF-8 bytes that will follow in the buffer.
abstract  int readVarintAsInt()
          Reads a variable length integer number at the current position in the current byte order.
abstract  long readVarintAsLong()
          Reads a variable length long number at the current position in the current byte order.
abstract  XsDataInputStream rewind()
          Rewinds the stream by reopening, if necessary and repositioning at the state of construction.
abstract  boolean setByteOrder(ByteOrder order)
          Sets the byte order of the data.
abstract  void setEncodingScheme(String enc)
          Sets the current string encoding scheme.
abstract  int size()
          Gets the total number of bytes in this stream.
abstract  byte[] toByteArray()
          Gets the underlying bytes of this stream.
abstract  ByteBuffer toByteBuffer(ByteBuffer buffer)
          Transfers the underlying bytes of this stream to the given byte buffer at current position.
 
Methods inherited from class java.io.InputStream
available, close, mark, markSupported, read, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XsDataInputStream

public XsDataInputStream()
Method Detail

position

public abstract XsDataInputStream position(int i)
                                    throws IOException
Positions this stream to read from the given position.

Parameters:
i - a position in this stream
Returns:
this stream positioned at the given position.
Throws:
IOException - if the position is less than 0 or more than the size of this stream

position

public abstract int position()
                      throws IOException
Gets the current position from where the next byte will be read.

Throws:
IOException

size

public abstract int size()
                  throws IOException
Gets the total number of bytes in this stream.

Throws:
IOException

isClosed

public abstract boolean isClosed()
Affirms if this stream has been closed.


readBoolean

public abstract boolean readBoolean()
                             throws IOException
Reads 1-byte as a boolean value at the current position in current byte order.

Throws:
IOException

readByte

public abstract byte readByte()
                       throws IOException
Reads 1-byte as a signed byte value at the current position in current byte order.

Throws:
IOException

readUnsignedByte

public abstract int readUnsignedByte()
                              throws IOException
Reads 1-byte as an unsigned byte value at the current position in current byte order.

Throws:
IOException

readFully

public abstract void readFully(byte[] b,
                               int off,
                               int len)
                        throws IOException
Reads b.length bytes, if available. If requisite bytes are not available, an IOException is thrown. If the given byte array is null, throws a NullPointerException.

Parameters:
b - array of bytes to be populated. Must not be null.
off - an offset index. Must be positive.
len - number of bytes to read. Must be positive.
Throws:
IOException

readFully

public abstract void readFully(byte[] b)
                        throws IOException
Reads b.length bytes, if available. If requisite bytes are not available, an IOException is thrown. If the given byte array is null, throws a NullPointerException.

Throws:
IOException

readChar

public abstract char readChar()
                       throws IOException
Reads 2-byte as an signed integer value in the current position in current byte order. The 2-byte integer value is interpreted as a 2-byte UTF-16 character.

Throws:
IOException

readChars

public abstract void readChars(char[] c)
                        throws IOException
Reads c.length characters as an array of 2-byte signed integer values in the current position in current byte order. The 2-byte integer values are interpreted as 2-byte UTF-16 characters.

Throws:
IOException

readInt

public abstract int readInt()
                     throws IOException
Reads a 4-byte integer at the current position in current byte order.

Throws:
IOException

readFloat

public abstract float readFloat()
                         throws IOException
Reads a 4-byte floating point number at the current position in current byte order.

Throws:
IOException

readDouble

public abstract double readDouble()
                           throws IOException
Reads a 8-byte floating point number at the current position in current byte order.

Throws:
IOException

readLong

public abstract long readLong()
                       throws IOException
Reads a 8-byte integer number at the current position in current byte order.

Throws:
IOException

readShort

public abstract short readShort()
                         throws IOException
Reads a 2-byte signed integer number at the current position in current byte order.

Throws:
IOException

readUnsignedShort

public abstract int readUnsignedShort()
                               throws IOException
Reads a 2-byte unsigned integer number at the current position in current byte order.

Throws:
IOException

readVarintAsInt

public abstract int readVarintAsInt()
                             throws IOException
Reads a variable length integer number at the current position in the current byte order.

Throws:
IOException

readVarintAsLong

public abstract long readVarintAsLong()
                               throws IOException
Reads a variable length long number at the current position in the current byte order.

Throws:
IOException

getEncodingScheme

public abstract String getEncodingScheme()
Gets canonical name of the current string encoding scheme. By default, the encoding scheme is UTF-8.


setEncodingScheme

public abstract void setEncodingScheme(String enc)
Sets the current string encoding scheme.

Parameters:
enc - canonical name of an encoding scheme.

setByteOrder

public abstract boolean setByteOrder(ByteOrder order)
Sets the byte order of the data.

Parameters:
order - BIG_ENDIAN or LITTLE_ENDIAN byte order
Returns:
if the given order is different than the native order of the platform.

getByteOrder

public abstract ByteOrder getByteOrder()
Gets the byte order for writing multi-byte data.

Returns:
BIG_ENDIAN or LITTLE_ENDIAN byte order

readString

public abstract String readString()
                           throws IOException
Reads a string assuming that the number of bytes of the string to be read precedes the actual bytes as a 2-byte short number. The bytes are read and decoded with the current encoding scheme.
This method emulates the semantics of equivalent method of readUTF.

Returns:
the string being read
Throws:
IOException

readString

public abstract String readString(String encoding)
                           throws IOException
Reads a string assuming that the number of bytes of the string to be read precedes the actual bytes as a 2-byte short number. The bytes are read and decoded with the given encoding scheme.

Returns:
the string being read
Throws:
IOException

readStringAsNullTerminated

public abstract String readStringAsNullTerminated()
                                           throws IOException
Reads a string assuming that the string to be read is terminated by a single bye of value 0. The bytes are read and decoded with the current encoding scheme.

Returns:
the string being read
Throws:
IOException

readStringAsNullTerminated

public abstract String readStringAsNullTerminated(String encoding)
                                           throws IOException
Reads a string assuming that the string to be read is terminated by a single bye of value 0. The bytes are read and decoded with the given encoding scheme.

Returns:
the string being read
Throws:
IOException

readStringRaw

public abstract String readStringRaw(int L)
                              throws IOException
Reads a string as a array of bytes of given length. The bytes are read and decoded with the current encoding scheme.

Returns:
the string being read
Throws:
IOException

readStringRaw

public abstract String readStringRaw(String encoding,
                                     int L)
                              throws IOException
Reads a string as a array of bytes of given length. The bytes are read and decoded with the given encoding scheme.

Returns:
the string being read
Throws:
IOException

readString

public abstract String readString(String encoding,
                                  boolean lengthPrepended,
                                  int L,
                                  boolean nullTerminated)
                           throws IOException
Reads a string as a array of bytes with given parameter specifications. The bytes are read and decoded with the given encoding scheme.

Parameters:
lengthPrepended - if true, then a 2-byte short is read from the current position of the stream itself. The value read is assumed to be the number of bytes in the string. The next two parameters are ignored.
L - if the lengthPrepended and nullTerminated parameter are both false, then this value is considered to be the number of bytes in the string.
nullTerminated - if true and the lengthPrepended is false, then scans the stream from the current position to find a byte of value 0 as the terminating character of the string to be read.
Returns:
the string being read
Throws:
IOException

readUTF8String

public abstract String readUTF8String()
                               throws IOException
Reads a string as an array of bytes with the UTF-8 encoding The length is stored in a varint at the current position in the stream to indicate the number of UTF-8 bytes that will follow in the buffer.

Returns:
the string being read
Throws:
IOException

rewind

public abstract XsDataInputStream rewind()
Rewinds the stream by reopening, if necessary and repositioning at the state of construction.

Returns:
this stream positioned at the beginning of the stream.

toByteArray

public abstract byte[] toByteArray()
Gets the underlying bytes of this stream.


toByteBuffer

public abstract ByteBuffer toByteBuffer(ByteBuffer buffer)
Transfers the underlying bytes of this stream to the given byte buffer at current position.

Parameters:
buffer - a non-null buffer
Returns:
the buffer after the bytes are written.

IBM WebSphereTM eXtreme Scale, Release 8.6
API Specification

© Copyright International Business Machines Corp 2005,2012. All rights reserved.