01: package org.jicengine.expression;
02:
03: import org.jicengine.operation.*;
04: import org.jicengine.element.impl.FactoryElementCompiler;
05:
06: /**
07: * <p> </p>
08: *
09: * <p> </p>
10: *
11: * <p> </p>
12: *
13: * <p> </p>
14: *
15: * @author timo laitinen
16: */
17: public class FactoryInvocationParser implements Parser {
18:
19: public static final String FACTORY_NAME_PREFIX = "jic::";
20:
21: private Parser argumentsParser;
22:
23: public FactoryInvocationParser(Parser argumentsParser) {
24: this .argumentsParser = argumentsParser;
25: }
26:
27: /**
28: * @param expression String
29: */
30: public Operation parse(String expression) throws SyntaxException {
31: if (expression.startsWith(FACTORY_NAME_PREFIX)) {
32: // looks promising..
33: int parameterStart = expression
34: .indexOf(InvocationParser.METHOD_PARAMS_START);
35: int parameterEnd = expression
36: .indexOf(InvocationParser.METHOD_PARAMS_END);
37:
38: String factoryName = expression
39: .substring(0, parameterStart);
40: String argumentsExpression = expression.substring(
41: parameterStart + 1, parameterEnd);
42:
43: Operation[] arguments = InvocationParser.parseArguments(
44: this .argumentsParser, argumentsExpression);
45:
46: return new FactoryInvocationOperation(factoryName,
47: arguments);
48: } else {
49: return null;
50: }
51: }
52:
53: }
|