Groovy Documentation

java.gate.yam.translate
Class AbstractTranslator

java.lang.Object
  java.gate.yam.translate.AbstractTranslator
All Implemented Interfaces:
TranslationConstants

class AbstractTranslator

This class provides a model for YAM translators. It is intended to be extended by all translators.

author:
Hamish Cunningham


Field Summary
Map constantsMap

Map from constant name to output strings.

String[][] constantsTable

Array mapping node type name to start/end strings.

Map controlsMap

Map from control types to activity status.

static boolean debug

Debug flag.

StringBuilder footerStuff

Material to insert at the end of the translation.

List footnotesList

List of footnotes.

IOHandler ioHandler

The translator's IOHandler.

static Logger log

Logger

YamParseTree parseTree

Tree holding the results of a YAM parse.

Map predicatesMap

Map from predicate names to attributes.

Object[][] predicatesTable

Array mapping predicate type name to attributes.

static String translatorType

Type of the translator - "Html", for example.

Writer writer

Writer for translation results.

 
Constructor Summary
AbstractTranslator()

 
Method Summary
void addToFooter(String footerAddition)

Material to insert at the end of the translation.

String elide(String line)

Elide a string to fit a normal line.

String[] getConstantArray(String name)

Get the three-element array describing a constant from the map.

String getConstantEnd(int id)

Get the markup end element of a constant from the constants map.

String getConstantEnd(String name)

Get the markup end element of a constant from the constants map.

String getConstantStart(int id)

Get the markup start element of a constant from the constants map.

String getConstantStart(String name)

Get the markup start element of a constant from the constants map.

String getHeadingNumber(int[] contentsNumbering, int level)

Derive a heading number string from a numbering array and the level.

String getIndent(int level)

Get indent spacing for a contents line.

String getNodeImage(SimpleNode node)

Get a node's image from its tokens (using printTree).

String getNodeImage(SimpleNode node, boolean inContents)

Get a node's image from its tokens (using printTree).

void makeContents()

Collect contents and set heading bodies.

String makeHeader(int[] contentsNumbering, int level, String text, boolean markup, String headingClass)

Construct a header.

void makePreamble()

Deal with the preamble material (and title if it exists).

String makePreamble(String title)

Construct the preamble/header for the document.

void pr(String s)

Write a string.

void printEndNotes()

Print end notes.

void printTree(SimpleNode node)

Traverse (and translate) a subtree.

void printTree(SimpleNode node, boolean inContents)

Traverse (and translate) a subtree.

void printTree(SimpleNode node, boolean inContents, SimpleNode nextNode)

Traverse (and translate) a subtree.

void prln(String s)

Write a string plus a newline.

void processControl(SimpleNode node)

Process a control node.

void processPredicate(SimpleNode node)

Process a predicate node.

void processURLs(SimpleNode node)

Process URLs and Anchors.

void setIOHandler(IOHandler ioh)

Set the translator's IOHandler.

void setParseTree(YamParseTree parseTree)

Set the tree holding the results of a YAM parse.

void setWriter(Writer writer)

Set the Writer for translation results.

String subNewlines(String s)

Substitute newlines.

Writer translate()

Translation.

 
Methods inherited from class Object
wait, wait, wait, hashCode, getClass, equals, toString, notify, notifyAll
 

Field Detail

constantsMap

Map constantsMap
Map from constant name to output strings.


constantsTable

String[][] constantsTable
Array mapping node type name to start/end strings.


controlsMap

Map controlsMap
Map from control types to activity status.


debug

static final boolean debug
Debug flag.


footerStuff

StringBuilder footerStuff
Material to insert at the end of the translation.


footnotesList

List footnotesList
List of footnotes.


ioHandler

IOHandler ioHandler
The translator's IOHandler.


log

static Logger log
Logger


parseTree

YamParseTree parseTree
Tree holding the results of a YAM parse.


predicatesMap

Map predicatesMap
Map from predicate names to attributes.


predicatesTable

Object[][] predicatesTable
Array mapping predicate type name to attributes.


translatorType

static String translatorType
Type of the translator - "Html", for example.


writer

Writer writer
Writer for translation results. Defaults to gate.util.Out's Writer.


 
Constructor Detail

AbstractTranslator

AbstractTranslator()


 
Method Detail

addToFooter

public void addToFooter(String footerAddition)
Material to insert at the end of the translation.


elide

public String elide(String line)
Elide a string to fit a normal line.


getConstantArray

public String[] getConstantArray(String name)
Get the three-element array describing a constant from the map.


getConstantEnd

public String getConstantEnd(int id)
Get the markup end element of a constant from the constants map.
param:
id The id of the constant.


getConstantEnd

public String getConstantEnd(String name)
Get the markup end element of a constant from the constants map.
param:
name The name of the constant.


getConstantStart

public String getConstantStart(int id)
Get the markup start element of a constant from the constants map.
param:
id The id of the constant.


getConstantStart

public String getConstantStart(String name)
Get the markup start element of a constant from the constants map.
param:
name The name of the constant.


getHeadingNumber

public String getHeadingNumber(int[] contentsNumbering, int level)
Derive a heading number string from a numbering array and the level.


getIndent

public String getIndent(int level)
Get indent spacing for a contents line.


getNodeImage

public String getNodeImage(SimpleNode node)
Get a node's image from its tokens (using printTree).


getNodeImage

public String getNodeImage(SimpleNode node, boolean inContents)
Get a node's image from its tokens (using printTree).


makeContents

public void makeContents()
Collect contents and set heading bodies.


makeHeader

public String makeHeader(int[] contentsNumbering, int level, String text, boolean markup, String headingClass)
Construct a header.


makePreamble

public void makePreamble()
Deal with the preamble material (and title if it exists).


makePreamble

public String makePreamble(String title)
Construct the preamble/header for the document.


pr

public void pr(String s)
Write a string.


printEndNotes

public void printEndNotes()
Print end notes.


printTree

public void printTree(SimpleNode node)
Traverse (and translate) a subtree.


printTree

public void printTree(SimpleNode node, boolean inContents)
Traverse (and translate) a subtree.


printTree

public void printTree(SimpleNode node, boolean inContents, SimpleNode nextNode)
Traverse (and translate) a subtree.


prln

public void prln(String s)
Write a string plus a newline.


processControl

public void processControl(SimpleNode node)
Process a control node.


processPredicate

public void processPredicate(SimpleNode node)
Process a predicate node.


processURLs

public void processURLs(SimpleNode node)
Process URLs and Anchors.


setIOHandler

public void setIOHandler(IOHandler ioh)
Set the translator's IOHandler.


setParseTree

public void setParseTree(YamParseTree parseTree)
Set the tree holding the results of a YAM parse.


setWriter

public void setWriter(Writer writer)
Set the Writer for translation results.


subNewlines

public String subNewlines(String s)
Substitute newlines.


translate

public Writer translate()
Translation. Results are written to the Writer.


 

Groovy Documentation