KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jicengine > expression > BuildParameterParser


1 package org.jicengine.expression;
2
3 import org.jicengine.operation.*;
4
5 /**
6  * <p> </p>
7  *
8  * <p> </p>
9  *
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 JavaDoc 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 JavaDoc expression) throws SyntaxException
31     {
32         if (expression.startsWith(PREFIX)) {
33             char[] chars = expression.substring(PREFIX.length()+2).toCharArray();
34             for (int i = 0; i < chars.length; i++) {
35                 if( !Character.isLetterOrDigit(chars[i]) && chars[i] != '.' && chars[i] != '-' ){
36                     return null;
37                 }
38             }
39             return new VariableValueOperation(expression);
40         }
41         else {
42             return null;
43         }
44     }
45 }
46
Popular Tags