Groovy Documentation

java.gate.yam.translate
Class PrettyTranslator

java.lang.Object
  java.gate.yam.translate.AbstractTranslator
      java.gate.yam.translate.PrettyTranslator

class PrettyTranslator
extends AbstractTranslator

This class is a pretty-printer for YAM documents. It takes a parse tree as input, munges the whitespace in the Token images, and prints it to the supplied writer.

author:
Hamish Cunningham


Nested Class Summary
class PrettyTranslator.AnnotationData

A help class for storing annotation data before creating real annotations.

 
Field Summary
boolean identityFunction

Are we munging, or just recreating the original?

static boolean pleaseLeakLotsOfMemory

For debugging, set this true and the GATE docs that the translator creates will not be deleted.

 
Constructor Summary
PrettyTranslator()

Construction.

 
Method Summary
String getCommentImage(Token t)

Get the image of a comment.

String[][] getConstantsTable()

Array mapping node type name to start/end strings.

String getPlainNodeImage(SimpleNode n, boolean setOffsets, int offset)

Get a plain node's image from its tokens.

String getPlainNodeImage(SimpleNode n, boolean setOffsets, int offset, List annotations)

Get a plain node's image from its tokens.

String getPreamblePath()

Get the path to the preamble resource.

Object[][] getPredicatesTable()

Array mapping predicate type name to attributes.

int processToken(Token t, int offset, StringBuilder s, boolean setOffsets, List annotations)

void processURLs(SimpleNode node)

Process URLs and Anchors.

Writer translate()

Translation.

void traverse(SimpleNode n, StringBuilder content, List annotations, boolean firstPass, boolean nestedUnit)

Collect annotation data and content dominated by the input node.

 
Methods inherited from class AbstractTranslator
addToFooter, elide, getConstantArray, getConstantEnd, getConstantEnd, getConstantStart, getConstantStart, getHeadingNumber, getIndent, getNodeImage, getNodeImage, makeContents, makeHeader, makePreamble, makePreamble, pr, printEndNotes, printTree, printTree, printTree, prln, processControl, processPredicate, processURLs, setIOHandler, setParseTree, setWriter, subNewlines, translate
 

Field Detail

identityFunction

boolean identityFunction
Are we munging, or just recreating the original?


pleaseLeakLotsOfMemory

static boolean pleaseLeakLotsOfMemory
For debugging, set this true and the GATE docs that the translator creates will not be deleted. A fun trick to play on your colleagues is to set this true and then deploy into your favourite web container and sit back and wait for the screams from the systems admin team.


 
Constructor Detail

PrettyTranslator

public PrettyTranslator()
Construction.


 
Method Detail

getCommentImage

public String getCommentImage(Token t)
Get the image of a comment.


getConstantsTable

public String[][] getConstantsTable()
Array mapping node type name to start/end strings. Unused.


getPlainNodeImage

public String getPlainNodeImage(SimpleNode n, boolean setOffsets, int offset)
Get a plain node's image from its tokens. See #getPlainNodeImage(gate.yam.parse.SimpleNode, boolean, int, java.util.List)


getPlainNodeImage

public String getPlainNodeImage(SimpleNode n, boolean setOffsets, int offset, List annotations)
Get a plain node's image from its tokens. Also functions to set the (absolute) offsets on tokens when offset is set true, and when run a single pass across contiguous nodes.
param:
n the node to take an image of
param:
setOffsets whether to set start/end offsets on the tokens or not
param:
offset the absolute offset we're starting from
param:
annotations if non-null comment annotations will be accumulated here
return:
the image, and where appropriate new offsets on the token stream and/or comment annotations


getPreamblePath

public String getPreamblePath()
Get the path to the preamble resource. Unused.


getPredicatesTable

public Object[][] getPredicatesTable()
Array mapping predicate type name to attributes. Unused.


processToken

public int processToken(Token t, int offset, StringBuilder s, boolean setOffsets, List annotations)


processURLs

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


translate

public Writer translate()
Translation. Results are written to the Writer, which is also returned.


traverse

public void traverse(SimpleNode n, StringBuilder content, List annotations, boolean firstPass, boolean nestedUnit)
Collect annotation data and content dominated by the input node.


 

Groovy Documentation