org.apache.fontbox.ttf

Class TTFDataStream

public abstract class TTFDataStream extends Object

An interface into a data stream.

Version: $Revision: 1.1 $

Author: Ben Litchfield (ben@benlitchfield.com)

Method Summary
abstract voidclose()
Close the underlying resources.
abstract longgetCurrentPosition()
Get the current position in the stream.
abstract InputStreamgetOriginalData()
This will get the original data file that was used for this stream.
abstract intread()
Read an unsigned byte.
byte[]read(int numberOfBytes)
Read a specific number of bytes from the stream.
abstract intread(byte[] b, int off, int len)
floatread32Fixed()
Read a 16.16 fixed value, where the first 16 bits are the decimal and the last 16 bits are the fraction.
CalendarreadInternationalDate()
Read an eight byte international date.
abstract longreadLong()
Read an unsigned byte.
intreadSignedByte()
Read a signed byte.
abstract shortreadSignedShort()
Read an signed short.
StringreadString(int length)
Read a fixed length ascii string.
StringreadString(int length, String charset)
Read a fixed length ascii string.
longreadUnsignedInt()
Read an unsigned integer.
abstract intreadUnsignedShort()
Read an unsigned short.
int[]readUnsignedShortArray(int length)
Read an unsigned short array.
abstract voidseek(long pos)
Seek into the datasource.

Method Detail

close

public abstract void close()
Close the underlying resources.

Throws: IOException If there is an error closing the resources.

getCurrentPosition

public abstract long getCurrentPosition()
Get the current position in the stream.

Returns: The current position in the stream.

Throws: IOException If an error occurs while reading the stream.

getOriginalData

public abstract InputStream getOriginalData()
This will get the original data file that was used for this stream.

Returns: The data that was read from.

Throws: IOException If there is an issue reading the data.

read

public abstract int read()
Read an unsigned byte.

Returns: An unsigned byte.

Throws: IOException If there is an error reading the data.

read

public byte[] read(int numberOfBytes)
Read a specific number of bytes from the stream.

Parameters: numberOfBytes The number of bytes to read.

Returns: The byte buffer.

Throws: IOException If there is an error while reading.

read

public abstract int read(byte[] b, int off, int len)

Parameters: b The buffer to write to. off The offset into the buffer. len The length into the buffer.

Returns: The number of bytes read.

Throws: IOException If there is an error reading from the stream.

See Also: java.io.InputStream#read( byte[], int, int )

read32Fixed

public float read32Fixed()
Read a 16.16 fixed value, where the first 16 bits are the decimal and the last 16 bits are the fraction.

Returns: A 32 bit value.

Throws: IOException If there is an error reading the data.

readInternationalDate

public Calendar readInternationalDate()
Read an eight byte international date.

Returns: An signed short.

Throws: IOException If there is an error reading the data.

readLong

public abstract long readLong()
Read an unsigned byte.

Returns: An unsigned byte.

Throws: IOException If there is an error reading the data.

readSignedByte

public int readSignedByte()
Read a signed byte.

Returns: A signed byte.

Throws: IOException If there is an error reading the data.

readSignedShort

public abstract short readSignedShort()
Read an signed short.

Returns: An signed short.

Throws: IOException If there is an error reading the data.

readString

public String readString(int length)
Read a fixed length ascii string.

Parameters: length The length of the string to read.

Returns: A string of the desired length.

Throws: IOException If there is an error reading the data.

readString

public String readString(int length, String charset)
Read a fixed length ascii string.

Parameters: length The length of the string to read in bytes. charset The expected character set of the string.

Returns: A string of the desired length.

Throws: IOException If there is an error reading the data.

readUnsignedInt

public long readUnsignedInt()
Read an unsigned integer.

Returns: An unsiged integer.

Throws: IOException If there is an error reading the data.

readUnsignedShort

public abstract int readUnsignedShort()
Read an unsigned short.

Returns: An unsigned short.

Throws: IOException If there is an error reading the data.

readUnsignedShortArray

public int[] readUnsignedShortArray(int length)
Read an unsigned short array.

Parameters: length The length of the array to read.

Returns: An unsigned short array.

Throws: IOException If there is an error reading the data.

seek

public abstract void seek(long pos)
Seek into the datasource.

Parameters: pos The position to seek to.

Throws: IOException If there is an error seeking to that position.

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