Top Description Inners Fields Constructors Methods
org.apache.fontbox.ttf

pack-priv Class RandomAccessReadUnbufferedDataStream

extends TTFDataStream
Class Inheritance
Imports
java.io.IOException, .InputStream, org.apache.pdfbox.io.RandomAccessRead, .RandomAccessReadView

In contrast to RandomAccessReadDataStream, this class doesn't pre-load RandomAccessRead into a byte[], it works with RandomAccessRead directly. Performance: it is much faster if most of the buffer is skipped, and slower if whole buffer is read()

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final long
private final RandomAccessRead

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements java.io.Closeable.close.

Close the underlying resources.

public RandomAccessRead
createSubView(long length)

Overrides org.apache.fontbox.ttf.TTFDataStream.createSubView.

Creates a view from current position to pos + length.

public long
getCurrentPosition()

Implements abstract org.apache.fontbox.ttf.TTFDataStream.getCurrentPosition.

Get the current position in the stream.

public InputStream
getOriginalData()

Implements abstract org.apache.fontbox.ttf.TTFDataStream.getOriginalData.

Lifetime of returned InputStream is bound by this lifetime, it won't close underlying RandomAccessRead.

public long
getOriginalDataSize()

Implements abstract org.apache.fontbox.ttf.TTFDataStream.getOriginalDataSize.

This will get the original data size that was used for this stream.

public int
read()

Implements abstract org.apache.fontbox.ttf.TTFDataStream.read.

Read an unsigned byte.

public int
read(byte[]
The buffer to write to.
b
,
int
The offset into the buffer.
off
,
int
The length into the buffer.
len
)

Implements abstract org.apache.fontbox.ttf.TTFDataStream.read.

private int
public final long
readLong()

Implements abstract org.apache.fontbox.ttf.TTFDataStream.readLong.

Read an unsigned byte.

public void
seek(long
The position to seek to.
pos
)

Implements abstract org.apache.fontbox.ttf.TTFDataStream.seek.

Seek into the datasource.

Inherited from org.apache.fontbox.ttf.TTFDataStream:
readread32FixedreadInternationalDatereadSignedBytereadSignedShortreadStringreadStringreadTagreadUnsignedBytereadUnsignedByteArrayreadUnsignedIntreadUnsignedShortreadUnsignedShortArray

Field Detail

lengthback to summary
private final long length
randomAccessReadback to summary
private final RandomAccessRead randomAccessRead

Constructor Detail

RandomAccessReadUnbufferedDataStreamback to summary
pack-priv RandomAccessReadUnbufferedDataStream(RandomAccessRead randomAccessRead) throws IOException
Exceptions
IOException:
If there is a problem reading the source length.

Method Detail

closeback to summary
public void close() throws IOException

Implements java.io.Closeable.close.

Close the underlying resources.

Annotations
@Override
Exceptions
IOException:
If there is an error closing the resources.
createSubViewback to summary
public RandomAccessRead createSubView(long length)

Overrides org.apache.fontbox.ttf.TTFDataStream.createSubView.

Doc from org.apache.fontbox.ttf.TTFDataStream.createSubView.

Creates a view from current position to pos + length. It can be faster than read(length) if you only need a few bytes. SubView.close() should never close TTFDataStream.this, only itself.

Returns:RandomAccessRead

A view or null (caller can use read instead). Please close() the result

Annotations
@Override
getCurrentPositionback to summary
public long getCurrentPosition() throws IOException

Implements abstract org.apache.fontbox.ttf.TTFDataStream.getCurrentPosition.

Doc from org.apache.fontbox.ttf.TTFDataStream.getCurrentPosition.

Get the current position in the stream.

Returns:long

The current position in the stream.

Annotations
@Override
Exceptions
IOException:
If an error occurs while reading the stream.
getOriginalDataback to summary
public InputStream getOriginalData() throws IOException

Implements abstract org.apache.fontbox.ttf.TTFDataStream.getOriginalData.

Doc from org.apache.fontbox.ttf.TTFDataStream.getOriginalData.

Lifetime of returned InputStream is bound by this lifetime, it won't close underlying RandomAccessRead. This will get the original data file that was used for this stream.

Returns:InputStream

The data that was read from.

Annotations
@Override
Exceptions
IOException:
If there is an issue reading the data.
getOriginalDataSizeback to summary
public long getOriginalDataSize()

Implements abstract org.apache.fontbox.ttf.TTFDataStream.getOriginalDataSize.

Doc from org.apache.fontbox.ttf.TTFDataStream.getOriginalDataSize.

This will get the original data size that was used for this stream.

Returns:long

The size of the original data.

Annotations
@Override
readback to summary
public int read() throws IOException

Implements abstract org.apache.fontbox.ttf.TTFDataStream.read.

Doc from org.apache.fontbox.ttf.TTFDataStream.read.

Read an unsigned byte.

Returns:int

An unsigned byte.

Annotations
@Override
Exceptions
IOException:
If there is an error reading the data.
readback to summary
public int read(byte[] b, int off, int len) throws IOException

Implements abstract org.apache.fontbox.ttf.TTFDataStream.read.

Parameters
b:byte[]

Doc from org.apache.fontbox.ttf.TTFDataStream.read.

The buffer to write to.

off:int

Doc from org.apache.fontbox.ttf.TTFDataStream.read.

The offset into the buffer.

len:int

Doc from org.apache.fontbox.ttf.TTFDataStream.read.

The length into the buffer.

Returns:int

Doc from org.apache.fontbox.ttf.TTFDataStream.read.

The number of bytes read, or -1 at the end of the stream

Annotations
@Override
Exceptions
IOException:

Doc from org.apache.fontbox.ttf.TTFDataStream.read.

If there is an error reading from the stream.

readIntback to summary
private int readInt() throws IOException
readLongback to summary
public final long readLong() throws IOException

Implements abstract org.apache.fontbox.ttf.TTFDataStream.readLong.

Doc from org.apache.fontbox.ttf.TTFDataStream.readLong.

Read an unsigned byte.

Returns:long

An unsigned byte.

Annotations
@Override
Exceptions
IOException:
If there is an error reading the data.
seekback to summary
public void seek(long pos) throws IOException

Implements abstract org.apache.fontbox.ttf.TTFDataStream.seek.

Doc from org.apache.fontbox.ttf.TTFDataStream.seek.

Seek into the datasource.

Parameters
pos:long

The position to seek to.

Annotations
@Override
Exceptions
IOException:
If there is an error seeking to that position.
org.apache.fontbox.ttf back to summary

private final Class RandomAccessReadUnbufferedDataStream.RandomAccessReadNonClosingInputStream

extends InputStream
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final RandomAccessReadView

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
close()

Overrides java.io.InputStream.close.

Implements java.io.Closeable.close.

Closes this input stream and releases any system resources associated with the stream.

public int
read()

Implements abstract java.io.InputStream.read.

Reads the next byte of data from the input stream.

public int
read(byte[]
the buffer into which the data is read.
b
)

Overrides java.io.InputStream.read.

Reads some number of bytes from the input stream and stores them into the buffer array b.

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.InputStream.read.

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

public long
skip(long
the number of bytes to be skipped.
n
)

Overrides java.io.InputStream.skip.

Skips over and discards n bytes of data from this input stream.

Inherited from java.io.InputStream:
availablemarkmarkSupportednullInputStreamreadAllBytesreadNBytesreadNBytesresetskipNBytestransferTo

Field Detail

randomAccessReadback to summary
private final RandomAccessReadView randomAccessRead

Constructor Detail

RandomAccessReadNonClosingInputStreamback to summary
public RandomAccessReadNonClosingInputStream(RandomAccessReadView randomAccessRead)

Method Detail

closeback to summary
public void close() throws IOException

Overrides java.io.InputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.InputStream.close.

Closes this input stream and releases any system resources associated with the stream.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
readback to summary
public int read() throws IOException

Implements abstract java.io.InputStream.read.

Doc from java.io.InputStream.read.

Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

Returns:int

the next byte of data, or -1 if the end of the stream is reached.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
readback to summary
public int read(byte[] b) throws IOException

Overrides java.io.InputStream.read.

Doc from java.io.InputStream.read.

Reads some number of bytes from the input stream and stores them into the buffer array b. The number of bytes actually read is returned as an integer. This method blocks until input data is available, end of file is detected, or an exception is thrown.

If the length of b is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at the end of the file, the value -1 is returned; otherwise, at least one byte is read and stored into b.

The first byte read is stored into element b[0], the next one into b[1], and so on. The number of bytes read is, at most, equal to the length of b. Let k be the number of bytes actually read; these bytes will be stored in elements b[0] through b[k-1], leaving elements b[k] through b[b.length-1] unaffected.

Parameters
b:byte[]

the buffer into which the data is 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 the first byte cannot be read for any reason other than the end of the file, if the input stream has been closed, or if some other I/O error occurs.
readback to summary
public int read(byte[] b, int off, int len) throws IOException

Overrides java.io.InputStream.read.

Doc from java.io.InputStream.read.

Reads up to len bytes of data from the input stream into an array of bytes. An attempt is made to read as many as len bytes, but a smaller number may be read. The number of bytes actually read is returned as an integer.

This method blocks until input data is available, end of file is detected, or an exception is thrown.

If len is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at end of file, the value -1 is returned; otherwise, at least one byte is read and stored into b.

The first byte read is stored into element b[off], the next one into b[off+1], and so on. The number of bytes read is, at most, equal to len. Let k be the number of bytes actually read; these bytes will be stored in elements b[off] through b[off+k-1], leaving elements b[off+k] through b[off+len-1] unaffected.

In every case, elements b[0] through b[off-1] and elements b[off+len] through b[b.length-1] are unaffected.

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 the first byte cannot be read for any reason other than end of file, or if the input stream has been closed, or if some other I/O error occurs.
skipback to summary
public long skip(long n) throws IOException

Overrides java.io.InputStream.skip.

Doc from java.io.InputStream.skip.

Skips over and discards n bytes of data from this input stream. The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. This may result from any of a number of conditions; reaching end of file before n bytes have been skipped is only one possibility. The actual number of bytes skipped is returned. If n is negative, the skip method for class InputStream always returns 0, and no bytes are skipped. Subclasses may handle the negative value differently.

Parameters
n:long

the number of bytes to be skipped.

Returns:long

the actual number of bytes skipped which might be zero.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.