Class BytesInput

java.lang.Object
com.pnfsoftware.jeb.core.input.BytesInput
All Implemented Interfaces:
IInput

@Ser public class BytesInput extends Object implements IInput
An input object backed by an array of bytes.
  • Field Summary

    Fields inherited from interface com.pnfsoftware.jeb.core.input.IInput

    IDEAL_HEADER_SIZE
  • Constructor Summary

    Constructors
    Constructor
    Description
    BytesInput(byte[] data)
    Create an input object backing up the provided array of bytes.
    BytesInput(byte[] data, int offset, int length)
    Create an input object backing up the provided array of bytes.
    BytesInput(byte[] data, int offset, int length, String name)
    Create an input object backing up the provided array of bytes.
    BytesInput(IInput input, long offset, int length)
    Create an input object by reading the specified bytes of a source input.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Determine whether this input is readable.
    void
    Close that input and free all resources used by this object.
    Get a seekable read-only channel representing the input.
    long
    Provide the current input size of the input data.
    Get a read-only, big-endian buffer of the first input bytes.
    Retrieve the optional input name.
    Get the input stream.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BytesInput

      public BytesInput(byte[] data)
      Create an input object backing up the provided array of bytes.
      Parameters:
      data - non-null byte array
    • BytesInput

      public BytesInput(byte[] data, int offset, int length)
      Create an input object backing up the provided array of bytes.
      Parameters:
      data - non-null byte array
      offset - start offset in the array
      length - number of bytes to be backed
    • BytesInput

      public BytesInput(byte[] data, int offset, int length, String name)
      Create an input object backing up the provided array of bytes.
      Parameters:
      data - non-null byte array
      offset - start offset in the array
      length - number of bytes to be backed
      name - optional name
    • BytesInput

      public BytesInput(IInput input, long offset, int length) throws IOException
      Create an input object by reading the specified bytes of a source input.
      Parameters:
      input - a source input
      offset - offset in source
      length - size to read
      Throws:
      IOException
  • Method Details

    • getName

      public String getName()
      Description copied from interface: IInput
      Retrieve the optional input name.
      Specified by:
      getName in interface IInput
      Returns:
    • canRead

      public boolean canRead()
      Description copied from interface: IInput
      Determine whether this input is readable.
      Specified by:
      canRead in interface IInput
      Returns:
    • close

      public void close()
      Description copied from interface: IInput
      Close that input and free all resources used by this object.
      Specified by:
      close in interface IInput
    • getCurrentSize

      public long getCurrentSize()
      Description copied from interface: IInput
      Provide the current input size of the input data.
      Specified by:
      getCurrentSize in interface IInput
      Returns:
      the size, -1 if the size cannot be calculated or if an error occurred
    • getHeader

      public ByteBuffer getHeader()
      Description copied from interface: IInput
      Get a read-only, big-endian buffer of the first input bytes. Clients should not attempt to modify or directly access that buffer. The initial position is set to 0. It is recommended that implementations provide at least IInput.IDEAL_HEADER_SIZE bytes.
      Specified by:
      getHeader in interface IInput
      Returns:
      a unique buffer; on error, the returned buffer is null (unlike other methods declared in this interface, this method does not throw IOException)
    • getChannel

      public SeekableByteChannel getChannel()
      Description copied from interface: IInput
      Get a seekable read-only channel representing the input. Each call returns a unique channel. Clients should use this method to efficiently read at various locations within the given input.
      Specified by:
      getChannel in interface IInput
      Returns:
      a unique seekable channel
    • getStream

      public InputStream getStream()
      Description copied from interface: IInput
      Get the input stream. Each call returns a unique stream. Implementors should offer this method for convenience. The implementor is responsible for closing non-closed streams when IInput.close() is called.
      Specified by:
      getStream in interface IInput
      Returns:
      a unique input stream