Class DataInputByteArray

java.lang.Object
org.apache.fontbox.cff.DataInputByteArray
All Implemented Interfaces:
DataInput

public class DataInputByteArray extends Object implements DataInput
This class implements the DataInput interface using a byte buffer as source.
  • Field Details

    • inputBuffer

      private final byte[] inputBuffer
    • bufferPosition

      private int bufferPosition
  • Constructor Details

    • DataInputByteArray

      public DataInputByteArray(byte[] buffer)
      Constructor.
      Parameters:
      buffer - the buffer to be read
  • Method Details

    • hasRemaining

      public boolean hasRemaining() throws IOException
      Determines if there are any bytes left to read or not.
      Specified by:
      hasRemaining in interface DataInput
      Returns:
      true if there are any bytes left to read
      Throws:
      IOException - if an error occurs during reading
    • getPosition

      public int getPosition()
      Returns the current position.
      Specified by:
      getPosition in interface DataInput
      Returns:
      current position
    • setPosition

      public void setPosition(int position) throws IOException
      Sets the current position to the given value.
      Specified by:
      setPosition in interface DataInput
      Parameters:
      position - the given position
      Throws:
      IOException - if the new position ist out of range
    • readByte

      public byte readByte() throws IOException
      Read one single byte from the buffer.
      Specified by:
      readByte in interface DataInput
      Returns:
      the byte
      Throws:
      IOException - if an error occurs during reading
    • readUnsignedByte

      public int readUnsignedByte() throws IOException
      Read one single unsigned byte from the buffer.
      Specified by:
      readUnsignedByte in interface DataInput
      Returns:
      the unsigned byte as int
      Throws:
      IOException - if an error occurs during reading
    • peekUnsignedByte

      public int peekUnsignedByte(int offset) throws IOException
      Peeks one single unsigned byte from the buffer.
      Specified by:
      peekUnsignedByte in interface DataInput
      Parameters:
      offset - offset to the byte to be peeked
      Returns:
      the unsigned byte as int
      Throws:
      IOException - if an error occurs during reading
    • readBytes

      public byte[] readBytes(int length) throws IOException
      Read a number of single byte values from the buffer.
      Specified by:
      readBytes in interface DataInput
      Parameters:
      length - the number of bytes to be read
      Returns:
      an array with containing the bytes from the buffer
      Throws:
      IOException - if an error occurs during reading
    • length

      public int length() throws IOException
      Specified by:
      length in interface DataInput
      Throws:
      IOException