Top Description Fields Constructors Methods
org.apache.poi.util

public Class LittleEndianInputStream

extends FilterInputStream
implements LittleEndianInput
Class Inheritance
All Implemented Interfaces
org.apache.poi.util.LittleEndianInput
Known Direct Subclasses
org.apache.poi.poifs.crypt.ChunkedCipherInputStream
Imports
java.io.BufferedInputStream, .FilterInputStream, .IOException, .InputStream

Wraps an InputStream providing LittleEndianInput

This class does not buffer any input, so the stream read position maintained by this class is consistent with that of the inner stream.

Field Summary

Modifier and TypeField and Description
private static final int
private static final int
private int
private int
Inherited from java.io.FilterInputStream:
in

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private int
_read(byte[] buffer, int offset, int length)

public int
available()

Overrides java.io.FilterInputStream.available.

Implements org.apache.poi.util.LittleEndianInput.available.

Returns an estimate of 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.

private static void
checkEOF(int actualBytes, int expectedBytes)

public int
public synchronized void
mark(int
the maximum limit of bytes that can be read before the mark position becomes invalid.
readlimit
)

Overrides java.io.FilterInputStream.mark.

Marks the current position in this input stream.

public int
read(byte[]
the buffer into which the data is read.
b
,
int
the start offset in array b at which the data is written.
off
,
int
the maximum number of bytes to read.
len
)

Overrides java.io.FilterInputStream.read.

Reads up to len bytes of data from this input stream into an array of bytes.

public byte
public double
public float

Returns:

the float (32-bit) value
readFloat
()

get a float value, reads it in little endian format then converts the resulting revolting IEEE 754 (curse them) floating point number to a happy java float

public void
public void
readFully(byte[] buf, int off, int len)

Implements org.apache.poi.util.LittleEndianInput.readFully.

public int
public long
public void
readPlain(byte[]
the byte array to receive the bytes
buf
,
int
the start offset into the byte array
off
,
int
the amount of bytes to fill
len
)

Implements org.apache.poi.util.LittleEndianInput.readPlain.

Usually acts the same as readFully(byte[], int, int), but for an encrypted stream the raw (unencrypted) data is filled

public short
public int
public long

Returns:

the unsigned int (32-bit) value
readUInt
()

get an unsigned int value from an InputStream

public int
public synchronized void
reset()

Overrides java.io.FilterInputStream.reset.

Repositions this stream to the position at the time the mark method was last called on this input stream.

public void
skipFully(int len)

Inherited from java.io.FilterInputStream:
closemarkSupportedreadreadskip

Field Detail

BUFFERED_SIZEback to summary
private static final int BUFFERED_SIZE
EOFback to summary
private static final int EOF
markIndexback to summary
private int markIndex
readIndexback to summary
private int readIndex

Constructor Detail

LittleEndianInputStreamback to summary
public LittleEndianInputStream(InputStream is)

Method Detail

_readback to summary
private int _read(byte[] buffer, int offset, int length) throws IOException
availableback to summary
public int available()

Overrides java.io.FilterInputStream.available.

Implements org.apache.poi.util.LittleEndianInput.available.

Doc from java.io.FilterInputStream.available.

Returns an estimate of 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 another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes.

Returns:int

an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking.

Annotations
@Override
@SuppressForbidden:just delegating
checkEOFback to summary
private static void checkEOF(int actualBytes, int expectedBytes)
getReadIndexback to summary
public int getReadIndex()
markback to summary
public synchronized void mark(int readlimit)

Overrides java.io.FilterInputStream.mark.

Doc from java.io.FilterInputStream.mark.

Marks the current position in this input stream. A subsequent call to the reset method repositions this stream at the last marked position so that subsequent reads re-read the same bytes.

The readlimit argument tells this input stream to allow that many bytes to be read before the mark position gets invalidated.

Parameters
readlimit:int

the maximum limit of bytes that can be read before the mark position becomes invalid.

Annotations
@Override
readback to summary
public int read(byte[] b, int off, int len) throws IOException

Overrides java.io.FilterInputStream.read.

Doc from java.io.FilterInputStream.read.

Reads up to len bytes of data from this input stream into an array of bytes. If len is not zero, the method blocks until some input is available; otherwise, no bytes are read and 0 is returned.

Parameters
b:byte[]

the buffer into which the data is read.

off:int

the start offset in array b at which the data is written.

len:int

the maximum number of bytes to read.

Returns:int

the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
readByteback to summary
public byte readByte()

Implements org.apache.poi.util.LittleEndianInput.readByte.

Annotations
@Override
readDoubleback to summary
public double readDouble()

Implements org.apache.poi.util.LittleEndianInput.readDouble.

Annotations
@Override
readFloatback to summary
public float readFloat()

get a float value, reads it in little endian format then converts the resulting revolting IEEE 754 (curse them) floating point number to a happy java float

Returns:float

the float (32-bit) value

readFullyback to summary
public void readFully(byte[] buf)

Implements org.apache.poi.util.LittleEndianInput.readFully.

Annotations
@Override
readFullyback to summary
public void readFully(byte[] buf, int off, int len)

Implements org.apache.poi.util.LittleEndianInput.readFully.

Annotations
@Override
readIntback to summary
public int readInt()

Implements org.apache.poi.util.LittleEndianInput.readInt.

Annotations
@Override
readLongback to summary
public long readLong()

Implements org.apache.poi.util.LittleEndianInput.readLong.

Annotations
@Override
readPlainback to summary
public void readPlain(byte[] buf, int off, int len)

Implements org.apache.poi.util.LittleEndianInput.readPlain.

Doc from org.apache.poi.util.LittleEndianInput.readPlain.

Usually acts the same as readFully(byte[], int, int), but for an encrypted stream the raw (unencrypted) data is filled

Parameters
buf:byte[]

the byte array to receive the bytes

off:int

the start offset into the byte array

len:int

the amount of bytes to fill

Annotations
@Override
readShortback to summary
public short readShort()

Implements org.apache.poi.util.LittleEndianInput.readShort.

Annotations
@Override
readUByteback to summary
public int readUByte()

Implements org.apache.poi.util.LittleEndianInput.readUByte.

Annotations
@Override
readUIntback to summary
public long readUInt()

get an unsigned int value from an InputStream

Returns:long

the unsigned int (32-bit) value

Exceptions
IllegalStateException:
wraps any IOException thrown from reading the stream.
readUShortback to summary
public int readUShort()

Implements org.apache.poi.util.LittleEndianInput.readUShort.

Annotations
@Override
resetback to summary
public synchronized void reset() throws IOException

Overrides java.io.FilterInputStream.reset.

Doc from java.io.FilterInputStream.reset.

Repositions this stream to the position at the time the mark method was last called on this input stream.

Stream marks are intended to be used in situations where you need to read ahead a little to see what's in the stream. Often this is most easily done by invoking some general parser. If the stream is of the type handled by the parse, it just chugs along happily. If the stream is not of that type, the parser should toss an exception when it fails. If this happens within readlimit bytes, it allows the outer code to reset the stream and try another parser.

Annotations
@Override
Exceptions
IOException:
if this stream has not been marked or if the mark has been invalidated.
skipFullyback to summary
public void skipFully(int len) throws IOException