Package org.apache.fontbox.ttf
Class RAFDataStream
java.lang.Object
org.apache.fontbox.ttf.TTFDataStream
org.apache.fontbox.ttf.RAFDataStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
An implementation of the TTFDataStream that goes against a RAF.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRAFDataStream
(File file, String mode) Constructor.RAFDataStream
(String name, String mode) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close the underlying resources.long
Get the current position in the stream.This will get the original data file that was used for this stream.long
This will get the original data size that was used for this stream.int
read()
Read an unsigned byte.int
read
(byte[] b, int off, int len) long
readLong()
Read a signed 64-bit integer.short
Read a signed short.int
Read an unsigned short.void
seek
(long pos) Seek into the datasource.Methods inherited from class org.apache.fontbox.ttf.TTFDataStream
read, read32Fixed, readInternationalDate, readSignedByte, readString, readString, readString, readTag, readUnsignedByte, readUnsignedByteArray, readUnsignedInt, readUnsignedShortArray
-
Field Details
-
raf
-
ttfFile
-
BUFFERSIZE
private static final int BUFFERSIZE- See Also:
-
-
Constructor Details
-
RAFDataStream
RAFDataStream(String name, String mode) throws IOException Constructor.- Parameters:
name
- The raf file.mode
- The mode to open the RAF.- Throws:
IOException
- If there is a problem creating the RAF.- See Also:
-
RAFDataStream
RAFDataStream(File file, String mode) throws IOException Constructor.- Parameters:
file
- The raf file.mode
- The mode to open the RAF.- Throws:
IOException
- If there is a problem creating the RAF.- See Also:
-
-
Method Details
-
readSignedShort
Read a signed short.- Specified by:
readSignedShort
in classTTFDataStream
- Returns:
- An signed short.
- Throws:
IOException
- If there is an error reading the data.- See Also:
-
getCurrentPosition
Get the current position in the stream.- Specified by:
getCurrentPosition
in classTTFDataStream
- Returns:
- The current position in the stream.
- Throws:
IOException
- If an error occurs while reading the stream.
-
close
Close the underlying resources.- Throws:
IOException
- If there is an error closing the resources.
-
read
Read an unsigned byte.- Specified by:
read
in classTTFDataStream
- Returns:
- An unsigned byte.
- Throws:
IOException
- If there is an error reading the data.- See Also:
-
readUnsignedShort
Read an unsigned short.- Specified by:
readUnsignedShort
in classTTFDataStream
- Returns:
- An unsigned short.
- Throws:
IOException
- If there is an error reading the data.- See Also:
-
readLong
Read a signed 64-bit integer.- Specified by:
readLong
in classTTFDataStream
- Returns:
- eight bytes interpreted as a long.
- Throws:
IOException
- If there is an error reading the data.- See Also:
-
seek
Seek into the datasource.- Specified by:
seek
in classTTFDataStream
- Parameters:
pos
- The position to seek to.- Throws:
IOException
- If there is an error seeking to that position.
-
read
- Specified by:
read
in classTTFDataStream
- 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:
-
getOriginalData
This will get the original data file that was used for this stream.- Specified by:
getOriginalData
in classTTFDataStream
- Returns:
- The data that was read from.
- Throws:
IOException
- If there is an issue reading the data.
-
getOriginalDataSize
public long getOriginalDataSize()This will get the original data size that was used for this stream.- Specified by:
getOriginalDataSize
in classTTFDataStream
- Returns:
- The size of the original data.
-