OpMath

com.opmath.util.dmldoc
Class DMLDocBlock

java.lang.Object
  |
  +--com.opmath.util.dmldoc.DMLDocBlock
Direct Known Subclasses:
DMLDoc

class DMLDocBlock
extends Object

The Document Object Model (DOM) for the SGML template.

DMLDocBlock is a unit of the DMLDoc: this unit is roughly equivalent to a block of program code. Thus, it can represent the complete DOM, or some part of the DOM such as a LOOP or IF / IFNOT / IFDATAFOR / IFNODATAFOR component. DMLDocBlocks can be nested recursively.

A DMLDocBlock contains one or more DMLDocText components. Each of these components is responsible for one one SUB value, and its preceeding text.

Copyright: (c) 2002 The Open Math Company Limited

The Terms of Distribution of this software are stipulated in the javadoc Overview for this project.

Since:
J2SE 1.3
Version:
utilities-v011
Author:
Bruno Beloff bruno.beloff@opmath.com
See Also:
DMLDoc, DMLDocText

Field Summary
protected static String CMD_ENDIF
          The String identifying the DMLDoc ENDIF command.
protected static String CMD_ENDLOOP
          The String identifying the DMLDoc ENDLOOP command.
protected static String CMD_IF
          The String identifying the DMLDoc IF command.
protected static String CMD_IFDATA
          The String identifying the DMLDoc IFDATAFOR command.
protected static String CMD_IFNODATA
          The String identifying the DMLDoc IFNODATAFOR command.
protected static String CMD_IFNOT
          The String identifying the DMLDoc IFNOT command.
protected static String CMD_LOOP
          The String identifying the DMLDoc LOOP command.
protected static String CMD_SUB
          The String identifying the DMLDoc SUB command.
protected static String DELIMITERS
          The delimiters used to identify the DMLDoc command tokens in the template source.
protected static String EOL
          The end-of-line character or characters for the server operating system.
 
Constructor Summary
  DMLDocBlock()
          Constructs an empty DMLDocBlock node.
  DMLDocBlock(BufferedReader viewReader)
          Constructs a DMLDocBlock node for a given input text, and with a given DMLDocBlock parent node.
protected DMLDocBlock(BufferedReader viewReader, DMLDocBlock newParent, ParseCounter countLOOP, ParseCounter countIF)
          Constructs a DMLDocBlock for a given source text, and with a given DMLDocBlock parent node.
protected DMLDocBlock(BufferedReader viewReader, DMLDocBlock newParent, String ifToken, ParseCounter countLOOP, ParseCounter countIF)
          Constructs a DMLDocBlock for a given source text, and with a given DMLDocBlock parent node.
 
Method Summary
protected  void parse(BufferedReader viewReader)
          Constructs the DMLDocBlock according to the text supplied by the given BufferedReader.
 String toString()
          Returns a formatted string representaion of the DMLDocBlock instance.
 String view(ComparableTable model)
          Returns a String representaion of the DMLDocBlock instance, with the various SUBs, LOOPs and IF / IFNOT / IFDATAFOR / IFNODATAFOR elements processed, as determined by the contents of the com.opmath.util.datastruct.ComparableTable.
protected  String view(ComparableTable model, int mode, int loopIndex)
          Returns a String representaion of the DMLDocBlock instance, with the various SUBs, LOOPs and IF / IFNOT / IFDATAFOR / IFNODATAFOR elements processed, as determined by the contents of the com.opmath.util.datastruct.ComparableTable.
 ComparableList viewNames()
          Returns a ComparableList containing one Object for each of the SUB and IF / IFNOT / IFDATAFOR / IFNODATAFOR source names found in the SGML template file.
protected  ComparableList viewNames(ComparableList sourceList)
          Updates the com.opmath.util.datastruct.ComparableList with one Object for each of the SUB and IF / IFNOT / IFDATAFOR / IFNODATAFOR sources found in the SGML template file (if any).
 String viewWithException(ComparableTable model)
          Returns a String representaion of the DMLDocBlock instance, with the various SUBs, LOOPs and IF / IFNOT / IFDATAFOR / IFNODATAFOR elements processed, as determined by the contents of the com.opmath.util.datastruct.ComparableTable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DELIMITERS

protected static final String DELIMITERS

The delimiters used to identify the DMLDoc command tokens in the template source. Used by the DMLDoc parser.

Set to "\t\n\r #/|%,.;:'?=&\"<>[]{}".

Since:
J2SE 1.3
See Also:
Constant Field Values

EOL

protected static final String EOL

The end-of-line character or characters for the server operating system. Used by the DMLDoc parser, instantiator, and exception reporting methods.

Set to System.getProperty("line.separator").

Since:
J2SE 1.3

CMD_SUB

protected static final String CMD_SUB

The String identifying the DMLDoc SUB command. Used by the parser. Note that this parser is not case-sensitive for these commands.

Set to "SUB".

Since:
J2SE 1.3
See Also:
Constant Field Values

CMD_IF

protected static final String CMD_IF

The String identifying the DMLDoc IF command. Used by the parser. Note that this parser is not case-sensitive for these commands.

Set to "IF".

Since:
J2SE 1.3
See Also:
Constant Field Values

CMD_IFNOT

protected static final String CMD_IFNOT

The String identifying the DMLDoc IFNOT command. Used by the parser. Note that this parser is not case-sensitive for these commands.

Set to "IFNOT".

Since:
J2SE 1.3
See Also:
Constant Field Values

CMD_IFDATA

protected static final String CMD_IFDATA

The String identifying the DMLDoc IFDATAFOR command. Used by the parser. Note that this parser is not case-sensitive for these commands.

Set to "IFDATAFOR".

Since:
J2SE 1.3
See Also:
Constant Field Values

CMD_IFNODATA

protected static final String CMD_IFNODATA

The String identifying the DMLDoc IFNODATAFOR command. Used by the parser. Note that this parser is not case-sensitive for these commands.

Set to "IFNODATAFOR".

Since:
J2SE 1.3
See Also:
Constant Field Values

CMD_ENDIF

protected static final String CMD_ENDIF

The String identifying the DMLDoc ENDIF command. Used by the parser. Note that this parser is not case-sensitive for these commands.

Set to "ENDIF".

Since:
J2SE 1.3
See Also:
Constant Field Values

CMD_LOOP

protected static final String CMD_LOOP

The String identifying the DMLDoc LOOP command. Used by the parser. Note that this parser is not case-sensitive for these commands.

Set to "LOOP".

Since:
J2SE 1.3
See Also:
Constant Field Values

CMD_ENDLOOP

protected static final String CMD_ENDLOOP

The String identifying the DMLDoc ENDLOOP command. Used by the parser. Note that this parser is not case-sensitive for these commands.

Set to "ENDLOOP".

Since:
J2SE 1.3
See Also:
Constant Field Values
Constructor Detail

DMLDocBlock

protected DMLDocBlock(BufferedReader viewReader,
                      DMLDocBlock newParent,
                      String ifToken,
                      ParseCounter countLOOP,
                      ParseCounter countIF)
               throws DMLDocBuildException

Constructs a DMLDocBlock for a given source text, and with a given DMLDocBlock parent node.

NOTE: It is anticipated that DMLDoc(String, String) will be the most common way in which DMLDocBlock instances are created.

Parameters:
viewReader - a BufferedReader carrying the source text.
newParent - the DMLDocBlock which will be the parent of this new node.
ifToken - the String naming the IF / IFNOT determiner.
countLOOP - the ParseCounter used to measure LOOP balance.
countIF - the ParseCounter used to measure IF / IFNOT balance.
Throws:
DMLDocBuildException - An exception thrown if the source text contained malformed commands.
Since:
J2SE 1.3
See Also:
DMLDocBlock(String,String)

DMLDocBlock

protected DMLDocBlock(BufferedReader viewReader,
                      DMLDocBlock newParent,
                      ParseCounter countLOOP,
                      ParseCounter countIF)
               throws DMLDocBuildException

Constructs a DMLDocBlock for a given source text, and with a given DMLDocBlock parent node.

NOTE: It is anticipated that DMLDoc(String, String) will be the most common way in which DMLDocBlock instances are created.

Parameters:
viewReader - a BufferedReader carrying the source text.
newParent - the DMLDocBlock which will be the parent of this new node.
countLOOP - the ParseCounter used to measure LOOP balance.
countIF - the ParseCounter used to measure IF balance.
Throws:
DMLDocBuildException - An exception thrown if the source text contained malformed commands.
Since:
J2SE 1.3
See Also:
DMLDocBlock(String,String)

DMLDocBlock

public DMLDocBlock(BufferedReader viewReader)
            throws DMLDocBuildException

Constructs a DMLDocBlock node for a given input text, and with a given DMLDocBlock parent node.

NOTE: It is anticipated that DMLDoc(String, String) will be the most common way in which DMLDocBlock instances are created.

Parameters:
viewReader - the BufferedReader for the template file.
Throws:
DMLDocBuildException - An exception thrown if the source text contained malformed commands.
Since:
J2SE 1.3
See Also:
DMLDocBlock(String,String)

DMLDocBlock

public DMLDocBlock()

Constructs an empty DMLDocBlock node.

NOTE: It is anticipated that DMLDoc(String, String) will be the most common way in which DMLDocBlock instances are created.

Since:
J2SE 1.3
See Also:
DMLDocBlock(String,String)
Method Detail

viewNames

protected ComparableList viewNames(ComparableList sourceList)

Updates the com.opmath.util.datastruct.ComparableList with one Object for each of the SUB and IF / IFNOT / IFDATAFOR / IFNODATAFOR sources found in the SGML template file (if any).

It is anticipated that the alternative method - viewNames() - will be the normal way in which DMLDocBlock view sources are found.

Parameters:
sourceList - the ComparableList for the SUB and IF / IFNOT / IFDATAFOR / IFNODATAFOR source names.
Returns:
a ComparableList of source names.
Since:
J2SE 1.3
See Also:
viewNames(com.opmath.util.datastruct.ComparableList), DMLDocText.viewNames(com.opmath.util.datastruct.ComparableList)

viewNames

public ComparableList viewNames()

Returns a ComparableList containing one Object for each of the SUB and IF / IFNOT / IFDATAFOR / IFNODATAFOR source names found in the SGML template file.

If no substitution sources were found, viewNames() returns a ComparableList with zero elements.

Returns:
a ComparableList of source names.
Since:
J2SE 1.3

parse

protected void parse(BufferedReader viewReader)
              throws DMLDocBuildException

Constructs the DMLDocBlock according to the text supplied by the given BufferedReader. If the source text contains malformed commands, parse(BufferedReader) throws a DMLDocBuildException.

Parameters:
viewReader - a BufferedReader carrying the source text.
Returns:
a ComparableList of source names.
Throws:
DMLDocBuildException - An exception thrown if the source text contained malformed commands.
Since:
J2SE 1.3

view

protected String view(ComparableTable model,
                      int mode,
                      int loopIndex)
               throws DMLDocWriteException

Returns a String representaion of the DMLDocBlock instance, with the various SUBs, LOOPs and IF / IFNOT / IFDATAFOR / IFNODATAFOR elements processed, as determined by the contents of the com.opmath.util.datastruct.ComparableTable.

NOTE: This is a highly specialzed method, only called during recursive decents into the DOM.

Parameters:
model - the com.opmath.util.datastruct.ComparableTable representing the data set.
mode - the int representing the function of this DMLDocBlock.
loopIndex - the int representing the current row in the model.
Returns:
a new String containing the instantiated DMLDocBlock.
Throws:
DMLDocWriteException - An exception thrown if the com.opmath.util.datastruct.ComparableTable was malformed.
Since:
J2SE 1.3
See Also:
view(com.opmath.util.datastruct.ComparableTable)

viewWithException

public String viewWithException(ComparableTable model)
                         throws DMLDocWriteException

Returns a String representaion of the DMLDocBlock instance, with the various SUBs, LOOPs and IF / IFNOT / IFDATAFOR / IFNODATAFOR elements processed, as determined by the contents of the com.opmath.util.datastruct.ComparableTable.

If the com.opmath.util.datastruct.ComparableTable is malformed, viewWithException(com.opmath.util.datastruct.ComparableTable) raises a DMLDocWriteException exception.

Parameters:
model - the com.opmath.util.datastruct.ComparableTable representing the data set.
Returns:
a new String containing the instantiated DMLDocBlock.
Throws:
DMLDocWriteException - An exception thrown if the com.opmath.util.datastruct.ComparableTable was malformed.
Since:
J2SE 1.3
See Also:
view(com.opmath.util.datastruct.ComparableTable)

view

public String view(ComparableTable model)

Returns a String representaion of the DMLDocBlock instance, with the various SUBs, LOOPs and IF / IFNOT / IFDATAFOR / IFNODATAFOR elements processed, as determined by the contents of the com.opmath.util.datastruct.ComparableTable.

If the com.opmath.util.datastruct.ComparableTable is malformed, view(com.opmath.util.datastruct.ComparableTable) attempts to return a String containing an SGML-formatted report detailing the cause of the problem. The template resource for this report is held at com.opmath.util.dmldoc.tpl_DMLDocWriteException.html This template may be edited, but all of its <!-- SUB .. --> commands should remain unaltered.

NOTE: If com.opmath.util.dmldoc.tpl_DMLDocWriteException.html is not found, or is malformed, then view(com.opmath.util.datastruct.ComparableTable) reports to System.err and returns an empty String.

Parameters:
model - the com.opmath.util.datastruct.ComparableTable representing the data set.
Returns:
a new String containing the instantiated SGML template.
Since:
J2SE 1.3

toString

public String toString()

Returns a formatted string representaion of the DMLDocBlock instance. No instantiation is performed, but the structure of the DMLDocBlockinstance 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.

Overrides:
toString in class Object
Returns:
a new String
Since:
J2SE 1.3
See Also:
view(com.opmath.util.datastruct.ComparableTable)

OpMath

Submit a bug or feature to Open Math
Copyright © 2002 Open Math Company Limited, Brighton, UK