KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.jicengine.expression;
2
3 import org.jicengine.operation.VariableValueOperation;
4 import org.jicengine.operation.Operation;
5
6 /**
7  *
8  * <p>
9  * Copyright (C) 2004 Timo Laitinen
10  * </p>
11  * @author .timo
12  */

13
14 public class VariableParser implements Parser {
15
16     public Operation parse(String JavaDoc expression) throws SyntaxException
17     {
18         char[] chars = expression.toCharArray();
19         char character;
20
21         if(Character.isJavaIdentifierStart(chars[0])) {
22             for(int i = 1; i < chars.length; i++) {
23                 if(!Character.isJavaIdentifierPart(chars[i])) {
24                     return null;
25                 }
26             }
27             return new VariableValueOperation(expression);
28         }
29         else {
30             return null;
31         }
32
33
34         /*
35         if(Character.isLetter(chars[0]) && chars[0] != '-' ) {
36             for(int i = 1; i < chars.length; i++) {
37                 character = chars[i];
38                 if(character == OPERATION_SEPARATOR) {
39                     return null;
40                 }
41                 else if(character == METHOD_PARAMS_START || character == METHOD_PARAMS_END) {
42                     return null;
43                 }
44                 else {
45                     // continue..
46                 }
47             }
48             return new VariableValueOperation(expression);
49         }
50         else {
51             return null;
52         }
53         */

54     }
55 }
56
Popular Tags