public class CharacterFormatParser
extends java.lang.Object
parse(String)
method along with a set of callback methods,
each callback is called when a special character of the corresponding type is parsed.
The parse(String)
method is also responsible for checking the
Progress character format validity.
By default, all callbacks do nothing, they are expected to be re-defined in subclasses.
This class may be used directly for:
parse(String)
method.
parse(String)
method return value.Modifier and Type | Class and Description |
---|---|
private static interface |
CharacterFormatParser.DeferredAction
Interface for all deferred actions.
|
private static class |
CharacterFormatParser.ParseState
The state constants for the Progress format string parser.
|
Constructor and Description |
---|
CharacterFormatParser() |
Modifier and Type | Method and Description |
---|---|
private static void |
characterFormatIsIncomplete(java.lang.String format)
Helper method to process the error 164 error ("incomplete format string").
|
private static void |
genValueCannotBeDisplayedError(java.lang.String format)
Helper method to the
DisplayFormat.genValueCannotBeDisplayedError(String, String) |
private CharacterFormatParser.DeferredAction |
getActionForACharacter(char ch,
int position,
java.lang.String fmt)
Check character position and map a character to an action.
|
int |
parse(java.lang.String format)
Do the parse, call all 'visitXXX' callback methods.
|
protected void |
visitAlphanum(int repeatCount)
This method is called by
parse(String) for each occurrence of
the 'n' (alphanumeric) special character in format string. |
protected void |
visitAnyChar(int repeatCount)
This method is called by
parse(String) for each occurrence of
the 'x' (any character) special character in format string. |
protected void |
visitDigit(int repeatCount)
This method is called by
parse(String) for each occurrence of
the '9' (the digit) special character in format string. |
protected void |
visitEscape()
This method is called by
parse(String) for each occurrence of
the escape character '~' in format string. |
protected void |
visitFillChar(char ch)
This method is called by
parse(String) for each occurrence of
a non-special character in format string. |
protected void |
visitLetter(int repeatCount)
This method is called by
parse(String) for each occurrence of
the 'a' (letter) special character in format string. |
protected void |
visitUpperLetter(int repeatCount)
This method is called by
parse(String) for each occurrence of
the '!' (upcase) special character in format string. |
public final int parse(java.lang.String format)
format
- the format string to parseprotected void visitEscape()
parse(String)
for each occurrence of
the escape character '~' in format string.
By default this method does nothing.protected void visitFillChar(char ch)
parse(String)
for each occurrence of
a non-special character in format string.
By default this method does nothing.ch
- the format characterprotected void visitDigit(int repeatCount)
parse(String)
for each occurrence of
the '9' (the digit) special character in format string.
By default this method does nothing.repeatCount
- the special character repeat countprotected void visitUpperLetter(int repeatCount)
parse(String)
for each occurrence of
the '!' (upcase) special character in format string.
By default this method does nothing.repeatCount
- the special character repeat countprotected void visitLetter(int repeatCount)
parse(String)
for each occurrence of
the 'a' (letter) special character in format string.
By default this method does nothing.repeatCount
- the special character repeat countprotected void visitAlphanum(int repeatCount)
parse(String)
for each occurrence of
the 'n' (alphanumeric) special character in format string.
By default this method does nothing.repeatCount
- the special character repeat countprotected void visitAnyChar(int repeatCount)
parse(String)
for each occurrence of
the 'x' (any character) special character in format string.
By default this method does nothing.repeatCount
- the special character repeat countprivate static void genValueCannotBeDisplayedError(java.lang.String format)
DisplayFormat.genValueCannotBeDisplayedError(String, String)
format
- the offending format stringprivate static final void characterFormatIsIncomplete(java.lang.String format)
format
- the format string.private CharacterFormatParser.DeferredAction getActionForACharacter(char ch, int position, java.lang.String fmt)
Otherwise execute the visitFillChar(char)
, passing the character as the argument,
and return null
.
ch
- the character to dispatchposition
- the character position to check against the maximum length of 4gl characterfmt
- the currently parsed format for error reporting.true
if the character provided is a special formatting character