org.apache.fontbox.cff

## 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.

Author:
  Villu Ruusmann

### Constructor Summary

Constructors
Constructor and Description
`DataInputByteArray(byte[] buffer)` Constructor.

### Method Summary

All Methods Instance Methods Concrete Methods
`int` `getPosition()` Returns the current position.
`boolean` `hasRemaining()` Determines if there are any bytes left to read or not.
`int` `length()`
`int` `peekUnsignedByte(int offset)` Peeks one single unsigned byte from the buffer.
`byte` `readByte()` Read one single byte from the buffer.
`byte[]` `readBytes(int length)` Read a number of single byte values from the buffer.
`int` `readUnsignedByte()` Read one single unsigned byte from the buffer.
`void` `setPosition(int position)` Sets the current position to the given value.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.apache.fontbox.cff.DataInput

`readInt, readOffset, readShort, readUnsignedShort`

### Constructor Detail

#### DataInputByteArray

    public DataInputByteArray(byte[] buffer)

Constructor.

Parameters:
  `buffer` - the buffer to be read

### Method Detail

#### 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`