Class BinaryImpl

  • All Implemented Interfaces:
    Binary

    public class BinaryImpl
    extends Object
    implements Binary
    BinaryImpl implements the Binary interface.
    • Constructor Summary

      Constructors 
      Constructor Description
      BinaryImpl​(byte[] buffer)
      Creates a new BinaryImpl instance from a byte[] array.
      BinaryImpl​(InputStream in)
      Creates a new BinaryImpl instance from an InputStream.
    • Constructor Detail

      • BinaryImpl

        public BinaryImpl​(InputStream in)
                   throws IOException
        Creates a new BinaryImpl instance from an InputStream. The contents of the stream is spooled to a temporary file or to a byte buffer if its size is smaller than MAX_BUFFER_SIZE.

        Parameters:
        in - stream to be represented as a BLOBFileValue instance
        Throws:
        IOException - if an error occurs while reading from the stream or writing to the temporary file
      • BinaryImpl

        public BinaryImpl​(byte[] buffer)
        Creates a new BinaryImpl instance from a byte[] array.
        Parameters:
        buffer - byte array to be represented as a BinaryImpl instance
    • Method Detail

      • read

        public int read​(byte[] b,
                        long position)
                 throws IOException,
                        RepositoryException
        Reads successive bytes from the specified position in this Binary into the passed byte array until either the byte array is full or the end of the Binary is encountered.

        If Binary.dispose() has been called on this Binary object, then this method will throw the runtime exception IllegalStateException.

        Specified by:
        read in interface Binary
        Parameters:
        b - the buffer into which the data is read.
        position - the position in this Binary from which to start reading bytes.
        Returns:
        the number of bytes read into the buffer, or -1 if there is no more data because the end of the Binary has been reached.
        Throws:
        IOException - if an I/O error occurs.
        RepositoryException - if another error occurs.
      • dispose

        public void dispose()
        Releases all resources associated with this Binary object and informs the repository that these resources may now be reclaimed. An application should call this method when it is finished with the Binary object.
        Specified by:
        dispose in interface Binary