Interface BinaryData

  • All Known Subinterfaces:
    EditableBinaryData
    All Known Implementing Classes:
    ByteArrayData, ByteArrayEditableData, PagedData

    @ParametersAreNonnullByDefault
    public interface BinaryData
    Interface for binary data - read-only sequence of bytes. Provides methods to read whole or part of the data to array or stream.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      BinaryData copy()
      Creates copy of all data.
      BinaryData copy​(long startFrom, long length)
      Creates copy of given area.
      void copyToArray​(long startFrom, byte[] target, int offset, int length)
      Creates copy of given area into array of bytes.
      void dispose()
      Disposes all allocated data if possible.
      byte getByte​(long position)
      Returns particular byte from data.
      java.io.InputStream getDataInputStream()
      Provides handler for input stream generation.
      long getDataSize()
      Returns size of data or -1 if size is not available.
      boolean isEmpty()
      Returns true if data are empty.
      void saveToStream​(java.io.OutputStream outputStream)
      Saves/copies all data to given stream.
    • Method Detail

      • isEmpty

        boolean isEmpty()
        Returns true if data are empty.
        Returns:
        true if data empty
      • getDataSize

        long getDataSize()
        Returns size of data or -1 if size is not available.
        Returns:
        size of data in bytes
      • getByte

        byte getByte​(long position)
        Returns particular byte from data.
        Parameters:
        position - position
        Returns:
        byte on requested position
      • copy

        @Nonnull
        BinaryData copy()
        Creates copy of all data.
        Returns:
        copy of data
      • copy

        @Nonnull
        BinaryData copy​(long startFrom,
                        long length)
        Creates copy of given area.
        Parameters:
        startFrom - position to start copy from
        length - length of area
        Returns:
        copy of data
      • copyToArray

        void copyToArray​(long startFrom,
                         byte[] target,
                         int offset,
                         int length)
        Creates copy of given area into array of bytes.
        Parameters:
        startFrom - position to start copy from
        target - target byte array
        offset - offset position in target
        length - length of area to copy
      • saveToStream

        void saveToStream​(java.io.OutputStream outputStream)
                   throws java.io.IOException
        Saves/copies all data to given stream.
        Parameters:
        outputStream - output stream
        Throws:
        java.io.IOException - if input/output error
      • getDataInputStream

        @Nonnull
        java.io.InputStream getDataInputStream()
        Provides handler for input stream generation.
        Returns:
        new instance of input stream
      • dispose

        void dispose()
        Disposes all allocated data if possible.