java.lang.Object
org.bzdev.util.ObjectParser.SourceParser
- All Implemented Interfaces:
ObjectParser<ObjectParser.Source>
- Enclosing interface:
- ObjectParser<T>
public static class ObjectParser.SourceParser
extends Object
implements ObjectParser<ObjectParser.Source>
Object parser that tags a string as being one that is likely to
be an ESP expression or statement.
This class is used by ObjectNamerLauncher
to distinguish strings that must be evaluated from strings that
should not be evaluated. For example, when using ObjectNamerLauncher
with YAML,
would be treated as an expression whose value is 30. By contrast,- = 10 + 20
would be interpretted as the string "= 10 + 20". This is actually handled in two passes. During the first, sequences that could be ESP expressions or statements are replaced with objects whose type is- !!str = 10 + 20
ObjectParser.Source
containing the expression in string
form. In the second pass, each ObjectParser.Source
object is evaluated
as an ESP expression or statement. This prevents the second case,
where "= 10 + 20" was meant to be a string, from being replaced
with the value 30.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.bzdev.util.ObjectParser
ObjectParser.Exception, ObjectParser.Source, ObjectParser.SourceParser
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Determine if a string is syntactically valid.Parse a string and return the corresponding object.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.bzdev.util.ObjectParser
appliesTo
-
Constructor Details
-
SourceParser
Constructor.- Parameters:
ep
- the expression parser that will be used to evaluate to evaluate the source whenObjectParser.Source.evaluate()
is called for the first time.
-
-
Method Details
-
matches
Description copied from interface:ObjectParser
Determine if a string is syntactically valid.- Specified by:
matches
in interfaceObjectParser<ObjectParser.Source>
- Parameters:
string
- the string- Returns:
- true if the test succeeds; false if it fails
-
parse
Description copied from interface:ObjectParser
Parse a string and return the corresponding object.- Specified by:
parse
in interfaceObjectParser<ObjectParser.Source>
- Parameters:
s
- the string- Returns:
- the corresponding object
- Throws:
ObjectParser.Exception
- if the string could not be successfully parsed or the object could not be created
-