KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.jicengine.expression;
2
3 import org.jicengine.operation.*;
4 import org.jicengine.element.impl.FactoryElementCompiler;
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 FactoryInvocationParser implements Parser {
17
18     public static final String JavaDoc FACTORY_NAME_PREFIX = "jic::";
19
20     private Parser argumentsParser;
21
22     public FactoryInvocationParser(Parser argumentsParser)
23     {
24         this.argumentsParser = argumentsParser;
25     }
26
27     /**
28      * @param expression String
29      */

30     public Operation parse(String JavaDoc expression) throws SyntaxException
31     {
32         if( expression.startsWith(FACTORY_NAME_PREFIX) ){
33             // looks promising..
34
int parameterStart = expression.indexOf(InvocationParser.METHOD_PARAMS_START);
35             int parameterEnd = expression.indexOf(InvocationParser.METHOD_PARAMS_END);
36
37             String JavaDoc factoryName = expression.substring(0,parameterStart);
38             String JavaDoc argumentsExpression = expression.substring(parameterStart+1,parameterEnd);
39
40             Operation[] arguments = InvocationParser.parseArguments(this.argumentsParser, argumentsExpression);
41
42             return new FactoryInvocationOperation(factoryName, arguments);
43         }
44         else {
45             return null;
46         }
47     }
48
49 }
50
Popular Tags