# Class Formatter

java.lang.Object
uk.ac.starlink.ttools.Formatter

public class Formatter extends 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

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

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### Formatter

public Formatter()
Constructor.

## Method Details

### formatXML

public String formatXML(String xml, int indent) throws 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:
  `SAXException`

### setManualName

public void setManualName(String name)
Sets the text used to refer in formatted output to the STILTS manual.

Parameters:
  `name` - manual reference name

### getManualName

public String getManualName()
Returns the text used to refer in formatted output to the STILTS manual.

Returns:
  manual reference name

### addEntity

public void addEntity(String entName, 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 String formatWords(List<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