Package org.apache.fontbox.ttf
Class RAFDataStream
- java.lang.Object
-
- org.apache.fontbox.ttf.TTFDataStream
-
- org.apache.fontbox.ttf.RAFDataStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
class RAFDataStream extends TTFDataStream
An implementation of the TTFDataStream that goes against a RAF.
-
-
Field Summary
Fields Modifier and Type Field Description private static intBUFFERSIZEprivate java.io.RandomAccessFilerafprivate java.io.FilettfFile
-
Constructor Summary
Constructors Constructor Description RAFDataStream(java.io.File file, java.lang.String mode)Constructor.RAFDataStream(java.lang.String name, java.lang.String mode)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the underlying resources.longgetCurrentPosition()Get the current position in the stream.java.io.InputStreamgetOriginalData()This will get the original data file that was used for this stream.longgetOriginalDataSize()This will get the original data size that was used for this stream.intread()Read an unsigned byte.intread(byte[] b, int off, int len)longreadLong()Read a signed 64-bit integer.shortreadSignedShort()Read a signed short.intreadUnsignedShort()Read an unsigned short.voidseek(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 Detail
-
raf
private java.io.RandomAccessFile raf
-
ttfFile
private java.io.File ttfFile
-
BUFFERSIZE
private static final int BUFFERSIZE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RAFDataStream
RAFDataStream(java.lang.String name, java.lang.String mode) throws java.io.IOExceptionConstructor.- Parameters:
name- The raf file.mode- The mode to open the RAF.- Throws:
java.io.IOException- If there is a problem creating the RAF.- See Also:
RandomAccessFile( String, String )
-
RAFDataStream
RAFDataStream(java.io.File file, java.lang.String mode) throws java.io.IOExceptionConstructor.- Parameters:
file- The raf file.mode- The mode to open the RAF.- Throws:
java.io.IOException- If there is a problem creating the RAF.- See Also:
RandomAccessFile( File, String )
-
-
Method Detail
-
readSignedShort
public short readSignedShort() throws java.io.IOExceptionRead a signed short.- Specified by:
readSignedShortin classTTFDataStream- Returns:
- An signed short.
- Throws:
java.io.IOException- If there is an error reading the data.- See Also:
RandomAccessFile.readShort()
-
getCurrentPosition
public long getCurrentPosition() throws java.io.IOExceptionGet the current position in the stream.- Specified by:
getCurrentPositionin classTTFDataStream- Returns:
- The current position in the stream.
- Throws:
java.io.IOException- If an error occurs while reading the stream.
-
close
public void close() throws java.io.IOExceptionClose the underlying resources.- Throws:
java.io.IOException- If there is an error closing the resources.
-
read
public int read() throws java.io.IOExceptionRead an unsigned byte.- Specified by:
readin classTTFDataStream- Returns:
- An unsigned byte.
- Throws:
java.io.IOException- If there is an error reading the data.- See Also:
RandomAccessFile.read()
-
readUnsignedShort
public int readUnsignedShort() throws java.io.IOExceptionRead an unsigned short.- Specified by:
readUnsignedShortin classTTFDataStream- Returns:
- An unsigned short.
- Throws:
java.io.IOException- If there is an error reading the data.- See Also:
RandomAccessFile.readUnsignedShort()
-
readLong
public long readLong() throws java.io.IOExceptionRead a signed 64-bit integer.- Specified by:
readLongin classTTFDataStream- Returns:
- eight bytes interpreted as a long.
- Throws:
java.io.IOException- If there is an error reading the data.- See Also:
RandomAccessFile.readLong()
-
seek
public void seek(long pos) throws java.io.IOExceptionSeek into the datasource.- Specified by:
seekin classTTFDataStream- Parameters:
pos- The position to seek to.- Throws:
java.io.IOException- If there is an error seeking to that position.
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException- Specified by:
readin 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:
java.io.IOException- If there is an error reading from the stream.- See Also:
InputStream.read( byte[], int, int )
-
getOriginalData
public java.io.InputStream getOriginalData() throws java.io.IOExceptionThis will get the original data file that was used for this stream.- Specified by:
getOriginalDatain classTTFDataStream- Returns:
- The data that was read from.
- Throws:
java.io.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:
getOriginalDataSizein classTTFDataStream- Returns:
- The size of the original data.
-
-