Author: doogie
Date: Fri Nov 13 04:55:55 2009 New Revision: 835741 URL: http://svn.apache.org/viewvc?rev=835741&view=rev Log: No longer use jjtree to implement parsing. As a consequence of this, SQLSelect no longer depended on Parser, so javac wouldn't compile the generated code. SQLUtil was added to deal with this(this class will get more helpers later). Added: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/Parser.jj - copied, changed from r835737, ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/Parser.jjt ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/SQLUtil.java Removed: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/Parser.jjt Modified: ofbiz/trunk/framework/entity/build.xml ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/SQLSelect.java Modified: ofbiz/trunk/framework/entity/build.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/build.xml?rev=835741&r1=835740&r2=835741&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/build.xml (original) +++ ofbiz/trunk/framework/entity/build.xml Fri Nov 13 04:55:55 2009 @@ -53,7 +53,7 @@ <!-- ================================================================== --> <target name="gen-src"> - <ofbiz-jjtree dir="org/ofbiz/entity/sql" file="Parser"/> + <ofbiz-javacc dir="org/ofbiz/entity/sql" file="Parser"/> </target> <target name="classes" depends="prepare,gen-src"> Copied: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/Parser.jj (from r835737, ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/Parser.jjt) URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/Parser.jj?p2=ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/Parser.jj&p1=ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/Parser.jjt&r1=835737&r2=835741&rev=835741&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/Parser.jjt (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/Parser.jj Fri Nov 13 04:55:55 2009 @@ -2,14 +2,14 @@ JAVA_UNICODE_ESCAPE = false; ERROR_REPORTING = true; STATIC = false; - MULTI = true; +// MULTI = true; JDK_VERSION = "1.5"; - VISITOR = true; - BUILD_NODE_FILES = true; - NODE_FACTORY = false; - NODE_USES_PARSER = true; +// VISITOR = true; +// BUILD_NODE_FILES = true; +// NODE_FACTORY = false; +// NODE_USES_PARSER = true; // NODE_SCOPE_HOOK = true; - NODE_PREFIX = "SQL"; +// NODE_PREFIX = "SQL"; // DEBUG_PARSER = true; // DEBUG_LOOKAHEAD = true; // DEBUG_TOKEN_MANAGER = true; @@ -148,21 +148,22 @@ EntityCondition condition; int i; DynamicViewEntity dve = new DynamicViewEntity(); - jjtThis.setDynamicViewEntity(dve); + SQLSelect sqlSelect = new SQLSelect(); + sqlSelect.setDynamicViewEntity(dve); List<String> fieldList; List<String> orderBy; } { <SELECT> FieldDefs(dve) <FROM> Table(dve) - ( <WHERE> condition=ConditionExpression() { jjtThis.setWhereCondition(condition); } )? - ( <HAVING> condition=ConditionExpression() { jjtThis.setHavingCondition(condition); } )? + ( <WHERE> condition=ConditionExpression() { sqlSelect.setWhereCondition(condition); } )? + ( <HAVING> condition=ConditionExpression() { sqlSelect.setHavingCondition(condition); } )? ( <GROUP> <BY> fieldList=FieldList() { dve.setGroupBy(fieldList); } )? - ( <ORDER> <BY> orderBy=OrderByList() { jjtThis.setOrderBy(orderBy); } )? - ( <OFFSET> i=Integer() { jjtThis.setOffset(i); } )? - ( <LIMIT> i=Integer() { jjtThis.setLimit(i); } )? + ( <ORDER> <BY> orderBy=OrderByList() { sqlSelect.setOrderBy(orderBy); } )? + ( <OFFSET> i=Integer() { sqlSelect.setOffset(i); } )? + ( <LIMIT> i=Integer() { sqlSelect.setLimit(i); } )? <SEMI> - { return jjtThis; } + { return sqlSelect; } } /* CSSUpdate Update(): @@ -185,7 +186,7 @@ } */ -private void Table(DynamicViewEntity dve) #void: +private void Table(DynamicViewEntity dve): { String leftAlias, rightAlias; Boolean relOptional; @@ -204,7 +205,7 @@ } -private List<ModelKeyMap> KeyMaps(String leftAlias, String rightAlias) #void: +private List<ModelKeyMap> KeyMaps(String leftAlias, String rightAlias): { List<ModelKeyMap> keyMaps = FastList.newInstance(); ModelKeyMap keyMap; @@ -215,7 +216,7 @@ { return keyMaps; } } -private ModelKeyMap KeyMap(String leftAlias, String rightAlias) #void: +private ModelKeyMap KeyMap(String leftAlias, String rightAlias): { String alias1, field1; String alias2, field2; @@ -239,7 +240,7 @@ } } -private String TableName(DynamicViewEntity dve) #void: +private String TableName(DynamicViewEntity dve): { String name, alias = null; } @@ -252,27 +253,27 @@ } } -private Boolean Joiner() #void: +private Boolean Joiner(): {} { <LEFT> <JOIN> { return Boolean.TRUE; } | <JOIN> { return Boolean.FALSE; } } -private void FieldDefs(DynamicViewEntity dve) #void: +private void FieldDefs(DynamicViewEntity dve): {} { FieldDef(dve) ( <COMMA> FieldDef(dve) )* } -private void FieldDef(DynamicViewEntity dve) #void: +private void FieldDef(DynamicViewEntity dve): {} { LOOKAHEAD(AllField()) AllField(dve) | FieldSpec(dve) } -private void AllField(DynamicViewEntity dve) #void: +private void AllField(DynamicViewEntity dve): { String n; } @@ -282,13 +283,13 @@ { dve.addAliasAll(n, null); } } -private String NamePart() #void: +private String NamePart(): {} { <NAME> { return getToken(0).image; } } -private void FieldSpec(DynamicViewEntity dve) #void: +private void FieldSpec(DynamicViewEntity dve): { List<String> fieldUse; String tableAlias, fieldName, fieldAlias = null; @@ -305,14 +306,14 @@ } } -private String DQuoted() #void: +private String DQuoted(): { StringBuilder sb = new StringBuilder(); } { <START_DQUOTE> (<TEXT> { sb.append(getToken(0).image); } | <ESCAPED> { sb.append(getToken(0).image); })* <END_DQUOTE> { return sb.toString(); } } -private String SQuoted() #void: +private String SQuoted(): { StringBuilder sb = new StringBuilder(); } { <START_SQUOTE> ( @@ -323,7 +324,7 @@ { return sb.toString(); } } -private List<String> FieldList() #void: +private List<String> FieldList(): { List<String> list = FastList.newInstance(); String n; @@ -334,7 +335,7 @@ { return list; } } -private EntityConditionValue FieldUse() #void: +private EntityConditionValue FieldUse(): { String tableAlias = null, fieldName, s; } @@ -344,7 +345,7 @@ { return EntityFieldValue.makeFieldValue(fieldName, tableAlias, null, null); } } -private List<String> OrderByList() #void: +private List<String> OrderByList(): { List<String> orderBy = FastList.newInstance(); String obi; @@ -355,7 +356,7 @@ { return orderBy; } } -private String OrderByItem() #void: +private String OrderByItem(): { StringBuilder sb = new StringBuilder(); String n; @@ -369,7 +370,7 @@ { return sb.toString(); } } -private Integer Integer() #void: +private Integer Integer(): {} { <INTEGER> { @@ -384,7 +385,7 @@ } } -private Object Expression() #void: +private Object Expression(): { EntityConditionValue ecv; String s; @@ -396,13 +397,13 @@ | s=SQuoted() { return s; } } -private EntityCondition ConditionExpression() #void: +private EntityCondition ConditionExpression(): { EntityCondition ec; } { ec=AndExpression() { return ec; } } -private EntityCondition AndExpression() #void: +private EntityCondition AndExpression(): { List<EntityCondition> list = FastList.newInstance(); EntityCondition ec; @@ -416,7 +417,7 @@ } } -private EntityCondition OrExpression() #void: +private EntityCondition OrExpression(): { List<EntityCondition> list = FastList.newInstance(); EntityCondition ec; @@ -430,7 +431,7 @@ } } -private EntityCondition BooleanExpression() #void: +private EntityCondition BooleanExpression(): { Object v1, v2; EntityComparisonOperator op; @@ -440,7 +441,7 @@ { return EntityCondition.makeCondition(v1, op, v2); } } -private EntityComparisonOperator ComparisonOperator() #void: +private EntityComparisonOperator ComparisonOperator(): {} { ( <TEXT> )+ { return EntityOperator.lookupComparison(getToken(0).image); } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/SQLSelect.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/SQLSelect.java?rev=835741&r1=835740&r2=835741&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/SQLSelect.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/SQLSelect.java Fri Nov 13 04:55:55 2009 @@ -31,7 +31,7 @@ import org.ofbiz.entity.model.ModelKeyMap; import org.ofbiz.entity.util.EntityListIterator; -public class SQLSelect extends SimpleNode { +public class SQLSelect { private DynamicViewEntity dve; private EntityCondition whereCondition; private EntityCondition havingCondition; @@ -39,20 +39,6 @@ private int limit = -1; private List<String> orderBy; - public SQLSelect(int id) { - super(id); - } - - public SQLSelect(Parser p, int id) { - super(p, id); - } - - - /** Accept the visitor. **/ - public Object jjtAccept(ParserVisitor visitor, Object data) { - return visitor.visit(this, data); - } - public EntityListIterator getEntityListIterator(Delegator delegator) throws GenericEntityException { return delegator.findListIteratorByCondition(dve, whereCondition, havingCondition, null, orderBy, null); } Added: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/SQLUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/SQLUtil.java?rev=835741&view=auto ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/SQLUtil.java (added) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/SQLUtil.java Fri Nov 13 04:55:55 2009 @@ -0,0 +1,27 @@ +/* + * 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.ofbiz.entity.sql; + +import java.io.StringReader; + +public class SQLUtil { + public static SQLSelect parseSelect(String sql) throws ParseException { + return new Parser(new StringReader(sql)).Select(); + } +} |
Free forum by Nabble | Edit this page |