- java.lang.Object
-
- com.pervasive.datarush.encoding.text.CharParser
-
- All Implemented Interfaces:
TokenParser
public class CharParser extends Object
A parser producing character token values from single-character strings. Longer strings are considered parse errors.
-
-
Constructor Summary
Constructors Constructor Description CharParser()Creates a new parser.CharParser(String nullIndicator)Creates a new parser.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetParseError()Whenparsemethod returns false this method can be used to retrieve the specific error message detailing why the parsing failed.booleanparse(String text)Parses the given text string into a token value.protected voidsetParseError(String msg)voidsetTarget(ScalarSettable output)Sets the buffer for holding parsed values.
-
-
-
Constructor Detail
-
CharParser
public CharParser()
Creates a new parser. Only empty strings are treated as null.
-
CharParser
public CharParser(String nullIndicator)
Creates a new parser. Empty strings and the specified text value are treated as null.- Parameters:
nullIndicator- the text value representing null
-
-
Method Detail
-
setTarget
public final void setTarget(ScalarSettable output)
Description copied from interface:TokenParserSets the buffer for holding parsed values. A reference to this container is held and accessed only when an formatting is requested.- Specified by:
setTargetin interfaceTokenParser- Parameters:
output- the value buffer in which to store parsed values
-
parse
public final boolean parse(String text)
Description copied from interface:TokenParserParses the given text string into a token value. If the parse succeeds, the result is stored in the target buffer. If it fails, the contents of the target buffer are unchanged and information regarding failure will be saved that is accessible by calling thegetParseErrormethod.- Specified by:
parsein interfaceTokenParser- Parameters:
text- text string to convert. Callers should not assume it is safe to passnull.- Returns:
trueif the parsing succeeded,falseotherwise.
-
setParseError
protected final void setParseError(String msg)
-
getParseError
public final String getParseError()
Description copied from interface:TokenParserWhenparsemethod returns false this method can be used to retrieve the specific error message detailing why the parsing failed. If the last parse was successful an empty string will be returned- Specified by:
getParseErrorin interfaceTokenParser- Returns:
- a message detailing any parse errors that occurred
during the last call to
parse.
-
-