xbn.config
Class CRLineAnalyzer

java.lang.Object
  |
  +--xbn.XBNObject
        |
        +--xbn.config.CRLineAnalyzer

public class CRLineAnalyzer
extends XBNObject

Reads in and analyzes a single line from the source text for a ConfigReader. See ConfigReader.

It seems that, in a multi-live value ending on the LAST LINE of the file, the last value line is being ignored
Also, check how it behaves when the SECOND or subsequent lines have an unescaped control character in it. For example, an SQL query with an equals sign in the fourth line.

Source code:  CRLineAnalyzer.java.  Exmaple code:  See the example code for ConfigReaderFA.


Fields inherited from class xbn.XBNObject
bFALSE_IN_PRODUCTION, bTRUE_IN_PRODUCTION, sCNSTR, sES, sLINE_SEP
 
Constructor Summary
CRLineAnalyzer(StringBuffer sb_line, int i_lineNumber, int i_mlcStartLine, int i_varStartLine, StringOrBuffer sob_varStartName, char c_varStartDelim, Outputter optr_dbg, CRLAObjects crla_objects)
          Create a CRLineAnalyzer.
 
Method Summary
 char getDelimiter()
          Get the delimiter of the variable that was started on this line.
 int getMLCStartLine()
          At what line did the current multi-line comment start?
 String getName()
          Get the name of the variable that was started on this line.
 String getValue()
          Get the value of the variable existing on this line.
 int getVarStartLine()
          At which line did the current variable start?
 boolean hasName()
          Is this the first line in a variable?
 boolean hasValue()
          Does this line contain a line within a value?.
 boolean isStartLine()
          Is this line the beginning of a variable or comment?
 
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

CRLineAnalyzer

public CRLineAnalyzer(StringBuffer sb_line,
                      int i_lineNumber,
                      int i_mlcStartLine,
                      int i_varStartLine,
                      StringOrBuffer sob_varStartName,
                      char c_varStartDelim,
                      Outputter optr_dbg,
                      CRLAObjects crla_objects)
               throws ConfigFormatException

Create a CRLineAnalyzer.

Parameters:
sb_line - The current line, including the ending line separator. May not be null and may not contain the line separator at any point except the end. If this does not contain a line separator, this is assumed to be the very last line in the source text.
i_lineNumber - The line number that sb_line is in the source text. May not be less than one. For use in potential error messages.
i_mlcStartLine - The line number on which the current multi-line comment was started. If equal to -1, this line is not in the middle of a multi-line comment. Otherwise this is the line number in which the multi-line comment (in which sb_line is contained) began. Therefore, it may not be equal to or greater than i_lineNumber.
i_varStartLine - The line number on which the current variable's value (of which sb_line is the second or subsequent line) was started. If equal to -1, this line is not part of a value. Otherwise this is the line number in which a variable began. Therefore, it may not be equal to or greater than i_lineNumber.
ssb_varStartedName - The name of the variable started before this line. If i_varStartLine does not equal -1, this must be non-null. If i_varStartLine equals -1, this must be null. This is for potential error messages only, and is unrelated to what is returned by getName.
c_varStartDelim - The delimiter of the variable started before this line. If ssb_varStartedName equals null, this is ignored. This is for potential error messages only, and is unrelated to what is returned by getDelimiter.
crla_objects - Holds the internal objects used by this CRLineAnalyzer, including the CRConfig. May not be null.
optr_dbg - The Outputter to use for debugging. May not be null.
Throws:
ConfigFormatException - If any of the formatting rules for the source text of a ConfigReader are violated.
Method Detail

getMLCStartLine

public final int getMLCStartLine()

At what line did the current multi-line comment start?

Returns:
-1 If this line is not part of a multi-line comment.
A number between 1 and i_lineNumber, the line at which the current multi-line comment was started. (i_lineNumber, as provided to the constructor)

getVarStartLine

public final int getVarStartLine()

At which line did the current variable start?

Returns:
-1 If this line is not part of a variable.
A number between 1 and i_lineNumber, the line at which the current variable was started. (i_lineNumber, as provided to the constructor)

isStartLine

public final boolean isStartLine()

Is this line the beginning of a variable or comment?

Returns:
(getMLCStartLine() == i_lineNumber  ||
              getVarStartLine() == i_lineNumber  ||
              [is this line a single line comment?])

hasName

public final boolean hasName()

Is this the first line in a variable?

If it is, then the variable's name, delimiter and (first line of the) value can be retrieved with getName, getDelimiter and getValue.

Returns:
true If this is the first line in a variable.
false If not.

hasValue

public final boolean hasValue()

Does this line contain a line within a value?. If yes, get it with getValue.

Returns:
true If this line contains a value.
false If not.

getName

public final String getName()

Get the name of the variable that was started on this line.

Throws:
AssertException - If hasName equals false.

getDelimiter

public final char getDelimiter()

Get the delimiter of the variable that was started on this line.

Throws:
AssertException - If hasName equals false.

getValue

public final String getValue()

Get the value of the variable existing on this line.

Throws:
AssertException - If hasValue equals false.



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