Package com.tangosol.io
Class MultiByteArrayInputStream
java.lang.Object
java.io.InputStream
com.tangosol.io.MultiByteArrayInputStream
- All Implemented Interfaces:
com.oracle.coherence.common.io.InputStreaming,InputStreaming,Closeable,AutoCloseable
Reads binary data from a series of byte arrays.
- Author:
- cp 2001.11.03
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final byte[]Empty array of bytes.protected byte[][]The array of byte arrays.protected byte[]The current byte array.protected booleanTrue iff the array will be null'd out as it is traversed.protected booleanTrue after eof is determined.protected intThe index of the current byte array.protected intThe index of the marked byte array.protected intThe current offset in the current byte array.protected intThe marked offset in the marked byte array.protected static final intMarker position indicating that stream is not marked. -
Constructor Summary
ConstructorsConstructorDescriptionMultiByteArrayInputStream(byte[][] aab) Construct a MultiByteArrayInputStream.MultiByteArrayInputStream(byte[][] aab, boolean fDestructive) Construct a MultiByteArrayInputStream. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream.voidclose()Close the stream.voidmark(int readlimit) Marks the current position in this input stream.booleanTests if this input stream supports themarkandresetmethods.intread()Reads the next byte of data from the input stream.intread(byte[] abDest, int ofDest, int cbDest) Reads up tolenbytes of data from the input stream into an array of bytes.voidreset()Repositions this stream to the position at the time themarkmethod was last called on this input stream.longskip(long n) Skips over and discardsnbytes of data from this input stream.Methods inherited from class java.io.InputStream
nullInputStream, read, readAllBytes, readNBytes, readNBytes, skipNBytes, transferToMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.oracle.coherence.common.io.InputStreaming
read
-
Field Details
-
EMPTY_BYTES
protected static final byte[] EMPTY_BYTESEmpty array of bytes. -
MARK_UNSET
protected static final int MARK_UNSETMarker position indicating that stream is not marked.- See Also:
-
m_fEOF
protected boolean m_fEOFTrue after eof is determined. -
m_fDestructive
protected boolean m_fDestructiveTrue iff the array will be null'd out as it is traversed. -
m_aabArray
protected byte[][] m_aabArrayThe array of byte arrays. -
m_iArray
protected int m_iArrayThe index of the current byte array. -
m_ab
protected byte[] m_abThe current byte array. -
m_of
protected int m_ofThe current offset in the current byte array. -
m_iArrayMarked
protected int m_iArrayMarkedThe index of the marked byte array. -
m_ofMarked
protected int m_ofMarkedThe marked offset in the marked byte array.
-
-
Constructor Details
-
MultiByteArrayInputStream
public MultiByteArrayInputStream(byte[][] aab) Construct a MultiByteArrayInputStream.- Parameters:
aab- a non-null array of byte arrays of data to stream, each byte array must be non-null and non-zero-length
-
MultiByteArrayInputStream
public MultiByteArrayInputStream(byte[][] aab, boolean fDestructive) Construct a MultiByteArrayInputStream.- Parameters:
aab- a non-null array of byte arrays of data to stream, each byte array must be non-null and non-zero-lengthfDestructive- if true the supplied array will be cleared as it is traversed, stream mark positions will be respected
-
-
Method Details
-
read
Reads the next byte of data from the input stream. The value byte is returned as anintin the range0to255. If no byte is available because the end of the stream has been reached, the value-1is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.- Specified by:
readin interfacecom.oracle.coherence.common.io.InputStreaming- Specified by:
readin classInputStream- Returns:
- the next byte of data, or
-1if the end of the stream is reached. - Throws:
IOException- if an I/O error occurs.
-
read
Reads up tolenbytes of data from the input stream into an array of bytes. An attempt is made to read as many aslenbytes, but a smaller number may be read, possibly zero. The number of bytes actually read is returned as an integer.- Specified by:
readin interfacecom.oracle.coherence.common.io.InputStreaming- Overrides:
readin classInputStream- Parameters:
abDest- the buffer into which the data is readofDest- the start offset in arraybat which the data is writtencbDest- the maximum number of bytes to read- Returns:
- the total number of bytes read into the buffer, or
-1if there is no more data because the end of the stream has been reached. - Throws:
IOException- if an I/O error occurs
-
available
public int available()Returns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream. The next caller might be the same thread or or another thread.- Specified by:
availablein interfacecom.oracle.coherence.common.io.InputStreaming- Overrides:
availablein classInputStream- Returns:
- the number of bytes that can be read from this input stream without blocking.
-
skip
public long skip(long n) Skips over and discardsnbytes of data from this input stream. Theskipmethod may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly0. This may result from any of a number of conditions; reaching end of file beforenbytes have been skipped is only one possibility. The actual number of bytes skipped is returned. Ifnis negative, no bytes are skipped.- Specified by:
skipin interfacecom.oracle.coherence.common.io.InputStreaming- Overrides:
skipin classInputStream- Parameters:
n- the number of bytes to be skipped- Returns:
- the actual number of bytes skipped
-
close
public void close()Close the stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfacecom.oracle.coherence.common.io.InputStreaming- Overrides:
closein classInputStream
-
mark
public void mark(int readlimit) Marks the current position in this input stream. A subsequent call to theresetmethod repositions this stream at the last marked position so that subsequent reads re-read the same bytes.- Specified by:
markin interfacecom.oracle.coherence.common.io.InputStreaming- Overrides:
markin classInputStream- Parameters:
readlimit- the maximum limit of bytes that can be read before the mark position becomes invalid
-
reset
Repositions this stream to the position at the time themarkmethod was last called on this input stream.- Specified by:
resetin interfacecom.oracle.coherence.common.io.InputStreaming- Overrides:
resetin classInputStream- Throws:
IOException- if the stream has not been marked
-
markSupported
public boolean markSupported()Tests if this input stream supports themarkandresetmethods. ThemarkSupportedmethod ofInputStreamreturnsfalse.- Specified by:
markSupportedin interfacecom.oracle.coherence.common.io.InputStreaming- Overrides:
markSupportedin classInputStream- Returns:
trueif this true type supports the mark and reset method;falseotherwise
-