Package org.apache.fontbox.cff
Class DataInput
java.lang.Object
org.apache.fontbox.cff.DataInput
- Direct Known Subclasses:
CFFDataInput
This class contains some functionality to read a byte buffer.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
Returns the current position.Returns the buffer as an ISO-8859-1 string.boolean
Determines if there are any bytes left to read or not.int
length()
private int
peek
(int offset) int
peekUnsignedByte
(int offset) Peeks one single unsigned byte from the buffer.private int
read()
byte
readByte()
Read one single byte from the buffer.byte[]
readBytes
(int length) Read a number of single byte values from the buffer.int
readInt()
Read one single int (4 bytes) from the buffer.short
Read one single short value from the buffer.int
Read one single unsigned byte from the buffer.int
Read one single unsigned short (2 bytes) value from the buffer.void
setPosition
(int position) Sets the current position to the given value.
-
Field Details
-
inputBuffer
private final byte[] inputBuffer -
bufferPosition
private int bufferPosition
-
-
Constructor Details
-
DataInput
public DataInput(byte[] buffer) Constructor.- Parameters:
buffer
- the buffer to be read
-
-
Method Details
-
hasRemaining
public boolean hasRemaining()Determines if there are any bytes left to read or not.- Returns:
- true if there are any bytes left to read
-
getPosition
public int getPosition()Returns the current position.- Returns:
- current position
-
setPosition
public void setPosition(int position) Sets the current position to the given value.- Parameters:
position
- the given position
-
getString
Returns the buffer as an ISO-8859-1 string.- Returns:
- the buffer as string
- Throws:
IOException
- if an error occurs during reading
-
readByte
Read one single byte from the buffer.- Returns:
- the byte
- Throws:
IOException
- if an error occurs during reading
-
readUnsignedByte
Read one single unsigned byte from the buffer.- Returns:
- the unsigned byte as int
- Throws:
IOException
- if an error occurs during reading
-
peekUnsignedByte
Peeks one single unsigned byte from the buffer.- Returns:
- the unsigned byte as int
- Throws:
IOException
- if an error occurs during reading
-
readShort
Read one single short value from the buffer.- Returns:
- the short value
- Throws:
IOException
- if an error occurs during reading
-
readUnsignedShort
Read one single unsigned short (2 bytes) value from the buffer.- Returns:
- the unsigned short value as int
- Throws:
IOException
- if an error occurs during reading
-
readInt
Read one single int (4 bytes) from the buffer.- Returns:
- the int value
- Throws:
IOException
- if an error occurs during reading
-
readBytes
Read a number of single byte values from the buffer.- Parameters:
length
- the number of bytes to be read- Returns:
- an array with containing the bytes from the buffer
- Throws:
IOException
- if an error occurs during reading
-
read
private int read() -
peek
private int peek(int offset) -
length
public int length()
-