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

pack-priv Class RandomAccessReadDataStream

extends TTFDataStream
Class Inheritance
Imports
java.io.ByteArrayInputStream, .IOException, .InputStream, org.apache.commons.logging.Log, .LogFactory, org.apache.pdfbox.io.IOUtils, .RandomAccessRead, .RandomAccessReadBuffer

An implementation of the TTFDataStream using RandomAccessRead as source. The underlying RandomAccessRead can be any length, but this implementation supports only bufferLengths upto Integer.MAX_VALUE.

Field Summary

Modifier and TypeField and Description
private int
private final byte[]
private final long
private static final Log

Constructor Summary

AccessConstructor and Description
pack-priv
RandomAccessReadDataStream(RandomAccessRead
source to be read from. Caller should close it.
randomAccessRead
)

Constructor.

pack-priv
RandomAccessReadDataStream(InputStream
source to be read from. Caller should close it.
inputStream
)

Constructor.

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

Returns:

The current position in the stream.
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.

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

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

Returns:

An unsigned byte, or -1, signalling 'no more data'
read
()

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

Read an unsigned byte.

public int

Returns:

The number of bytes read or -1, signalling 'no more data'
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

Returns:

4 bytes interpreted as an int.
readInt
()

Read a signed 32-bit integer.

public final long

Returns:

eight bytes interpreted as a long.
readLong
()

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

Read a signed 64-bit integer.

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

currentPositionback to summary
private int currentPosition
databack to summary
private final byte[] data
lengthback to summary
private final long length
LOGback to summary
private static final Log LOG

Constructor Detail

RandomAccessReadDataStreamback to summary
pack-priv RandomAccessReadDataStream(RandomAccessRead randomAccessRead) throws IOException

Constructor.

Parameters
randomAccessRead:RandomAccessRead

source to be read from. Caller should close it.

Exceptions
IOException:
If there is a problem reading the source data.
RandomAccessReadDataStreamback to summary
pack-priv RandomAccessReadDataStream(InputStream inputStream) throws IOException

Constructor.

Parameters
inputStream:InputStream

source to be read from. Caller should close it.

Exceptions
IOException:
If there is a problem reading the source data.

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.

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.

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.

Read an unsigned byte.

Returns:int

An unsigned byte, or -1, signalling 'no more data'

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[]

The buffer to write to.

off:int

The offset into the buffer.

len:int

The length into the buffer.

Returns:int

The number of bytes read or -1, signalling 'no more data'

Annotations
@Override
Exceptions
IOException:
If there is an error reading from the stream.
See Also
java.io.InputStream#read(byte[], int, int)
readIntback to summary
private int readInt() throws IOException

Read a signed 32-bit integer.

Returns:int

4 bytes interpreted as an int.

Exceptions
IOException:
If there is an error reading the data.
readLongback to summary
public final long readLong() throws IOException

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

Read a signed 64-bit integer.

Returns:long

eight bytes interpreted as a long.

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.

Seek into the datasource. When the requested pos is < 0, an IOException() is fired. When the requested pos is ≥ length, the currentPosition is set to the first byte after the data!

Parameters
pos:long

The position to seek to.

Annotations
@Override
Exceptions
IOException:
If there is an error seeking to that position.