Modified: ode/trunk/bpel-ql/src/main/java/org/apache/ode/ql/tree/nodes/Query.java URL: http://svn.apache.org/viewvc/ode/trunk/bpel-ql/src/main/java/org/apache/ode/ql/tree/nodes/Query.java?rev=659307&r1=659306&r2=659307&view=diff ============================================================================== --- ode/trunk/bpel-ql/src/main/java/org/apache/ode/ql/tree/nodes/Query.java (original) +++ ode/trunk/bpel-ql/src/main/java/org/apache/ode/ql/tree/nodes/Query.java Thu May 22 16:25:57 2008 @@ -1,93 +1,93 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.ode.ql.tree.nodes; - -import java.util.Collection; - -public class Query implements Node { - private static final long serialVersionUID = -1889820969391077174L; - private final Collection<Object> childs; - private final OrderBy order; - private Limit limit; - - - /** - * @param childs - * @param order - * @param limit - */ - public Query(final Collection<Object> childs, final OrderBy order, Limit limit) { - super(); - this.childs = childs; - this.order = order; - this.limit = limit; - } - - - /** - * @param childs - * @param order - */ - public Query(final Collection<Object> childs, final OrderBy order) { - super(); - this.childs = childs; - this.order = order; - } - - - /** - * @param childs - */ - public Query(final Collection<Object> childs) { - this(childs, null); - } - - - /** - * @return the childs - */ - public Collection<Object> getChilds() { - return childs; - } - - - /** - * @return the order - */ - public OrderBy getOrder() { - return order; - } - - - /** - * @return the limit - */ - public Limit getLimit() { - return limit; - } - - - /** - * @param limit the limit to set - */ - public void setLimit(Limit limit) { - this.limit = limit; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.ode.ql.tree.nodes; + +import java.util.Collection; + +public class Query implements Node { + private static final long serialVersionUID = -1889820969391077174L; + private final Collection<Object> childs; + private final OrderBy order; + private Limit limit; + + + /** + * @param childs + * @param order + * @param limit + */ + public Query(final Collection<Object> childs, final OrderBy order, Limit limit) { + super(); + this.childs = childs; + this.order = order; + this.limit = limit; + } + + + /** + * @param childs + * @param order + */ + public Query(final Collection<Object> childs, final OrderBy order) { + super(); + this.childs = childs; + this.order = order; + } + + + /** + * @param childs + */ + public Query(final Collection<Object> childs) { + this(childs, null); + } + + + /** + * @return the childs + */ + public Collection<Object> getChilds() { + return childs; + } + + + /** + * @return the order + */ + public OrderBy getOrder() { + return order; + } + + + /** + * @return the limit + */ + public Limit getLimit() { + return limit; + } + + + /** + * @param limit the limit to set + */ + public void setLimit(Limit limit) { + this.limit = limit; + } +}
Modified: ode/trunk/bpel-ql/src/main/java/org/apache/ode/ql/tree/nodes/Value.java URL: http://svn.apache.org/viewvc/ode/trunk/bpel-ql/src/main/java/org/apache/ode/ql/tree/nodes/Value.java?rev=659307&r1=659306&r2=659307&view=diff ============================================================================== --- ode/trunk/bpel-ql/src/main/java/org/apache/ode/ql/tree/nodes/Value.java (original) +++ ode/trunk/bpel-ql/src/main/java/org/apache/ode/ql/tree/nodes/Value.java Thu May 22 16:25:57 2008 @@ -1,61 +1,61 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.ode.ql.tree.nodes; - -public class Value<V> implements Node { - private static final long serialVersionUID = -533404312907890996L; - - private V value; - - /** - * @param value - */ - public Value(final V value) { - super(); - this.value = value; - } - - - /** - * - */ - public Value() { - super(); - } - - - /** - * @return the value - */ - public V getValue() { - return value; - } - - - /** - * @param value the value to set - */ - public void setValue(V value) { - this.value = value; - } - - - -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.ode.ql.tree.nodes; + +public class Value<V> implements Node { + private static final long serialVersionUID = -533404312907890996L; + + private V value; + + /** + * @param value + */ + public Value(final V value) { + super(); + this.value = value; + } + + + /** + * + */ + public Value() { + super(); + } + + + /** + * @return the value + */ + public V getValue() { + return value; + } + + + /** + * @param value the value to set + */ + public void setValue(V value) { + this.value = value; + } + + + +} Modified: ode/trunk/bpel-ql/src/main/java/org/apache/ode/ql/tree/nodes/ValuesHelper.java URL: http://svn.apache.org/viewvc/ode/trunk/bpel-ql/src/main/java/org/apache/ode/ql/tree/nodes/ValuesHelper.java?rev=659307&r1=659306&r2=659307&view=diff ============================================================================== --- ode/trunk/bpel-ql/src/main/java/org/apache/ode/ql/tree/nodes/ValuesHelper.java (original) +++ ode/trunk/bpel-ql/src/main/java/org/apache/ode/ql/tree/nodes/ValuesHelper.java Thu May 22 16:25:57 2008 @@ -1,35 +1,35 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.ode.ql.tree.nodes; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; - -public class ValuesHelper { - public static Collection extract(Collection values) { - Collection<Object> result = new ArrayList<Object>(values.size()); - for(Iterator iter = values.iterator();iter.hasNext();) { - Value value = (Value)iter.next(); - result.add(value.getValue()); - } - return result; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.ode.ql.tree.nodes; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; + +public class ValuesHelper { + public static Collection extract(Collection values) { + Collection<Object> result = new ArrayList<Object>(values.size()); + for(Iterator iter = values.iterator();iter.hasNext();) { + Value value = (Value)iter.next(); + result.add(value.getValue()); + } + return result; + } +} Modified: ode/trunk/bpel-ql/src/main/jjtree/ql.jjt URL: http://svn.apache.org/viewvc/ode/trunk/bpel-ql/src/main/jjtree/ql.jjt?rev=659307&r1=659306&r2=659307&view=diff ============================================================================== --- ode/trunk/bpel-ql/src/main/jjtree/ql.jjt (original) +++ ode/trunk/bpel-ql/src/main/jjtree/ql.jjt Thu May 22 16:25:57 2008 @@ -1,224 +1,224 @@ -options { - MULTI=true; - NODE_DEFAULT_VOID=true; - STATIC=false; -} - -PARSER_BEGIN(QLParser) - -package org.apache.ode.ql.jcc; - -import java.io.*; - -class QLParser { -} - -PARSER_END(QLParser) - - -SKIP : -{ - " " -| "\t" -| "\n" -| "\r" -} - -TOKEN : -{ - < LESS: "<" > -| - < GREATER: ">" > -| - < LE: "<=" > -| - < GE: ">=" > -| - < IN: "in" > -| - < LIKE: "like" > -| - < AND: "and" > -| - < OR: "or" > -| - < EQUAL: "=" > -| - < ORDER_BY: "order" (<WHITESPACE>)+ "by" (<WHITESPACE>)+ > -| - < ORDER_TYPE: "asc" | "desc" > -| - < PARAMETER_CHAR: "?" > -| - < LIMIT: "limit" (<WHITESPACE>)+ > -| - < NUMBER: (["0"-"9"])+ > -| - < PROPERTY: ("$")("{"<NAMESPACE>"}")?(<QNAME_NAME>) > -| - < #NAMESPACE: <LETTER>(<LETTER> | <DIGIT>)* > -| - < #QNAME_NAME: <LETTER>(<LETTER> | <DIGIT>)* > -| - < FIELD: <LETTER>(<LETTER> | <DIGIT>)* > -| - < VALUE: "\"" (~["\""])* "\"" > -| - < #LETTER: ["_","-",".","a"-"z","A"-"Z"] > -| - < #SPEC_CHAR: ["*","&","?",":","%"] > -| - < #DIGIT: ["0","1","2","3","4","5","6","7","8","9"] > -| - < #WHITESPACE: [" ", "\t", "\n", "\r"] > - -} - -ASTStart start() #Start : {} -{ - - Query() - { return jjtThis; } -} - -void Query() : {} -{ - [LogicExpression()] [OrderByExpression()] [Limit()]<EOF> -} -void Limit() #Limit : -{ - Token t; -} -{ - (<LIMIT>) - ( - t=<NUMBER> { - jjtn000.setNumber(t.image); - } - ) -} -void LogicExpression() : {} -{ - ORExpression() -} -void OrderByExpression() #OrderBy : {} -{ - <ORDER_BY> OrderByField() ("," OrderByField())* -} -void OrderByField() #OrderByField : {} -{ - Field() (OrderType())? -} -void OrderType() #OrderType : { - Token t; -} -{ - t=<ORDER_TYPE> { - jjtn000.setValue(t.image); - } -} -void ORExpression() : {} -{ - ( - ANDExpression() (<OR> ANDExpression())* - )#Or(>1) -} - -void ANDExpression() : {} -{ - ( - CompareExpression() (<AND> CompareExpression())* - )#And(>1) -} - -void CompareExpression() : {} -{ - Identifier() - ( - Equal() - | - LessExpression() - | - GreaterExpression() - | - LEExpression() - | - GEExpression() - | - InExpression() - | - Like() - ) -| - "(" LogicExpression() ")" -} - -void Equal() #Equal(2) : {} -{ - <EQUAL> Value() -} -void Like() #Like(2) : {} -{ - <LIKE> Value() -} -void LessExpression() #Less(2) : {} -{ - <LESS> Value() -} -void GreaterExpression() #Greater(2) : {} -{ - <GREATER> Value() -} -void LEExpression() #LE(2) : {} -{ - <LE> Value() -} -void GEExpression() #GE(2) : {} -{ - <GE> Value() -} -void InExpression() #In(2) : {} -{ - <IN> InValuesExpression() -} -void InValuesExpression() #InValues : {} -{ - "(" [(Value() ("," Value())*)] ")" -} -void Identifier() : {} -{ - Field() | Property() -} - -void Field() #Field : -{ - Token t; -} -{ - t=<FIELD> - { - jjtn000.setName(t.image); - } - -} -void Property() #Property : -{ - Token t; -} -{ - t=<PROPERTY>{ - jjtn000.setName(t.image); - } -} -void Value() #Value : -{ - Token t; -} -{ - t=<VALUE> - { - jjtn000.setValue(t.image); - } -| - <PARAMETER_CHAR> -} +options { + MULTI=true; + NODE_DEFAULT_VOID=true; + STATIC=false; +} + +PARSER_BEGIN(QLParser) + +package org.apache.ode.ql.jcc; + +import java.io.*; + +class QLParser { +} + +PARSER_END(QLParser) + + +SKIP : +{ + " " +| "\t" +| "\n" +| "\r" +} + +TOKEN : +{ + < LESS: "<" > +| + < GREATER: ">" > +| + < LE: "<=" > +| + < GE: ">=" > +| + < IN: "in" > +| + < LIKE: "like" > +| + < AND: "and" > +| + < OR: "or" > +| + < EQUAL: "=" > +| + < ORDER_BY: "order" (<WHITESPACE>)+ "by" (<WHITESPACE>)+ > +| + < ORDER_TYPE: "asc" | "desc" > +| + < PARAMETER_CHAR: "?" > +| + < LIMIT: "limit" (<WHITESPACE>)+ > +| + < NUMBER: (["0"-"9"])+ > +| + < PROPERTY: ("$")("{"<NAMESPACE>"}")?(<QNAME_NAME>) > +| + < #NAMESPACE: <LETTER>(<LETTER> | <DIGIT>)* > +| + < #QNAME_NAME: <LETTER>(<LETTER> | <DIGIT>)* > +| + < FIELD: <LETTER>(<LETTER> | <DIGIT>)* > +| + < VALUE: "\"" (~["\""])* "\"" > +| + < #LETTER: ["_","-",".","a"-"z","A"-"Z"] > +| + < #SPEC_CHAR: ["*","&","?",":","%"] > +| + < #DIGIT: ["0","1","2","3","4","5","6","7","8","9"] > +| + < #WHITESPACE: [" ", "\t", "\n", "\r"] > + +} + +ASTStart start() #Start : {} +{ + + Query() + { return jjtThis; } +} + +void Query() : {} +{ + [LogicExpression()] [OrderByExpression()] [Limit()]<EOF> +} +void Limit() #Limit : +{ + Token t; +} +{ + (<LIMIT>) + ( + t=<NUMBER> { + jjtn000.setNumber(t.image); + } + ) +} +void LogicExpression() : {} +{ + ORExpression() +} +void OrderByExpression() #OrderBy : {} +{ + <ORDER_BY> OrderByField() ("," OrderByField())* +} +void OrderByField() #OrderByField : {} +{ + Field() (OrderType())? +} +void OrderType() #OrderType : { + Token t; +} +{ + t=<ORDER_TYPE> { + jjtn000.setValue(t.image); + } +} +void ORExpression() : {} +{ + ( + ANDExpression() (<OR> ANDExpression())* + )#Or(>1) +} + +void ANDExpression() : {} +{ + ( + CompareExpression() (<AND> CompareExpression())* + )#And(>1) +} + +void CompareExpression() : {} +{ + Identifier() + ( + Equal() + | + LessExpression() + | + GreaterExpression() + | + LEExpression() + | + GEExpression() + | + InExpression() + | + Like() + ) +| + "(" LogicExpression() ")" +} + +void Equal() #Equal(2) : {} +{ + <EQUAL> Value() +} +void Like() #Like(2) : {} +{ + <LIKE> Value() +} +void LessExpression() #Less(2) : {} +{ + <LESS> Value() +} +void GreaterExpression() #Greater(2) : {} +{ + <GREATER> Value() +} +void LEExpression() #LE(2) : {} +{ + <LE> Value() +} +void GEExpression() #GE(2) : {} +{ + <GE> Value() +} +void InExpression() #In(2) : {} +{ + <IN> InValuesExpression() +} +void InValuesExpression() #InValues : {} +{ + "(" [(Value() ("," Value())*)] ")" +} +void Identifier() : {} +{ + Field() | Property() +} + +void Field() #Field : +{ + Token t; +} +{ + t=<FIELD> + { + jjtn000.setName(t.image); + } + +} +void Property() #Property : +{ + Token t; +} +{ + t=<PROPERTY>{ + jjtn000.setName(t.image); + } +} +void Value() #Value : +{ + Token t; +} +{ + t=<VALUE> + { + jjtn000.setValue(t.image); + } +| + <PARAMETER_CHAR> +} Modified: ode/trunk/bpel-ql/src/test/java/org/apache/ode/ql/SyntaxTest.java URL: http://svn.apache.org/viewvc/ode/trunk/bpel-ql/src/test/java/org/apache/ode/ql/SyntaxTest.java?rev=659307&r1=659306&r2=659307&view=diff ============================================================================== --- ode/trunk/bpel-ql/src/test/java/org/apache/ode/ql/SyntaxTest.java (original) +++ ode/trunk/bpel-ql/src/test/java/org/apache/ode/ql/SyntaxTest.java Thu May 22 16:25:57 2008 @@ -1,78 +1,78 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.ode.ql; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; - -import junit.framework.TestCase; - -import org.apache.ode.ql.tree.Builder; -import org.apache.ode.ql.tree.BuilderFactory; - -public class SyntaxTest extends TestCase { - - private final static String TESTS_DIR = "target/test-classes"; - - private File[] casesFiles = new File(TESTS_DIR).listFiles(); - - /** - * @see junit.framework.TestCase#setUp() - */ - @Override - protected void setUp() throws Exception { - super.setUp(); - - casesFiles = new File(System.getProperty("baseDir")).listFiles(); - //casesFiles = new File(TESTS_DIR).listFiles(); - } - - public void test() throws Exception { - for(File caseFile : casesFiles) { - if (caseFile.isFile()) { - doTestCaseFile(caseFile); - } - } - } - - public void doTestCaseFile(File caseFile) throws Exception { - BufferedReader reader = new BufferedReader(new FileReader(caseFile)); - try { - String testCase; - while((testCase = reader.readLine())!=null) { - try { - doTest(testCase); - }catch(Throwable ex) { - throw new Exception("Failure in "+caseFile.toString()+":" + testCase + " case.", ex); - } - - } - }finally { - reader.close(); - } - } - - public void doTest(String query) throws Exception { - Builder<String> builder = BuilderFactory.getInstance().createBuilder(); - @SuppressWarnings("unused") - final org.apache.ode.ql.tree.nodes.Node rootNode = builder.build(query); - } - -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.ode.ql; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; + +import junit.framework.TestCase; + +import org.apache.ode.ql.tree.Builder; +import org.apache.ode.ql.tree.BuilderFactory; + +public class SyntaxTest extends TestCase { + + private final static String TESTS_DIR = "target/test-classes"; + + private File[] casesFiles = new File(TESTS_DIR).listFiles(); + + /** + * @see junit.framework.TestCase#setUp() + */ + @Override + protected void setUp() throws Exception { + super.setUp(); + + casesFiles = new File(System.getProperty("baseDir")).listFiles(); + //casesFiles = new File(TESTS_DIR).listFiles(); + } + + public void test() throws Exception { + for(File caseFile : casesFiles) { + if (caseFile.isFile()) { + doTestCaseFile(caseFile); + } + } + } + + public void doTestCaseFile(File caseFile) throws Exception { + BufferedReader reader = new BufferedReader(new FileReader(caseFile)); + try { + String testCase; + while((testCase = reader.readLine())!=null) { + try { + doTest(testCase); + }catch(Throwable ex) { + throw new Exception("Failure in "+caseFile.toString()+":" + testCase + " case.", ex); + } + + } + }finally { + reader.close(); + } + } + + public void doTest(String query) throws Exception { + Builder<String> builder = BuilderFactory.getInstance().createBuilder(); + @SuppressWarnings("unused") + final org.apache.ode.ql.tree.nodes.Node rootNode = builder.build(query); + } + +}
