|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.openbp.common.string.parser.StringParser
public class StringParser
Generic string parser class. Provides methods to scan a string for identifiers, numbers etc.
| Constructor Summary | |
|---|---|
StringParser(java.lang.String strArg)
Constructor. |
|
| Method Summary | |
|---|---|
java.lang.String |
errorMsg(java.lang.String msg)
Returns an error message prefixed by the standard error prefix and a file/line specification (see the setFileName(java.lang.String) methods). |
char |
getChar()
Get the current character. |
char |
getChar(int i)
Get a character relative to the current position. |
java.lang.String |
getExtraIdentifierChars()
Gets the valid characters in identifiers beside letter, digit or underscore. |
java.lang.String |
getFileName()
Gets the file name. |
java.lang.String |
getIdentifier()
Get the identifier at the current position. |
int |
getLength()
Gets the length of the string. |
int |
getLineNr()
Gets the current line number. |
java.lang.String |
getNonWhitespace()
Get the text until the next white space at the current position. |
java.lang.String |
getNumber()
Get the number constant at the current position. |
java.util.List |
getOptionalParameters()
Get the parameters enclosed in () as an array of strings. |
java.lang.String |
getOptionArgument()
Get the string constant at the current position. |
int |
getPos()
Gets the current character position. |
java.lang.String |
getQualifiedIdentifier()
Get the (qualified) identifier at the current position. |
java.lang.String |
getSourceString()
Gets the source string. |
java.lang.String |
getString(char delimChar)
Get the string constant at the current position. |
java.lang.String |
getUntilEndOfLine()
Get the text until the end of the line. |
boolean |
isEnd()
Checks if we are at the end of the str. |
void |
nextChar()
Proceed to the next character. |
void |
nextChar(int n)
Skip characters. |
void |
printError(java.lang.String msg)
Prints an error message |
void |
reInit(java.lang.String str)
Re-inits the string parse. |
void |
restorePos(int pos)
Restores the current character position to a previously saved state. |
void |
rewindChar()
Rewind to the previous character. |
void |
rewindChar(int n)
Rewind several characters. |
void |
setExtraIdentifierChars(java.lang.String extraIdentifierChars)
Sets the valid characters in identifiers beside letter, digit or underscore. |
void |
setFileName(java.lang.String errorFileName)
Sets the file name to prepend to error messages. |
void |
setLineNr(int line)
Sets the current line number. |
void |
setPos(int pos)
Sets the current character position. |
boolean |
skipAssignmentOperator(java.lang.String ident)
Skips an assignemnt operator (" = ") |
void |
skipNoNewlineSpace()
Skips spaces and tabs only, no newlines |
void |
skipSpace()
Skips all white spaces. |
void |
skipUntil(java.lang.String pattern,
boolean skipPattern)
Skips until a pattern is found. |
boolean |
startsWith(java.lang.String pattern)
Check if 'pattern' matches the string at the current position. |
java.lang.String |
substring()
Performs a substring operation on the string from the current position up to the end of the string. |
java.lang.String |
substring(int begin)
Performs a substring operation on the string. |
java.lang.String |
substring(int begin,
int end)
Performs a substring operation on the string. |
void |
throwError(java.lang.String msg)
Throws an error runtime exception. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public StringParser(java.lang.String strArg)
strArg - String to parse| Method Detail |
|---|
public java.lang.String getExtraIdentifierChars()
public void setExtraIdentifierChars(java.lang.String extraIdentifierChars)
public void reInit(java.lang.String str)
str - String to parsepublic void setFileName(java.lang.String errorFileName)
errorFileName - File name or nullpublic char getChar()
public char getChar(int i)
i - The index of the character to return from the current position
public void nextChar()
public void nextChar(int n)
n - Number of characters to skippublic void rewindChar()
public void rewindChar(int n)
n - Number of characters to rewindpublic void skipSpace()
public void skipNoNewlineSpace()
public boolean skipAssignmentOperator(java.lang.String ident)
ident - The identifier before the operator (for error messages)
public boolean isEnd()
public int getPos()
public void setPos(int pos)
pos - The character position, starting with 0public void restorePos(int pos)
pos - The character position to restorepublic int getLength()
public java.lang.String getFileName()
setFileName(java.lang.String)public int getLineNr()
setFileName(java.lang.String)public void setLineNr(int line)
line - The new line numberpublic java.lang.String getUntilEndOfLine()
public java.lang.String getIdentifier()
public java.lang.String getQualifiedIdentifier()
public java.lang.String getNonWhitespace()
public java.lang.String getNumber()
public java.lang.String getOptionArgument()
public java.lang.String getString(char delimChar)
delimChar - Specifies the delimiter character that should enclose the returned string.public java.util.List getOptionalParameters()
public boolean startsWith(java.lang.String pattern)
pattern - The pattern to search for
public void skipUntil(java.lang.String pattern,
boolean skipPattern)
pattern - The pattern to search forskipPattern - true The pattern itself is skipped. The current position will
be at the first character after the pattern
public java.lang.String substring(int begin,
int end)
begin - The start indexend - The end index
public java.lang.String substring(int begin)
begin - The start index
public java.lang.String substring()
public void throwError(java.lang.String msg)
msg - The error messagepublic void printError(java.lang.String msg)
msg - The error messagepublic java.lang.String getSourceString()
public java.lang.String errorMsg(java.lang.String msg)
setFileName(java.lang.String) methods).
msg - The 'raw' error message
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||