|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sibvisions.util.type.StringParser
public class StringParser
The StringParser is a very simple text parser, that just implements
splitting a single line into fields.
| Constructor Summary | |
|---|---|
StringParser(char pSeparator)
Creates a new instance of StringParser with supplied separator. |
|
StringParser(char pSeparator,
char pQuote)
Creates a new instance of StringParser with supplied separator and quote char. |
|
StringParser(char pSeparator,
char pQuote,
char pEscape)
Creates a new instance of StringParser with supplied separator, quote and escape character. |
|
| Method Summary | |
|---|---|
protected boolean |
isAllWhiteSpace(CharSequence pText)
Gets whether the given text only contains whitespaces or is empty. |
boolean |
isIgnoreLeadingWhiteSpace()
Gets whether leading whitespaces should be ignored. |
boolean |
isMustQuote()
Gets whether the strict quote mode is enabled. |
protected boolean |
isNextCharacterEscapable(String pText,
boolean pInQuotes,
int pIndex)
Gets whether the next character is an escape. |
boolean |
isPending()
Gets whether parsing has open fields from last call(s). |
boolean |
isRemoveQuotes()
Gets whether leading and trailing quotes will be removed from the fields. |
String[] |
parse(String pText)
Parse a line that contains one filed. |
String[] |
parse(String pText,
boolean pMulti)
Parse a line with multi field support. |
void |
setIgnoreLeadingWhiteSpace(boolean pIgnore)
Sets whether leading whitespaces should be ignored. |
void |
setMustQuote(boolean pMustQuote)
Sets whether a field must be in quotes to be a valid field. |
void |
setRemoveQuotes(boolean pIgnoreQuotes)
Sets whether leading and trailing quotes should be removed from the fields. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public StringParser(char pSeparator)
StringParser with supplied separator. The default
quote character & and escape character \ will be used.
pSeparator - the delimiter to use for separating entries
public StringParser(char pSeparator,
char pQuote)
StringParser with supplied separator and quote char.
The default escape character \ will be used.
pSeparator - the delimiter to use for separating entriespQuote - the character to use for quoted elements
public StringParser(char pSeparator,
char pQuote,
char pEscape)
StringParser with supplied separator, quote and escape character.
pSeparator - the delimiter to use for separating entriespQuote - the character to use for quoted elementspEscape - the character to use for escaping a separator or quote| Method Detail |
|---|
public String[] parse(String pText)
throws IOException
pText - the text to parse
IOException - if parsing fails
public String[] parse(String pText,
boolean pMulti)
throws IOException
pText - the text to parsepMulti - whether the text contains more than one field
IOException - if parsing failspublic boolean isPending()
protected boolean isNextCharacterEscapable(String pText,
boolean pInQuotes,
int pIndex)
pText - the current textpInQuotes - true if the current context is quotedpIndex - current index in text
true if the next character is a quoteprotected boolean isAllWhiteSpace(CharSequence pText)
pText - a sequence of characters to examine
true if every character in the sequence is whitespacepublic void setRemoveQuotes(boolean pIgnoreQuotes)
pIgnoreQuotes - true to remove quotes from found fields,
false if found should contain leading and trailing quotespublic boolean isRemoveQuotes()
true if leading and trailing quotes will be removed,
false otherwisepublic void setMustQuote(boolean pMustQuote)
pMustQuote - true to enable strict quote mode, false bo
allow mixed fieldspublic boolean isMustQuote()
true if strict quote mode is enabled, false otherwisesetMustQuote(boolean)public void setIgnoreLeadingWhiteSpace(boolean pIgnore)
pIgnore - true to ignore leading whitespaces,
false otherwisepublic boolean isIgnoreLeadingWhiteSpace()
true if leading whitespaces will be ignored,
false otherwise
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||