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
public class RAFDataStream extends TTFDataStream
An implementation of the TTFDataStream that goes against a RAF.- Version:
- $Revision: 1.2 $
- Author:
- Ben Litchfield (ben@benlitchfield.com)
-
-
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 void
close()
Close the underlying resources.long
getCurrentPosition()
Get the current position in the stream.java.io.InputStream
getOriginalData()
This will get the original data file that was used for this stream.int
read()
Read an unsigned byte.int
read(byte[] b, int off, int len)
long
readLong()
Read an unsigned byte.short
readSignedShort()
Read an signed short.int
readUnsignedShort()
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, readUnsignedByte, readUnsignedByteArray, readUnsignedInt, readUnsignedShortArray
-
-
-
-
Constructor Detail
-
RAFDataStream
public RAFDataStream(java.lang.String name, java.lang.String mode) throws java.io.FileNotFoundException
Constructor.- Parameters:
name
- The raf file.mode
- The mode to open the RAF.- Throws:
java.io.FileNotFoundException
- If there is a problem creating the RAF.- See Also:
RandomAccessFile( String, String )
-
RAFDataStream
public RAFDataStream(java.io.File file, java.lang.String mode) throws java.io.FileNotFoundException
Constructor.- Parameters:
file
- The raf file.mode
- The mode to open the RAF.- Throws:
java.io.FileNotFoundException
- If there is a problem creating the RAF.- See Also:
RandomAccessFile( File, String )
-
-
Method Detail
-
readSignedShort
public short readSignedShort() throws java.io.IOException
Read an signed short.- Specified by:
readSignedShort
in classTTFDataStream
- Returns:
- An signed short.
- Throws:
java.io.IOException
- If there is an error reading the data.
-
getCurrentPosition
public long getCurrentPosition() throws java.io.IOException
Get the current position in the stream.- Specified by:
getCurrentPosition
in 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.IOException
Close the underlying resources.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in classTTFDataStream
- Throws:
java.io.IOException
- If there is an error closing the resources.
-
read
public int read() throws java.io.IOException
Read an unsigned byte.- Specified by:
read
in classTTFDataStream
- Returns:
- An unsigned byte.
- Throws:
java.io.IOException
- If there is an error reading the data.
-
readUnsignedShort
public int readUnsignedShort() throws java.io.IOException
Read an unsigned short.- Specified by:
readUnsignedShort
in classTTFDataStream
- Returns:
- An unsigned short.
- Throws:
java.io.IOException
- If there is an error reading the data.
-
readLong
public long readLong() throws java.io.IOException
Read an unsigned byte.- Specified by:
readLong
in classTTFDataStream
- Returns:
- An unsigned byte.
- Throws:
java.io.IOException
- If there is an error reading the data.
-
seek
public void seek(long pos) throws java.io.IOException
Seek into the datasource.- Specified by:
seek
in 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:
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:
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.IOException
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:
java.io.IOException
- If there is an issue reading the data.
-
-