Class Formatter


  • public class Formatter
    extends java.lang.Object
    Assists in formatting text for output on the terminal.
    Since:
    31 Aug 2005
    Author:
    Mark Taylor
    • Constructor Summary

      Constructors 
      Constructor Description
      Formatter()
      Constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addEntity​(java.lang.String entName, java.lang.String entValue)
      Adds an internal entity declaration to this formatter.
      static java.lang.String formatWords​(java.util.List<java.lang.String> wordList, int indent)
      Utility method for writing a number of unbreakable words on the terminal.
      java.lang.String formatXML​(java.lang.String xml, int indent)
      Returns a string which is a formatted version of an XML string.
      java.lang.String getManualName()
      Returns the text used to refer in formatted output to the STILTS manual.
      void setManualName​(java.lang.String name)
      Sets the text used to refer in formatted output to the STILTS manual.
      • Methods inherited from class java.lang.Object

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

      • Formatter

        public Formatter()
        Constructor.
    • Method Detail

      • formatXML

        public java.lang.String formatXML​(java.lang.String xml,
                                          int indent)
                                   throws org.xml.sax.SAXException
        Returns a string which is a formatted version of an XML string. The result is suitable for output on the terminal. A few elements, such as p, code, ul, ref etc may be treated specially.
        Parameters:
        xml - XML text
        indent - number of spaces to indent every line
        Throws:
        org.xml.sax.SAXException
      • setManualName

        public void setManualName​(java.lang.String name)
        Sets the text used to refer in formatted output to the STILTS manual.
        Parameters:
        name - manual reference name
      • getManualName

        public java.lang.String getManualName()
        Returns the text used to refer in formatted output to the STILTS manual.
        Returns:
        manual reference name
      • addEntity

        public void addEntity​(java.lang.String entName,
                              java.lang.String entValue)
        Adds an internal entity declaration to this formatter. Any entities added here are declared in the document declaration of XML parsed by the formatXML method.
        Parameters:
        entName - internal entity name
        entValue - entity value
      • formatWords

        public static java.lang.String formatWords​(java.util.List<java.lang.String> wordList,
                                                   int indent)
        Utility method for writing a number of unbreakable words on the terminal. Line breaks are introduced where required to avoid overrunning screen lines (currently, 80 characters). The first line is indented the given number of spaces, subsequent lines start aligned with the end of the first word:
             aaaa bbb cccc d eee ...
                  xxxxxx yy
         
        Parameters:
        wordList - list of words
        indent - number of spaces to indent lines
        Returns:
        formatted string