org.apache.fontbox.cff

Class DataInput

public class DataInput extends Object

This class contains some functionality to read a byte buffer.

Version: $Revision$

Author: Villu Russmann

Constructor Summary
DataInput(byte[] buffer)
Constructor.
Method Summary
intgetPosition()
Returns the current position.
StringgetString()
Returns the buffer as an ISO-8859-1 string.
booleanhasRemaining()
Determines if there are any bytes left to read or not.
bytereadByte()
Read one single byte from the buffer.
byte[]readBytes(int length)
Read a number of single byte values from the buffer.
intreadInt()
Read one single int (4 bytes) from the buffer.
shortreadShort()
Read one single short value from the buffer.
intreadUnsignedByte()
Read one single unsigned byte from the buffer.
intreadUnsignedShort()
Read one single unsigned short (2 bytes) value from the buffer.
voidsetPosition(int position)
Sets the current position to the given value.

Constructor Detail

DataInput

public DataInput(byte[] buffer)
Constructor.

Parameters: buffer the buffer to be read

Method Detail

getPosition

public int getPosition()
Returns the current position.

Returns: current position

getString

public String getString()
Returns the buffer as an ISO-8859-1 string.

Returns: the buffer as string

Throws: IOException if an error occurs during reading

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

readByte

public byte readByte()
Read one single byte from the buffer.

Returns: the byte

Throws: IOException if an error occurs during reading

readBytes

public byte[] readBytes(int length)
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

readInt

public int readInt()
Read one single int (4 bytes) from the buffer.

Returns: the int value

Throws: IOException if an error occurs during reading

readShort

public short readShort()
Read one single short value from the buffer.

Returns: the short value

Throws: IOException if an error occurs during reading

readUnsignedByte

public int readUnsignedByte()
Read one single unsigned byte from the buffer.

Returns: the unsigned byte as int

Throws: IOException if an error occurs during reading

readUnsignedShort

public int 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

setPosition

public void setPosition(int position)
Sets the current position to the given value.

Parameters: position the given position

Copyright © 2008-2011 Apache Software Foundation. All Rights Reserved.