|
OpMath | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--com.opmath.util.dmldoc.DMLDocText
An object representing one component of a Document Object Model (DOM).
DMLDocText represents the objects which make up a
DMLDocBlock. Details of this class are only of relevance to
developers wishing to extend the dmldoc classes.
A DMLDocBlock holds the root of a linked list of
DMLDocTexts. One DMLDocText contains some text, at
the end of which is a SUB target or a child DMLDocBlock (the child
represents a LOOP or IF / IFNOT / IFDATAFOR / IFNODATAFOR block.
Copyright: (c) 2002 The Open Math Company Limited
The Terms of Distribution of this software are stipulated in the javadoc Overview for this project.
DMLDoc,
DMLDocBlock| Field Summary | |
protected static int |
MODE_EMPTY
Returned by subBlockMode(). |
protected static int |
MODE_IF
Returned by subBlockMode(). |
protected static int |
MODE_IFDATA
Returned by subBlockMode(). |
protected static int |
MODE_IFNODATA
Returned by subBlockMode(). |
protected static int |
MODE_IFNOT
Returned by subBlockMode(). |
protected static int |
MODE_LOOP
Returned by subBlockMode(). |
| Constructor Summary | |
DMLDocText()
Constructs a new DMLDocText node. |
|
| Method Summary | |
protected DMLDocText |
addDMLDocText()
Adds a new DMLDocText following this DMLDocText. |
protected void |
addText(String newText)
Appends some text to the text held by this DMLDocText. |
protected int |
maxColumnSize(ComparableTable display)
Returns the size of the longest column in the ComparableTable,
for all of the SUB and IF / IFNOT / IFDATAFOR / IFNODATAFOR sources known
to this DMLDocText. |
protected void |
newIf(BufferedReader inputText,
DMLDocBlock parent,
String ifToken,
boolean positive,
ParseCounter countLOOP,
ParseCounter countIF)
Creates an IF / IFNOT / IFDATAFOR / IFNODATAFOR element for this DMLDocText. |
protected void |
newIfData(BufferedReader inputText,
DMLDocBlock parent,
String ifToken,
boolean positive,
ParseCounter countLOOP,
ParseCounter countIF)
|
protected void |
newLoop(BufferedReader inputText,
DMLDocBlock parent,
ParseCounter countLOOP,
ParseCounter countIF)
Creates a DMLDocBlock LOOP element for this DMLDocText. |
protected void |
newSource(String subString)
Adds the SUB source to this DMLDocText. |
protected DMLDocText |
next()
Returns the DMLDocText node chained to the end of this one. |
protected DMLDocBlock |
subBlock()
Returns the DMLDocBlock introduced by this DMLDocText. |
protected int |
subBlockMode()
Returns an int code indicating whether this DMLDocText
introduces a DMLDocBlock. |
protected String |
subValue(ComparableTable display,
Comparable columnKey,
int loopIndex)
Returns a substitution value for the given Vector of data
values and index i. |
protected String |
text()
Returns the text component of this DMLDocText. |
String |
toString()
Returns a string representaion of the DMLDocText instance. |
protected String |
view(ComparableTable display,
int i)
Returns a string representaion of this DMLDocText instance,
with the various SUBs, LOOPs and IF / IFNOT / IFDATAFOR / IFNODATAFOR elements
processed, as determined by the ComparableTable and the loop
index i. |
protected ComparableList |
viewNames(ComparableList sourceList)
Fills a com.opmath.util.datastruct.ComparableList with the
substitution source names known to this DMLDocText. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected static final int MODE_EMPTY
Returned by subBlockMode().
subBlockMode(),
Constant Field Valuesprotected static final int MODE_LOOP
Returned by subBlockMode().
subBlockMode(),
Constant Field Valuesprotected static final int MODE_IF
Returned by subBlockMode().
subBlockMode(),
Constant Field Valuesprotected static final int MODE_IFNOT
Returned by subBlockMode().
subBlockMode(),
Constant Field Valuesprotected static final int MODE_IFDATA
Returned by subBlockMode().
subBlockMode(),
Constant Field Valuesprotected static final int MODE_IFNODATA
Returned by subBlockMode().
subBlockMode(),
Constant Field Values| Constructor Detail |
public DMLDocText()
Constructs a new DMLDocText node. The contents of the node
will be instantiated later.
| Method Detail |
protected DMLDocText next()
Returns the DMLDocText node chained to the end of this one.
If there are no more DMLDocTexts, then next()
returns null.
com.opmath.util.dmldoc.DMLDocText or null.protected DMLDocBlock subBlock()
Returns the DMLDocBlock introduced by this DMLDocText.
If no DMLDocBlock exists, then subBlock() returns
null.
com.opmath.util.dmldoc.DMLDocText or null.protected int subBlockMode()
Returns an int code indicating whether this DMLDocText
introduces a DMLDocBlock. The code can be one of:
int.protected String text()
Returns the text component of this DMLDocText.
Stringprotected ComparableList viewNames(ComparableList sourceList)
Fills a com.opmath.util.datastruct.ComparableList with the
substitution source names known to this DMLDocText.
If no sources are known, viewNames(com.opmath.util.datastruct.ComparableList)
does not alter the com.opmath.util.datastruct.ComparableList.
sourceList - the com.opmath.util.datastruct.ComparableList
holding the source names.
com.opmath.util.datastruct.ComparableList.DMLDocBlock.viewNames(),
DMLDocBlock.viewNames(com.opmath.util.datastruct.ComparableList)protected DMLDocText addDMLDocText()
Adds a new DMLDocText following this DMLDocText.
Always returns the new DMLDocText.
com.opmath.util.dmldoc.DMLDocTextprotected void newSource(String subString)
Adds the SUB source to this DMLDocText.
NOTE: Given that a DMLDocText has at most only one
SUB target, it also has only one SUB source. Performing newSource(String)
more than once on the same instance is therefore of doubtful value, but is legal.
subString - the String naming this SUB source.protected void addText(String newText)
Appends some text to the text held by this DMLDocText.
newText - the String carrying the text.
protected void newLoop(BufferedReader inputText,
DMLDocBlock parent,
ParseCounter countLOOP,
ParseCounter countIF)
throws DMLDocBuildException
Creates a DMLDocBlock LOOP element for this DMLDocText.
The LOOP element begins with text inputText and has the parent
DMLDocBlock parent.
The arguments countLOOP and countIF can be used
to validate the number of LOOP versus ENDLOOP, and IF / IFNOT / IFDATAFOR /
IFNODATAFOR versus ENDIF instructions encountered in the template source -
these counters should both be zero on exit from the DMLDocBlock
building operation.
inputText - the BufferedReader carrying the template source.parent - the DMLDocBlock parent of this node.countLOOP - the ParseCounter for LOOP commands.countIF - the ParseCounter for IF / IFNOT / IFDATAFOR / IFNODATAFOR commands.
DMLDocBuildException - An exception thrown if
inputText contained malformed commands.
protected void newIf(BufferedReader inputText,
DMLDocBlock parent,
String ifToken,
boolean positive,
ParseCounter countLOOP,
ParseCounter countIF)
throws DMLDocBuildException
Creates an IF / IFNOT / IFDATAFOR / IFNODATAFOR element for this
DMLDocText. Its DMLDocBlock begins with text
inputText and has the parent DMLDocBlock
parent.
The argument ifToken is the source agument of the IF /
IFNOT / IFDATAFOR / IFNODATAFOR instruction. Theargument positive
is true for IF and IFDATAFOR, false for IFNOT and
IFNODATAFOR. The ParseCounter arguments are equivalent to those for
newLoop(BufferedReader, DMLDocBlock, ParseCounter, ParseCounter).
inputText - the BufferedReader carrying the template source.parent - the DMLDocBlock parent of this node.ifToken - the String naming the IF / IFNOT / IFDATAFOR / IFNODATAFOR determiner.positive - the boolean for determiner sense.countLOOP - the ParseCounter for LOOP commands.countIF - the ParseCounter for IF/ IFNOT commands.
DMLDocBuildException - An exception thrown if
inputText contained malformed commands.newLoop(BufferedReader, DMLDocBlock, ParseCounter, ParseCounter)
protected void newIfData(BufferedReader inputText,
DMLDocBlock parent,
String ifToken,
boolean positive,
ParseCounter countLOOP,
ParseCounter countIF)
throws DMLDocBuildException
DMLDocBuildException
protected int maxColumnSize(ComparableTable display)
throws DMLDocWriteException
Returns the size of the longest column in the ComparableTable,
for all of the SUB and IF / IFNOT / IFDATAFOR / IFNODATAFOR sources known
to this DMLDocText.
Note the plural substitution sources! Each DMLDocText
has at most one substitution source, and at most one IF / IFNOT / IFDATAFOR
/ IFNODATAFOR source. But maxColumnSize(ComparableTable)
returns the size of the longest column known to this DMLDocText
and those chained to it using addDMLDocText().
maxColumnSize(ComparableTable)checks the IF source, if present,
but does not need to descend into the IF's DMLDocBlock node.
display - the ComparableTable carrying the data set.
int
DMLDocWriteException - An exception thrown
if a SUB or IF / IFNOT / IFDATAFOR / IFNODATAFOR source was
not found in the ComparableTable.addDMLDocText()
protected String subValue(ComparableTable display,
Comparable columnKey,
int loopIndex)
throws DMLDocWriteException
Returns a substitution value for the given Vector of data
values and index i.
subValue(com.opmath.util.datastruct.ComparableList, int)
embodies a number of important rules which define the instatiation bahaviour
of DMLDocBlock:
com.opmath.util.datastruct.ComparableList contains
only one element, then that element is returned, irrespective of the value
of i.com.opmath.util.datastruct.ComparableList contains
more than one element, then the element at i is returned.i is outside the range for the
com.opmath.util.datastruct.ComparableList of data values, then
an empty String ("") is returned.NOTE: Although subValue(com.opmath.util.datastruct.ComparableList, int)
is formally able to throw a com.opmath.util.dmldoc.DMLDocWriteException,
this will not happen under normal operations.
String
DMLDocWriteException - Reserved.
protected String view(ComparableTable display,
int i)
throws DMLDocWriteException
Returns a string representaion of this DMLDocText instance,
with the various SUBs, LOOPs and IF / IFNOT / IFDATAFOR / IFNODATAFOR elements
processed, as determined by the ComparableTable and the loop
index i.
display - the ComparableTable carrying the data set.i - the int index into the column.
String
DMLDocWriteException - An exception thrown
if the ComparableTable does not match the
DMLDocText.toString()public String toString()
Returns a string representaion of the DMLDocText instance.
No instantiation is performed, but the structure of the DMLDocText instance
is revealed.
NOTE: Intended to be used for debugging tasks only. The format of the
output may change from one release of dmldoc to the next.
toString in class ObjectStringview(com.opmath.util.datastruct.ComparableTable, int)
|
OpMath | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||