| 1 package org.jicengine.expression; 2 3 import org.jicengine.operation.FieldValueOperation; 4 5 import org.jicengine.operation.Operation; 6 7 14 15 public class FieldValueParser implements Parser { 16 17 Parser elementParser; 18 19 public FieldValueParser(Parser elementParser) 20 { 21 this.elementParser = elementParser; 22 } 23 24 public Operation parse(String expression) throws SyntaxException 25 { 26 char[] chars = expression.toCharArray(); 27 int fieldNameSeparatorIndex = -1; 28 for (int i = chars.length-1; 0 <= i; i--) { 29 if( chars[i] == METHOD_PARAMS_END || chars[i] == METHOD_PARAMS_START || chars[i] == ARRAY_LENGTH_START || chars[i] == ARRAY_LENGTH_END){ 30 break; 33 } 34 else if( chars[i] == OPERATION_SEPARATOR ){ 35 fieldNameSeparatorIndex = i; 37 break; 38 } 39 else { 40 continue; 41 } 42 } 43 44 if( fieldNameSeparatorIndex != -1 ){ 45 String actorName = expression.substring(0, fieldNameSeparatorIndex); 47 String fieldName = expression.substring(fieldNameSeparatorIndex+1); 48 49 Operation actor = elementParser.parse(actorName); 50 51 return new FieldValueOperation(expression, actor, fieldName); 52 } 53 else { 54 return null; 57 } 58 } 59 } 60 | Popular Tags |