|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.gate.yam.format.YamFormatter
class YamFormatter
Format utility for YAM based on JAPE.
Field Summary | |
---|---|
static String |
EDIT_AT
Annotation type for the Edit annotations. |
static String |
NUM_BLANK_LINES_AFTER_FEATURE_NAME
name of the feature to represent the number of lines after the Edit annotation |
static String |
NUM_BLANK_LINES_BEFORE_FEATURE_NAME
name of the feature to represent the number of lines before the Edit annotation |
static String |
WRAP_AT
Annotation type for the Wrap annotations |
static String |
YAM_PARSER_XGAPP
Yam Parser xgapp file name (relative to web-app/WEB-INF/gate) used if no explicit DocumentProcessor has been provided. |
private static DocumentProcessor |
documentProcessor
DocumentProcessor used to process the GATE document. |
static Logger |
log
Logger |
static Map |
spacesTable
Spaces Table used for storing desired number of min/max/normal spaces before/after the edit annotations |
Constructor Summary | |
YamFormatter()
|
Method Summary | |
---|---|
private static int
|
calculateIndentLevel(StringBuilder content)
This method counts the indentLevel by looking for white-spaces at the start of the first line. |
private static void
|
formatDocument(gate.Document doc, StringBuilder content)
This method formats the document for its white spaces - adding more where needed and deleting where are more than desired. |
private static boolean
|
insertNL(StringBuilder content, int nlToAdd, int insertAt)
Inserts new lines (represented by nlToAdd) at the specified position (insertAt) |
private static int
|
nlsAfterAnnotation(StringBuilder content, gate.Annotation a, int insertAt)
Removes new lines where more than desired and adds where too few content of the document that should be formatted for new lines Edit annotation which contains information about new lines before and after the annotations (as counted in the original document). |
private static void
|
nlsBeforeAnnotation(StringBuilder content, gate.Annotation a, int insertAt, int nlsToPreserve)
Removes new lines where more than desired and adds where too few content of the document that should be formatted for new lines Edit annotation which contains information about new lines before and after the annotations (as counted in the original document). |
static void
|
normalise(gate.Document doc, StringBuilder content)
Normalise the spacing in an annotated YAM document. |
private static boolean
|
removeNL(StringBuilder content, int nlToRemove, int removeAt, boolean backward)
Removes new lines (represented by nlToRemove) at the specified position (removeAt) indicates if the new lines to delete are in the backward direction if this method carried out changes, false otherwise |
static void
|
setDocumentProcessor(DocumentProcessor p)
|
private static void
|
setupDefaultDocumentProcessor()
Set up a default simple document processor if one has not been configured externally. |
static void
|
wrap(StringBuilder inputText, int startOffset, int endOffset, int indentLevel, int textWidth)
Wrap a range of text. |
Methods inherited from class Object | |
---|---|
wait, wait, wait, hashCode, getClass, equals, toString, notify, notifyAll |
Field Detail |
---|
static final String EDIT_AT
static final String NUM_BLANK_LINES_AFTER_FEATURE_NAME
static final String NUM_BLANK_LINES_BEFORE_FEATURE_NAME
static final String WRAP_AT
static final String YAM_PARSER_XGAPP
private static DocumentProcessor documentProcessor
static Logger log
static final Map spacesTable
Constructor Detail |
---|
YamFormatter()
Method Detail |
---|
private static int calculateIndentLevel(StringBuilder content)
private static void formatDocument(gate.Document doc, StringBuilder content)
private static boolean insertNL(StringBuilder content, int nlToAdd, int insertAt)
private static int nlsAfterAnnotation(StringBuilder content, gate.Annotation a, int insertAt)
private static void nlsBeforeAnnotation(StringBuilder content, gate.Annotation a, int insertAt, int nlsToPreserve)
public static void normalise(gate.Document doc, StringBuilder content)
private static boolean removeNL(StringBuilder content, int nlToRemove, int removeAt, boolean backward)
public static void setDocumentProcessor(DocumentProcessor p)
private static void setupDefaultDocumentProcessor()
public static void wrap(StringBuilder inputText, int startOffset, int endOffset, int indentLevel, int textWidth)
Groovy Documentation