echoxul.util.bean
Class ExpressionParser
java.lang.Object
echoxul.util.bean.ExpressionParser
- public class ExpressionParser
- extends java.lang.Object
The ExpressionParser class is responsible for parsing simple
expressions into an Object value suitable for assignment.
The expression syntax is quite simple and is constituted
by the following types:
- String: Represented by text within double quotes
- Integer: Represented by a sequence of digits
- Boolean: Represented by the word "true" or "false"
- Object: Represented by a word followed by open parenthesis,
a comma delimitted parameter list and a closing parenthesis.
- Object Field: Represented by a word followed by a dot and the field name
Examples:
- String: "This is a string"
- Integer: 1234
- Boolean: true
- Object: color(1, 2, 3)
- Object: color(12345)
- Object Field: color.RED
This class also has support for reading an entire set of properties
in standard java properties file format.
- Author:
- Terry Laurenzo
Method Summary |
java.lang.Object |
parseExpression(java.lang.String expr)
Parse an expression into a value. |
java.util.Map |
parseProperties(java.io.Reader in)
Parse from a Reader that represents a properties file. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ExpressionParser
public ExpressionParser()
parseProperties
public java.util.Map parseProperties(java.io.Reader in)
throws java.lang.IllegalArgumentException,
java.io.IOException
- Parse from a Reader that represents a properties file.
This will return a Map of all associations in the file.
The syntax is identical to standard java property files
- Throws:
java.lang.IllegalArgumentException
java.io.IOException
parseExpression
public java.lang.Object parseExpression(java.lang.String expr)
throws java.lang.IllegalArgumentException
- Parse an expression into a value. Throw an IllegalArgumentException
on syntax error.
- Throws:
java.lang.IllegalArgumentException
Copyright © 2004 Terry Laurenzo. All Rights Reserved.