01: package org.jicengine.expression;
02:
03: import org.jicengine.operation.*;
04:
05: /**
06: * <p> </p>
07: *
08: * <p> </p>
09: *
10: * <p> </p>
11: *
12: * <p> </p>
13: *
14: * @author timo laitinen
15: */
16: public class BuildParameterParser implements Parser {
17:
18: public static final String PREFIX = "param::";
19:
20: /**
21: * @return Parsers may return null in order to signal 'abort' i.e.
22: *
23: * @return Parsers may return null in order to signal 'abort' i.e. if the
24: * syntax of the expression is not understood by the parser
25: * implementation. i.e. NumberParser returns null if the expression is a
26: * string-expression..
27: * @throws SyntaxException
28: * @param expression String
29: */
30: public Operation parse(String expression) throws SyntaxException {
31: if (expression.startsWith(PREFIX)) {
32: char[] chars = expression.substring(PREFIX.length() + 2)
33: .toCharArray();
34: for (int i = 0; i < chars.length; i++) {
35: if (!Character.isLetterOrDigit(chars[i])
36: && chars[i] != '.' && chars[i] != '-') {
37: return null;
38: }
39: }
40: return new VariableValueOperation(expression);
41: } else {
42: return null;
43: }
44: }
45: }
|