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

public Class DataInputRandomAccessRead

extends Object
implements DataInput
Class Inheritance
All Implemented Interfaces
org.apache.fontbox.cff.DataInput
Imports
java.io.IOException, org.apache.pdfbox.io.RandomAccessRead

This class implements the DataInput interface using a RandomAccessRead as source.

Note

things can get hairy when the underlying buffer is larger than Integer#MAX_VALUE. Straight forward reading may work, but getPosition() and setPosition(int) may have problems.

Field Summary

Modifier and TypeField and Description
private final RandomAccessRead

Constructor Summary

AccessConstructor and Description
public
DataInputRandomAccessRead(RandomAccessRead
the source to be read from
randomAccessRead
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

current position.
getPosition
()

Implements org.apache.fontbox.cff.DataInput.getPosition.

Returns the current position.

public boolean

Returns:

true if there are any bytes left to read.
hasRemaining
()

Implements org.apache.fontbox.cff.DataInput.hasRemaining.

Determines if there are any bytes left to read or not.

public int
public int

Returns:

the unsigned byte as int.
peekUnsignedByte
(int
offset to the byte to be peeked, must be 0 ≤ offset.
offset
)

Implements org.apache.fontbox.cff.DataInput.peekUnsignedByte.

Peeks one single unsigned byte from the buffer.

public byte

Returns:

the byte.
readByte
()

Implements org.apache.fontbox.cff.DataInput.readByte.

Read one single byte from the buffer.

public byte[]

Returns:

an array with containing the bytes from the buffer.
readBytes
(int
the number of bytes to be read, must be 0 ≤ length.
length
)

Implements org.apache.fontbox.cff.DataInput.readBytes.

Read a number of single byte values from the buffer.

public int

Returns:

the unsigned byte as int.
readUnsignedByte
()

Implements org.apache.fontbox.cff.DataInput.readUnsignedByte.

Read one single unsigned byte from the buffer.

public void
setPosition(int
the given position, must be 0 ≤ position < length.
position
)

Implements org.apache.fontbox.cff.DataInput.setPosition.

Sets the current absolute position to the given value.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

randomAccessReadback to summary
private final RandomAccessRead randomAccessRead

Constructor Detail

DataInputRandomAccessReadback to summary
public DataInputRandomAccessRead(RandomAccessRead randomAccessRead)

Constructor.

Parameters
randomAccessRead:RandomAccessRead

the source to be read from

Method Detail

getPositionback to summary
public int getPosition() throws IOException

Implements org.apache.fontbox.cff.DataInput.getPosition.

Returns the current position.

Returns:int

current position.

Annotations
@Override
Exceptions
IOException:
when the underlying buffer has already been closed.
hasRemainingback to summary
public boolean hasRemaining() throws IOException

Implements org.apache.fontbox.cff.DataInput.hasRemaining.

Determines if there are any bytes left to read or not.

Returns:boolean

true if there are any bytes left to read.

Annotations
@Override
Exceptions
IOException:
when the underlying buffer has already been closed.
lengthback to summary
public int length() throws IOException

Implements org.apache.fontbox.cff.DataInput.length.

Annotations
@Override
peekUnsignedByteback to summary
public int peekUnsignedByte(int offset) throws IOException

Implements org.apache.fontbox.cff.DataInput.peekUnsignedByte.

Peeks one single unsigned byte from the buffer.

Parameters
offset:int

offset to the byte to be peeked, must be 0 ≤ offset.

Returns:int

the unsigned byte as int.

Annotations
@Override
Exceptions
IOException:
when the offset is negative or beyond end_of_buffer or when the underlying buffer has been closed already.
readByteback to summary
public byte readByte() throws IOException

Implements org.apache.fontbox.cff.DataInput.readByte.

Read one single byte from the buffer.

Returns:byte

the byte.

Annotations
@Override
Exceptions
IOException:
when there are no bytes to reador when the underlying buffer has already been closed.
readBytesback to summary
public byte[] readBytes(int length) throws IOException

Implements org.apache.fontbox.cff.DataInput.readBytes.

Read a number of single byte values from the buffer.

Note

when readBytes(5) is called, but there are only 3 bytes available, the caller gets an IOException, not the 3 bytes!

Parameters
length:int

the number of bytes to be read, must be 0 ≤ length.

Returns:byte[]

an array with containing the bytes from the buffer.

Annotations
@Override
Exceptions
IOException:
when there are less than length bytes available or when the underlying buffer has already been closed.
readUnsignedByteback to summary
public int readUnsignedByte() throws IOException

Implements org.apache.fontbox.cff.DataInput.readUnsignedByte.

Read one single unsigned byte from the buffer.

Returns:int

the unsigned byte as int.

Annotations
@Override
Exceptions
IOException:
when there are no bytes to read or when the underlying buffer has already been closed.
setPositionback to summary
public void setPosition(int position) throws IOException

Implements org.apache.fontbox.cff.DataInput.setPosition.

Sets the current absolute position to the given value. You cannot use setPosition(-20) to move 20 bytes back!

Parameters
position:int

the given position, must be 0 ≤ position < length.

Annotations
@Override
Exceptions
IOException:
if the new position is out of rangeor when the underlying buffer has already been closed.