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

pack-priv abstract Class TTFDataStream

extends Object
implements Closeable
Class Inheritance
All Implemented Interfaces
java.io.Closeable, java.lang.AutoCloseable
Known Direct Subclasses
org.apache.fontbox.ttf.RandomAccessReadDataStream, org.apache.fontbox.ttf.RandomAccessReadUnbufferedDataStream, org.apache.fontbox.ttf.TTCDataStream
Imports
java.io.Closeable, .EOFException, .IOException, .InputStream, java.nio.charset.Charset, .StandardCharsets, java.util.Calendar, .TimeZone, org.apache.pdfbox.io.RandomAccessRead

An abstract class to read a data stream.
Author
Ben Litchfield

Field Summary

Modifier and TypeField and Description
private static final TimeZone

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public RandomAccessRead

Returns:

A view or null (caller can use read instead). Please close() the result
createSubView
(long length)

Creates a view from current position to pos + length.

public abstract long

Returns:

The current position in the stream.
getCurrentPosition
()

Get the current position in the stream.

public abstract InputStream

Returns:

The data that was read from.
getOriginalData
()

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

public abstract long

Returns:

The size of the original data.
getOriginalDataSize
()

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

public abstract int

Returns:

An unsigned byte.
read
()

Read an unsigned byte.

public byte[]

Returns:

The byte buffer.
read
(int
The number of bytes to read.
numberOfBytes
)

Read a specific number of bytes from the stream.

public abstract int

Returns:

The number of bytes read, or -1 at the end of the stream
read
(byte[]
The buffer to write to.
b
,
int
The offset into the buffer.
off
,
int
The length into the buffer.
len
)

public float

Returns:

A 32 bit value.
read32Fixed
()

Read a 16.16 fixed value, where the first 16 bits are the decimal and the last 16 bits are the fraction.

public Calendar

Returns:

A signed short.
readInternationalDate
()

Read an eight byte international date.

public abstract long

Returns:

An unsigned byte.
readLong
()

Read an unsigned byte.

public int

Returns:

A signed byte.
readSignedByte
()

Read a signed byte.

public short

Returns:

A signed short.
readSignedShort
()

Read a signed short.

public String

Returns:

A string of the desired length.
readString
(int
The length of the string to read.
length
)

Read a fixed length ascii string.

public String

Returns:

A string of the desired length.
readString
(int
The length of the string to read in bytes.
length
,
Charset
The expected character set of the string.
charset
)

Read a fixed length string.

public String
readTag()

Reads a tag, an array of four uint8s used to identify a script, language system, feature, or baseline.

public int

Returns:

An unsigned byte.
readUnsignedByte
()

Read an unsigned byte.

public int[]

Returns:

An unsigned byte array.
readUnsignedByteArray
(int
the length of the array to be read
length
)

Read an unsigned byte array.

public long

Returns:

An unsigned integer.
readUnsignedInt
()

Read an unsigned integer.

public int

Returns:

An unsigned short.
readUnsignedShort
()

Read an unsigned short.

public int[]

Returns:

An unsigned short array.
readUnsignedShortArray
(int
The length of the array to read.
length
)

Read an unsigned short array.

public abstract void
seek(long
The position to seek to.
pos
)

Seek into the datasource.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

TIMEZONE_UTCback to summary
private static final TimeZone TIMEZONE_UTC

Constructor Detail

TTFDataStreamback to summary
pack-priv TTFDataStream()

Method Detail

createSubViewback to summary
public RandomAccessRead createSubView(long length)

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

getCurrentPositionback to summary
public abstract long getCurrentPosition() throws IOException

Get the current position in the stream.

Returns:long

The current position in the stream.

Exceptions
IOException:
If an error occurs while reading the stream.
getOriginalDataback to summary
public abstract InputStream getOriginalData() throws IOException

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

Returns:InputStream

The data that was read from.

Exceptions
IOException:
If there is an issue reading the data.
getOriginalDataSizeback to summary
public abstract long getOriginalDataSize()

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

Returns:long

The size of the original data.

readback to summary
public abstract int read() throws IOException

Read an unsigned byte.

Returns:int

An unsigned byte.

Exceptions
IOException:
If there is an error reading the data.
readback to summary
public byte[] read(int numberOfBytes) throws IOException

Read a specific number of bytes from the stream.

Parameters
numberOfBytes:int

The number of bytes to read.

Returns:byte[]

The byte buffer.

Exceptions
IOException:
If there is an error while reading.
readback to summary
public abstract int read(byte[] b, int off, int len) throws IOException
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 at the end of the stream

Exceptions
IOException:
If there is an error reading from the stream.
See Also
java.io.InputStream#read(byte[], int, int)
read32Fixedback to summary
public float read32Fixed() throws IOException

Read a 16.16 fixed value, where the first 16 bits are the decimal and the last 16 bits are the fraction.

Returns:float

A 32 bit value.

Exceptions
IOException:
If there is an error reading the data.
readInternationalDateback to summary
public Calendar readInternationalDate() throws IOException

Read an eight byte international date.

Returns:Calendar

A signed short.

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

Read an unsigned byte.

Returns:long

An unsigned byte.

Exceptions
IOException:
If there is an error reading the data.
readSignedByteback to summary
public int readSignedByte() throws IOException

Read a signed byte.

Returns:int

A signed byte.

Exceptions
IOException:
If there is an error reading the data.
readSignedShortback to summary
public short readSignedShort() throws IOException

Read a signed short.

Returns:short

A signed short.

Exceptions
IOException:
If there is an error reading the data.
readStringback to summary
public String readString(int length) throws IOException

Read a fixed length ascii string.

Parameters
length:int

The length of the string to read.

Returns:String

A string of the desired length.

Exceptions
IOException:
If there is an error reading the data.
readStringback to summary
public String readString(int length, Charset charset) throws IOException

Read a fixed length string.

Parameters
length:int

The length of the string to read in bytes.

charset:Charset

The expected character set of the string.

Returns:String

A string of the desired length.

Exceptions
IOException:
If there is an error reading the data.
readTagback to summary
public String readTag() throws IOException

Reads a tag, an array of four uint8s used to identify a script, language system, feature, or baseline.

readUnsignedByteback to summary
public int readUnsignedByte() throws IOException

Read an unsigned byte. Similar to read(), but throws an exception if EOF is unexpectedly reached.

Returns:int

An unsigned byte.

Exceptions
IOException:
If there is an error reading the data.
readUnsignedByteArrayback to summary
public int[] readUnsignedByteArray(int length) throws IOException

Read an unsigned byte array.

Parameters
length:int

the length of the array to be read

Returns:int[]

An unsigned byte array.

Exceptions
IOException:
If there is an error reading the data.
readUnsignedIntback to summary
public long readUnsignedInt() throws IOException

Read an unsigned integer.

Returns:long

An unsigned integer.

Exceptions
IOException:
If there is an error reading the data.
readUnsignedShortback to summary
public int readUnsignedShort() throws IOException

Read an unsigned short.

Returns:int

An unsigned short.

Exceptions
IOException:
If there is an error reading the data.
readUnsignedShortArrayback to summary
public int[] readUnsignedShortArray(int length) throws IOException

Read an unsigned short array.

Parameters
length:int

The length of the array to read.

Returns:int[]

An unsigned short array.

Exceptions
IOException:
If there is an error reading the data.
seekback to summary
public abstract void seek(long pos) throws IOException

Seek into the datasource.

Parameters
pos:long

The position to seek to.

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