xbn.template
Class TemplateLineAnalyzer

java.lang.Object
  |
  +--xbn.XBNObject
        |
        +--xbn.template.TemplateLineAnalyzer

public class TemplateLineAnalyzer
extends XBNObject

For every line found in a template, this class retrieves surrounding text and gaps.

Source code:  TemplateLineAnalyzer.java

Configuration for this class is held in a TParseConfig.

Note that, for speed and efficiency, gaps are validated on the fly, one at a time, as they are retrieved. You will successfully retrieve the first three gaps contained in the line, even when the fourth one is illegally formatted.


Fields inherited from class xbn.XBNObject
bFALSE_IN_PRODUCTION, bTRUE_IN_PRODUCTION, sCNSTR, sES, sLINE_SEP
 
Constructor Summary
TemplateLineAnalyzer(StringBuffer sb_line)
          Create an TemplateLineAnalyzer.
TemplateLineAnalyzer(String s_templateName, int i_lineNumber, StringBuffer sb_line)
          Create an TemplateLineAnalyzer.
TemplateLineAnalyzer(String s_templateName, int i_lineNumber, StringBuffer sb_line, TLAObjects tla_objects)
          Create an TemplateLineAnalyzer.
TemplateLineAnalyzer(String s_templateName, int i_lineNumber, StringBuffer sb_line, TParseConfig tp_config)
          Create an TemplateLineAnalyzer.
 
Method Summary
 int getCharArrIdx()
          Get the current character array index.
 String getFinalSurrTxt()
          Get the final surrounding text, after all surrounding-text-and-gaps have been retrieved.
 GapConfig getGapConfig()
          Get the GapConfig for direct manipulation.
 int getLineNumber()
          Get the current line number.
 s_s getNextSurrTxtAndGap()
          Get the next surrounding text and gap.
 String getTemplateName()
          Get the name of the template being analyzed.
 TParseConfig getTParseConfig()
          Get the TParseConfig for direct manipulation.
 boolean hasAnotherGap()
          Is there another gap in the line, yet to be retrieved?
 boolean isDoneAnalyzing()
          Has this line been completely analyzed?
 
Methods inherited from class xbn.XBNObject
getXMsgPrefix, sop, sopl, sopl, throwAX, throwAXIfBadStr, throwAXIfNull, throwAXSpoof
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateLineAnalyzer

public TemplateLineAnalyzer(StringBuffer sb_line)
                     throws TemplateFormatException

Create an TemplateLineAnalyzer.

Equal to TParseConfig(null, -1, sb_line, new TParseConfig())

This constructor is intended for testing purposes only. When using this class for real, it is recommended that you use the TLAObjects version of this class' constructors.


TemplateLineAnalyzer

public TemplateLineAnalyzer(String s_templateName,
                            int i_lineNumber,
                            StringBuffer sb_line)
                     throws TemplateFormatException

Create an TemplateLineAnalyzer.

Equal to TParseConfig(s_templateName, i_lineNumber, sb_line, (new TParseConfig()))


TemplateLineAnalyzer

public TemplateLineAnalyzer(String s_templateName,
                            int i_lineNumber,
                            StringBuffer sb_line,
                            TParseConfig tp_config)
                     throws TemplateFormatException

Create an TemplateLineAnalyzer.

Equal to TemplateLineAnalyzer(s_templateName, i_lineNumber, sb_line, (new TLAObjects(tp_config))

This constructor is intended for testing purposes only. When using this class for real, it is recommended that you use the TLAObjects version of this class' constructors.


TemplateLineAnalyzer

public TemplateLineAnalyzer(String s_templateName,
                            int i_lineNumber,
                            StringBuffer sb_line,
                            TLAObjects tla_objects)
                     throws TemplateFormatException

Create an TemplateLineAnalyzer.

Parameters:
s_templateName - The name of the template being analyzed, for debugging purposes only.
i_lineNumber - The current line number, for debugging purposes only. Should be greater than zero, but not enforced.
sb_line - A single line of text that may or may not contain a gap. May not be null.
tla_objects - The TLAObjects, containing some of the internal objects needed by this class, as well as the TParseConfig, which defines what a gap is.
Throws:
AssertException - If sb_line contains a line separator.
Method Detail

getTParseConfig

public final TParseConfig getTParseConfig()

Get the TParseConfig for direct manipulation.

Returns:
The TParseConfig as provided to the TLAObjects constructor.

getGapConfig

public final GapConfig getGapConfig()

Get the GapConfig for direct manipulation.

Returns:
getTParseConfig().getGapConfig()

getLineNumber

public final int getLineNumber()

Get the current line number.

Returns:
-1 if the sb_line, as passed into the constructor, is null, or the line was not null, but analysis has been completed.
i_lineNumber Exactly as provided to the constructor.

getTemplateName

public final String getTemplateName()

Get the name of the template being analyzed.

Returns:
null if sb_line, as passed into the constructor, is null, or the line was not null, but analysis has been completed.
s_templateName Exactly as provided to the constructor.

getCharArrIdx

public final int getCharArrIdx()

Get the current character array index.

Returns:
The array index of the character immediately following the surrounding-text-and-gap about to be retrieved, or -1 if isDoneAnalyzing equals true.


isDoneAnalyzing

public final boolean isDoneAnalyzing()

Has this line been completely analyzed?

Returns:
true If all surrounding-texts-and-gaps and the final surrounding text have been retrieved.

Sanity check: When this returns true, hasAnotherGap equals false, getTemplateName equals null and getLineNumber and getCharArrIdx equal -1.

false If there is at least one more surrounding-text-and-gap, or the final surrounding text has not yet been retrieved.

Sanity chock: When this returns false, hasAnotherGap may equal either true or false, getTemplateName and getLineNumber equal [whatever was provided to the constructor] and and getCharArrIdx equals [something greater than -1].


hasAnotherGap

public final boolean hasAnotherGap()

Is there another gap in the line, yet to be retrieved?

Returns:
true If there is another surrounding-text-and-gap to be retrieved. isDoneAnalyzing will equal false in this case.
false If there are no more gaps to be retrieved for this line. isDoneAnalyzing may equal either true or false in this case.

getNextSurrTxtAndGap

public s_s getNextSurrTxtAndGap()
                         throws TemplateFormatException

Get the next surrounding text and gap.

Returns:
a s_s, where the sOne element is the surrounding text, and sTwo is the gap name. Neither will ever be null, and the gap name will never be empty string.
Throws:
AssertException - If hasAnotherGap equals false.

getFinalSurrTxt

public String getFinalSurrTxt()

Get the final surrounding text, after all surrounding-text-and-gaps have been retrieved.

Throws:
AssertException - If either hasAnotherGap or isDoneAnalyzing equal true.



Copyright 1997-2003, Jeff Epstein, All Rights Reserved. See top of source code files for copyright notice.

 

http://sourceforge.net/projects/xbnjava

 

SourceForge.net Logo