Class TextContext

    • Constructor Detail

      • TextContext

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

      • getViewerData

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

        protected void resetData()
        Resets the internal data.

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

      • loadFromFile

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

        public void loadFromReader​(Reader r)
                            throws IOException
        Loads the text from a reader.
        Parameters:
        r - The reader to read the text from
        Throws:
        NullPointerException - If the r argument is null
        IOException - If an I/O error occurred
      • loadFromText

        public void loadFromText​(String text)
        Loads the text.
        Parameters:
        text - The text to load
        Throws:
        NullPointerException - If the text argument is null
      • appendText

        public void appendText​(String text)
        Appends text.
        Parameters:
        text - The text to append
        Throws:
        NullPointerException - if the text argument is null
      • appendLine

        public void appendLine​(String line)
        Appends a line to the text data. This method appends the supplied line and a carriage return + linefeed character to the internal text data after it has been escaped by the escapeLine method.
        Parameters:
        line - The line to append. It should not be null
        Throws:
        NullPointerException - if the line argument is null
      • escapeLine

        protected String escapeLine​(String line)
        Escapes a line.

        If overriden in derived classes, this method escapes a line depending on the viewer format used. The default implementation does no escaping.

        Parameters:
        line - The line to escape
        Returns:
        The escaped line
      • close

        public void close()
        Overrides to release any resources of this text context.
        Overrides:
        close in class ViewerContext