Class BinaryContext

  • Direct Known Subclasses:
    BinaryViewerContext

    public class BinaryContext
    extends ViewerContext
    This is the base class for all viewer contexts, which deal with binary data. A viewer context is the library-side representation of a viewer in the Console.

    This class is not guaranteed to be threadsafe.

    • Constructor Detail

      • BinaryContext

        public BinaryContext​(ViewerId vi)
        Creates and initializes a BinaryContext instance.
        Parameters:
        vi - The viewer ID to use
    • Method Detail

      • getViewerData

        public byte[] getViewerData()
        Overridden. Returns the actual binary data which will be displayed in the viewer specified by the getViewerId
        Specified by:
        getViewerData in class ViewerContext
        Returns:
        The actual binary data which will be displayed in the viewer specified by the getViewerId method.
      • resetData

        protected void resetData()
        Resets the internal data stream.

        This method is intended to reset the internal data stream if custom handling of data is needed by derived classes.

      • loadFromFile

        public void loadFromFile​(String fileName)
                          throws IOException
        Loads the binary data from a file.
        Parameters:
        fileName - The name of the file to load the binary data from.
        Throws:
        NullPointerException - The fileName argument is null
        IOException - An I/O error occurred
      • loadFromStream

        public void loadFromStream​(InputStream is)
                            throws IOException
        Loads the binary data from a stream.
        Parameters:
        is - The stream to load the binary data from.
        Throws:
        NullPointerException - The is argument is null
        IOException - An I/O error occurred
      • appendBytes

        public void appendBytes​(byte[] b)
        Overloaded. Appends a buffer.
        Parameters:
        b - The buffer to append
        Throws:
        NullPointerException - The b argument is null
      • appendBytes

        public void appendBytes​(byte[] b,
                                int off,
                                int len)
        Overloaded. Appends a buffer. Lets you specify the offset in the buffer and the amount of bytes to append.
        Parameters:
        b - The buffer to append
        off - The offset at which to begin appending
        len - The number of bytes to append
        Throws:
        IndexOutOfBoundsException - The sum of the off and len parameters is greater than the actual buffer length or the off or len arguments are negative
        NullPointerException - The b argument is null
      • close

        public void close()
        Overridden. Releases any resources used by this binary context.
        Overrides:
        close in class ViewerContext