Very large update. SQL parser is fairly generic now. Can parse sql

that is compatible with features used by ofbiz.  Has support for
DELETE, INSERT, INSERT SELECT, SELECT, UPDATE, and VIEW.

Modified the delegator side of the above to handle the new
interfaces.  Now supports complex alias.  Only SELECT is supported,
and the parseCondition code is disabled for the time being.

The plan(sic) here is to obviously support the other sql statements.
Then, to have a jdbc wrapper around all this, so external tools, that
only know how to talk jdbc, can actually talk directly to the
delegator.

Plus, many more people can understand sql syntax.  This allows them
to do things with ofbiz, that they would find much more difficult if
they had to write <view-entity> definitions.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@880835 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Adam Heath
2009-11-16 16:31:32 +00:00
parent 2a7ac0293a
commit 91050d9263
58 changed files with 3111 additions and 647 deletions
@@ -0,0 +1,54 @@
/*
* 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.sql;
public final class BooleanCondition implements Condition {
private final Value left;
private final String op;
private final Value right;
public BooleanCondition(Value left, String op, Value right) {
this.left = left;
this.op = op;
this.right = right;
}
public Value getLeft() {
return left;
}
public String getOp() {
return op;
}
public Value getRight() {
return right;
}
public String toString() {
return appendTo(new StringBuilder()).toString();
}
public StringBuilder appendTo(StringBuilder sb) {
left.appendTo(sb);
sb.append(' ').append(op).append(' ');
right.appendTo(sb);
return sb;
}
}
@@ -0,0 +1,24 @@
/*
* 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.sql;
import org.ofbiz.base.util.Appender;
public interface Condition extends Appender<StringBuilder> {
}
@@ -0,0 +1,53 @@
/*
* 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.sql;
import java.util.Iterator;
import java.util.List;
import org.ofbiz.base.util.StringUtil;
public final class ConditionList implements Condition, Iterable<Condition> {
private final Joiner joiner;
private final List<Condition> conditions;
public ConditionList(Joiner joiner, List<Condition> conditions) {
this.joiner = joiner;
this.conditions = conditions;
}
public void add(Condition condition) {
conditions.add(condition);
}
public Joiner getJoiner() {
return joiner;
}
public Iterator<Condition> iterator() {
return conditions.iterator();
}
public StringBuilder appendTo(StringBuilder sb) {
sb.append('(');
StringUtil.appendTo(sb, conditions, " ", " ", joiner.toString());
sb.append(')');
return sb;
}
}
@@ -0,0 +1,22 @@
/*
* 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.sql;
public abstract class ConstantValue extends Value {
}
@@ -0,0 +1,22 @@
/*
* 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.sql;
public abstract class DeletePlan<P extends DeletePlan<P>> extends SQLPlan<P> {
}
@@ -0,0 +1,53 @@
/*
* 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.sql;
import java.util.Iterator;
import java.util.List;
import org.ofbiz.base.util.Appender;
import org.ofbiz.base.util.StringUtil;
public final class FieldAll implements Appender<StringBuilder>, Iterable<String> {
private final String alias;
private final List<String> exclude;
public FieldAll(String alias, List<String> exclude) {
this.alias = alias;
this.exclude = exclude;
}
public String getAlias() {
return alias;
}
public Iterator<String> iterator() {
return exclude.iterator();
}
public StringBuilder appendTo(StringBuilder sb) {
sb.append(alias).append(".*");
if (!exclude.isEmpty()) {
sb.append(" EXCLUDE (");
StringUtil.append(sb, exclude, null, null, ", ");
sb.append(')');
}
return sb;
}
}
@@ -0,0 +1,37 @@
/*
* 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.sql;
import org.ofbiz.base.util.Appender;
public abstract class FieldDef implements Appender<StringBuilder> {
protected final String alias;
protected FieldDef(String alias) {
this.alias = alias;
}
public final String getAlias() {
return alias;
}
public String toString() {
return appendTo(new StringBuilder()).toString();
}
}
@@ -0,0 +1,40 @@
/*
* 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.sql;
public final class FieldDefFieldValue extends FieldDef {
private final FieldValue value;
public FieldDefFieldValue(FieldValue value, String alias) {
super(alias == null ? value.getFieldName() : alias);
this.value = value;
}
public FieldValue getFieldValue() {
return value;
}
public StringBuilder appendTo(StringBuilder sb) {
value.appendTo(sb);
if (!value.getFieldName().equals(alias)) {
sb.append(" AS ").append(alias);
}
return sb;
}
}
@@ -0,0 +1,38 @@
/*
* 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.sql;
public final class FieldDefValue extends FieldDef {
private final StaticValue value;
public FieldDefValue(StaticValue value, String alias) {
super(alias == null ? value.getDefaultName() : alias);
this.value = value;
}
public StaticValue getValue() {
return value;
}
public StringBuilder appendTo(StringBuilder sb) {
value.appendTo(sb);
sb.append(" AS ").append(alias);
return sb;
}
}
@@ -0,0 +1,53 @@
/*
* 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.sql;
public final class FieldValue extends StaticValue {
private final String fieldName;
private final String tableName;
public FieldValue(String fieldName) {
this(null, fieldName);
}
public FieldValue(String tableName, String fieldName) {
this.tableName = tableName;
this.fieldName = fieldName;
}
public final String getTableName() {
return tableName;
}
public final String getFieldName() {
return fieldName;
}
public String getDefaultName() {
return fieldName;
}
public StringBuilder appendTo(StringBuilder sb) {
if (tableName != null) {
sb.append(tableName).append('.');
}
sb.append(fieldName);
return sb;
}
}
@@ -0,0 +1,57 @@
/*
* 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.sql;
import java.util.Iterator;
import java.util.List;
import org.ofbiz.base.util.StringUtil;
public final class FunctionCall extends StaticValue implements Iterable<Value> {
private final String name;
private final List<Value> values;
public FunctionCall(String name, List<Value> values) {
this.name = name;
this.values = values;
}
public String getName() {
return name;
}
public String getDefaultName() {
return name;
}
public int getArgCount() {
return values.size();
}
public Iterator<Value> iterator() {
return values.iterator();
}
public StringBuilder appendTo(StringBuilder sb) {
sb.append(name).append('(');
StringUtil.appendTo(sb, values, null, null, ", ");
sb.append(')');
return sb;
}
}
@@ -0,0 +1,22 @@
/*
* 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.sql;
public abstract class InsertPlan<P extends InsertPlan<P>> extends SQLPlan<P> {
}
@@ -0,0 +1,44 @@
/*
* 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.sql;
import java.util.Iterator;
import java.util.List;
import org.ofbiz.base.util.Appender;
import org.ofbiz.base.util.StringUtil;
public class InsertRow implements Appender<StringBuilder>, Iterable<Value> {
private final List<Value> values;
public InsertRow(List<Value> values) {
this.values = values;
}
public Iterator<Value> iterator() {
return values.iterator();
}
public StringBuilder appendTo(StringBuilder sb) {
sb.append('(');
StringUtil.appendTo(sb, values, null, null, ", ");
sb.append(')');
return sb;
}
}
@@ -0,0 +1,24 @@
/*
* 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.sql;
import org.ofbiz.base.util.Appender;
public interface InsertSource extends Appender<StringBuilder> {
}
@@ -0,0 +1,42 @@
/*
* 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.sql;
import java.util.Iterator;
import java.util.List;
import org.ofbiz.base.util.StringUtil;
public class InsertValues implements InsertSource, Iterable<InsertRow> {
private final List<InsertRow> rows;
public InsertValues(List<InsertRow> rows) {
this.rows = rows;
}
public Iterator<InsertRow> iterator() {
return rows.iterator();
}
public StringBuilder appendTo(StringBuilder sb) {
sb.append("VALUES ");
StringUtil.appendTo(sb, rows, null, null, ", ");
return sb;
}
}
@@ -0,0 +1,74 @@
/*
* 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.sql;
import java.util.Iterator;
import java.util.List;
public final class Joined implements Iterable<KeyMap> {
private final boolean isOptional;
private final TableName tableName;
private final List<KeyMap> keyMaps;
private final Joined joined;
public Joined(boolean isOptional, TableName tableName, List<KeyMap> keyMaps) {
this(isOptional, tableName, keyMaps, null);
}
public Joined(boolean isOptional, TableName tableName, List<KeyMap> keyMaps, Joined joined) {
this.isOptional = isOptional;
this.tableName = tableName;
this.keyMaps = keyMaps;
this.joined = joined;
}
public boolean isOptional() {
return isOptional;
}
public TableName getTableName() {
return tableName;
}
public Iterator<KeyMap> iterator() {
return keyMaps.iterator();
}
public Joined getJoined() {
return joined;
}
public StringBuilder appendTo(String leftAlias, StringBuilder sb) {
sb.append(isOptional ? " LEFT JOIN " : " JOIN ");
return appendToRest(leftAlias, sb);
}
public StringBuilder appendToRest(String leftAlias, StringBuilder sb) {
tableName.appendTo(sb);
sb.append(" ON ");
for (int i = 0; i < keyMaps.size(); i++) {
if (i != 0) sb.append(" AND ");
keyMaps.get(i).appendTo(leftAlias, tableName.getAlias(), sb);
}
if (joined != null) {
joined.appendTo(tableName.getAlias(), sb);
}
return sb;
}
}
@@ -0,0 +1,23 @@
/*
* 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.sql;
public enum Joiner {
AND, OR
}
@@ -0,0 +1,44 @@
/*
* 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.sql;
public final class KeyMap {
private final String leftFieldName;
private final String rightFieldName;
public KeyMap(String leftFieldName, String rightFieldName) {
this.leftFieldName = leftFieldName;
this.rightFieldName = rightFieldName;
}
public String getLeftFieldName() {
return leftFieldName;
}
public String getRightFieldName() {
return rightFieldName;
}
public StringBuilder appendTo(String leftAlias, String rightAlias, StringBuilder sb) {
sb.append(leftAlias).append('.').append(leftFieldName);
sb.append(" = ");
sb.append(rightAlias).append('.').append(rightFieldName);
return sb;
}
}
@@ -0,0 +1,38 @@
/*
* 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.sql;
import java.util.List;
import org.ofbiz.base.util.StringUtil;
public final class ListValue extends Value {
private final List<Value> values;
public ListValue(List<Value> values) {
this.values = values;
}
public StringBuilder appendTo(StringBuilder sb) {
sb.append('(');
StringUtil.appendTo(sb, values, null, null, ", ");
sb.append(')');
return sb;
}
}
+63
View File
@@ -0,0 +1,63 @@
/*
* 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.sql;
import java.util.List;
public final class Main {
public static void main(String[] args) throws Exception {
Planner<?, ?, ?, ?, ?, ?> planner = new DebugPlanner();
List<SQLStatement<?, ?>> statements = new Parser(System.in).SQLFile();
for (SQLStatement<?, ?> statement: statements) {
run(statement, planner);
}
}
private static final void run(SQLStatement statement, Planner planner) {
System.err.println(statement);
SQLPlan plan = statement.plan(planner);
System.err.println("\tplan=" + plan);
}
private final static class DebugPlanner implements Planner {
public SQLPlan plan(SQLStatement statement) {
return null;
}
public DeletePlan plan(SQLDelete deleteStatement) {
return null;
}
public InsertPlan plan(SQLInsert insertStatement) {
return null;
}
public SelectPlan plan(SQLSelect selectStatement) {
return null;
}
public UpdatePlan plan(SQLUpdate updateStatement) {
return null;
}
public ViewPlan plan(SQLView viewStatement) {
return null;
}
}
}
@@ -0,0 +1,53 @@
/*
* 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.sql;
import java.util.Iterator;
import java.util.List;
import org.ofbiz.base.util.StringUtil;
public final class MathValue extends StaticValue implements Iterable<StaticValue> {
private final String op;
private final List<StaticValue> values;
public MathValue(String op, List<StaticValue> values) {
this.op = op;
this.values = values;
}
public String getOp() {
return op;
}
public String getDefaultName() {
return null;
}
public Iterator<StaticValue> iterator() {
return values.iterator();
}
public StringBuilder appendTo(StringBuilder sb) {
sb.append('(');
StringUtil.appendTo(sb, values, " ", null, op);
sb.append(')');
return sb;
}
}
@@ -0,0 +1,36 @@
/*
* 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.sql;
public final class NumberValue<N extends Number> extends ConstantValue {
private final N number;
public NumberValue(N number) {
this.number = number;
}
public N getNumber() {
return number;
}
public StringBuilder appendTo(StringBuilder sb) {
sb.append(number);
return sb;
}
}
@@ -0,0 +1,36 @@
/*
* 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.sql;
public final class ParameterValue extends Value {
private final String name;
public ParameterValue(String name) {
this.name = name;
}
public String getName() {
return name;
}
public StringBuilder appendTo(StringBuilder sb) {
sb.append('?').append(name);
return sb;
}
}
+773
View File
@@ -0,0 +1,773 @@
/*
* 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.
*/
options {
JAVA_UNICODE_ESCAPE = false;
ERROR_REPORTING = true;
STATIC = false;
// MULTI = true;
JDK_VERSION = "1.5";
// VISITOR = true;
// BUILD_NODE_FILES = true;
// NODE_FACTORY = false;
// NODE_USES_PARSER = true;
// NODE_SCOPE_HOOK = true;
// NODE_PREFIX = "SQL";
// DEBUG_PARSER = true;
// DEBUG_LOOKAHEAD = true;
// DEBUG_TOKEN_MANAGER = true;
LOOKAHEAD = 1;
// CHOICE_AMBIGUITY_CHECK = 3;
// OTHER_AMBIGUITY_CHECK = 3;
IGNORE_CASE = true;
}
PARSER_BEGIN(Parser)
package org.ofbiz.sql;
import java.io.*;
import java.util.Collections;
import java.util.List;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
import javolution.util.FastList;
import javolution.util.FastMap;
import javolution.util.FastSet;
import org.ofbiz.base.conversion.ConversionException;
import org.ofbiz.base.conversion.Converter;
import org.ofbiz.base.conversion.Converters;
public class Parser {
}
PARSER_END(Parser)
TOKEN_MGR_DECLS: {
private final LinkedList<Integer> stack = new LinkedList<Integer>();
void pushState(int newState) {
stack.add(curLexState);
SwitchTo(newState);
}
void popState() {
SwitchTo(stack.removeLast());
}
}
TOKEN: {
<OPEN_PAREN: "(">
| <CLOSE_PAREN: ")">
| <AND: "AND">
| <OR: "OR">
| <PERIOD: ".">
| <JOIN: "JOIN">
| <LEFT: "LEFT">
| <AS: "AS">
| <WHERE: "WHERE">
| <HAVING: "HAVING">
| <GROUP: "GROUP">
| <ORDER: "ORDER">
//| <UNION: "UNION">
| <BY: "BY">
| <ON: "ON">
| <USING: "USING">
| <LIMIT: "LIMIT">
| <OFFSET: "OFFSET">
| <SELECT: "SELECT">
| <DELETE: "DELETE">
| <UPDATE: "UPDATE">
| <INSERT: "INSERT">
| <RELATION: "RELATION">
| <EXCLUDE: "EXCLUDE">
| <TYPE: "TYPE">
| <TITLE: "TITLE">
| <SET: "SET">
| <FROM: "FROM">
| <SEMI: ";">
| <STAR: "*">
| <COMMA: ",">
| <DESC: "DESC">
| <ASC: "ASC">
| <EQUALS: "=">
| <BETWEEN: "BETWEEN">
| <INTO: "INTO">
| <VALUES: "VALUES">
| <CREATE: "CREATE">
| <VIEW: "VIEW">
| <START_DQUOTE: "\""> { pushState(IN_DQUOTE); }
| <START_SQUOTE: "'"> { pushState(IN_SQUOTE); }
| <INTEGER:
"0" (
"x" (["0"-"9","a"-"b"])+
| (["0"-"7"])+
)
| ["1"-"9"] (["0"-"9"])*
>
| <NAME: ["a"-"z"] (["a"-"z","0"-"9","_","-"])*>
| <PARAMETER: "?" (["a"-"z"])+>
//| <WORD: (~["'", "\"", "/", " ", "\f", "\n", "\r", "\t", "*"])+>
}
<DEFAULT>
SKIP: {
<SPACE: " " | "\f" | "\n" | "\r" | "\t">
}
<*>
MORE: {
<COMMENT_START: "/*"> { if (curLexState != IN_COMMENT) pushState(IN_COMMENT); }
}
<IN_COMMENT>
MORE: {
<(~[])>
| <COMMENT_END: ("\n" | "\r" | "\r\n")> { popState(); }
}
<IN_DQUOTE,IN_SQUOTE>
TOKEN: {
<ESCAPED: "\\" ["r", "n", "b", "t", "f"]>
}
<IN_DQUOTE>
TOKEN: {
<END_DQUOTE: "\""> { popState(); }
}
<IN_SQUOTE>
TOKEN: {
<ESCAPE_SQUOTE: "''">
| <END_SQUOTE: "'"> { popState(); }
}
<DEFAULT,IN_DQUOTE,IN_SQUOTE>
TOKEN: {
<TEXT: (~[])>
}
// -------------------
public List<SQLStatement<?, ?>> SQLFile():
{
List<SQLStatement<?, ?>> list = FastList.newInstance();
SQLStatement<?, ?> statement;
}
{
( statement=Statement() ( <SEMI> )? { list.add(statement); } )*
<EOF>
{ return list; }
}
public SQLStatement StandaloneStatement():
{
SQLStatement statement;
}
{
statement=Statement() ( <SEMI> )? <EOF> { return statement; }
}
public SQLView ViewStatement():
{
SQLView sqlView;
}
{
sqlView=View() ( <SEMI> )? <EOF> { return sqlView; }
}
public SQLSelect SelectStatement():
{
SQLSelect sqlSelect;
}
{
sqlSelect=Select() ( <SEMI> )? <EOF> { return sqlSelect; }
}
public SQLDelete DeleteStatement():
{
SQLDelete sqlDelete;
}
{
sqlDelete=Delete() ( <SEMI> )? <EOF> { return sqlDelete; }
}
public SQLUpdate UpdateStatement():
{
SQLUpdate sqlUpdate;
}
{
sqlUpdate=Update() ( <SEMI> )? <EOF> { return sqlUpdate; }
}
public SQLInsert InsertStatement():
{
SQLInsert sqlInsert;
}
{
sqlInsert=Insert() ( <SEMI> )? <EOF> { return sqlInsert; }
}
public Condition Condition():
{ Condition c; }
{
c=ConditionExpression() <EOF> { return c; }
}
private SQLStatement Statement():
{
SQLStatement statement;
}
{
(
statement=Select() { return statement; }
| statement=Delete() { return statement; }
| statement=Update() { return statement; }
| statement=Insert() { return statement; }
)
}
private SQLView View():
{
String name;
SQLSelect sqlSelect;
}
{
<CREATE> <VIEW> name=NamePart() <AS> sqlSelect=Select()
{ return new SQLView(name, sqlSelect); }
}
private SQLSelect Select():
{
Integer i;
List<String> orderBy = null, groupBy = null;
Map<String, FieldDef> fieldDefs = FastMap.newInstance();
List<FieldAll> fieldAlls = FastList.newInstance();
Table table;
List<Relation> relations = FastList.newInstance();
Relation relation;
Condition whereCondition = null, havingCondition = null;
int offset = -1, limit = -1;
}
{
<SELECT> (
FieldDef(fieldDefs, fieldAlls)
( <COMMA> FieldDef(fieldDefs, fieldAlls) )*
)
<FROM> table=Table()
( <RELATION> relation=Relation() { relations.add(relation); } )*
( <WHERE> whereCondition=ConditionExpression() )?
( <HAVING> havingCondition=ConditionExpression() )?
( <GROUP> <BY> groupBy=FieldList() )?
( <ORDER> <BY> orderBy=OrderByList() )?
( <OFFSET> offset=Integer() )?
( <LIMIT> limit=Integer() )?
{ return new SQLSelect(fieldAlls, fieldDefs, table, relations, whereCondition, havingCondition, groupBy, orderBy, offset, limit); }
}
private Relation Relation():
{
String type = null, title = null, entityName;
List<KeyMap> keyMaps;
}
{
( <TYPE> type=NamePart() )?
( <TITLE> title=NamePart() )?
<NAME> { entityName = getToken(0).image; }
keyMaps=KeyMaps("cur", "other")
{ return new Relation(type, title, entityName, keyMaps); }
}
private SQLUpdate Update():
{
TableName tableName;
List<Table> tableList = null;
Condition whereCondition = null;
List<SetField> allSetFields = FastList.newInstance();
List<SetField> setFields;
Joined joined = null;
}
{
<UPDATE> tableName=TableName()
<SET>
setFields=SetField() { allSetFields.addAll(setFields); }
( <COMMA> setFields=SetField() { allSetFields.addAll(setFields); } )*
( <FROM> joined=JoinedRest(false, tableName) )?
( <WHERE> whereCondition=ConditionExpression() )?
{ return new SQLUpdate(new Table(tableName, joined), allSetFields, whereCondition); }
}
private SQLDelete Delete():
{
TableName tableName;
List<Table> tableList = null;
Condition whereCondition = null;
Joined joined = null;
}
{
<DELETE> <FROM> tableName=TableName()
( <USING> joined=JoinedRest(false, tableName) )?
( <WHERE> whereCondition=ConditionExpression() )?
{ return new SQLDelete(new Table(tableName, joined), whereCondition); }
}
private SQLInsert Insert():
{
TableName tableName;
List<String> columns = FastList.newInstance();
String n;
InsertSource source;
}
{
<INSERT> <INTO> tableName=TableName() (
<OPEN_PAREN>
n=NamePart() { columns.add(n); }
( <COMMA> n=NamePart() { columns.add(n); } )*
<CLOSE_PAREN>
)?
( source=InsertValues() | source=Select() )
{ return new SQLInsert(tableName, source, columns); }
}
private InsertValues InsertValues():
{
List<InsertRow> list = FastList.newInstance();
InsertRow row;
}
{
<VALUES>
row=InsertRow() { list.add(row); }
( <COMMA> row=InsertRow() { list.add(row); } )*
{ return new InsertValues(list); }
}
private InsertRow InsertRow():
{
List<Value> list = FastList.newInstance();
Value v;
}
{
<OPEN_PAREN>
v=InsertValue() { list.add(v); }
( <COMMA> v=InsertValue() { list.add(v); } )*
<CLOSE_PAREN>
{ return new InsertRow(list); }
}
private Value InsertValue():
{
Value v;
Integer i;
String s;
}
{
v=ParameterValue() { return v; }
| i=Integer() { return new NumberValue<Integer>(i); }
| s=SQuoted() { return new StringValue(s); }
}
private List<SetField> SetField():
{
List<SetField> setFields = FastList.newInstance();
String n;
Value v;
List<String> columnList = FastList.newInstance();
List<Value> valueList = FastList.newInstance();
}
{
(
n=NamePart() <EQUALS> v=Value() { setFields.add(new SetField(n, v)); }
| <OPEN_PAREN>
n=NamePart() { columnList.add(n); }
( <COMMA> n=NamePart() { columnList.add(n); } )*
<CLOSE_PAREN>
<EQUALS>
<OPEN_PAREN>
v=Value() { valueList.add(v); }
( <COMMA> v=Value() { valueList.add(v); } )*
<CLOSE_PAREN>
)
{ return setFields; }
}
private Table Table():
{
TableName tableName;
Joined joined = null;
}
{
tableName=TableName()
( joined=Joined(tableName) )?
{ return new Table(tableName, joined); }
}
private Joined Joined(TableName leftTableName):
{
Boolean isOptional;
Joined joined = null;
}
{
isOptional=Joiner() joined=JoinedRest(isOptional, leftTableName)
{ return joined; }
}
private Joined JoinedRest(boolean isOptional, TableName leftTableName):
{
TableName rightTableName;
List<KeyMap> keyMaps;
Joined joined = null;
}
{
rightTableName=TableName()
keyMaps=KeyMaps(leftTableName.getAlias(), rightTableName.getAlias())
( joined=Joined(rightTableName) )?
{ return new Joined(isOptional, rightTableName, keyMaps, joined); }
}
private List<KeyMap> KeyMaps(String leftAlias, String rightAlias):
{
List<KeyMap> keyMaps = FastList.newInstance();
String n;
}
{
(
<ON>
KeyMap(keyMaps, leftAlias, rightAlias)
( <AND> KeyMap(keyMaps, leftAlias, rightAlias) )*
|
<USING>
n=NamePart() { keyMaps.add(new KeyMap(n, n)); }
( <COMMA> n=NamePart() { keyMaps.add(new KeyMap(n, n)); } )*
)
{ return keyMaps; }
}
private void KeyMap(List<KeyMap> keyMaps, String leftAlias, String rightAlias):
{
String alias1, field1;
String alias2, field2;
}
{
alias1=NamePart() <PERIOD> field1=NamePart()
<EQUALS>
alias2=NamePart() <PERIOD> field2=NamePart()
{
if (alias1.equals(leftAlias)) {
if (!alias2.equals(rightAlias)) throw new IllegalArgumentException("invalid right alias(" + alias2 + "), expected(" + rightAlias + ")");
keyMaps.add(new KeyMap(field1, field2));
} else if (alias1.equals(rightAlias)) {
if (!alias2.equals(leftAlias)) throw new IllegalArgumentException("invalid left alias(" + alias2 + "), expected(" + leftAlias + ")");
keyMaps.add(new KeyMap(field2, field1));
} else {
throw new IllegalArgumentException("invalid aliases, expected(" + leftAlias + " or " + rightAlias + ")");
}
}
}
private TableName TableName():
{
String tableName, alias = null;
}
{
tableName=NamePart()
( (<AS>)? alias=NamePart() )?
{ return new TableName(tableName, alias); }
}
private Boolean Joiner():
{}
{
<LEFT> <JOIN> { return Boolean.TRUE; }
| <JOIN> { return Boolean.FALSE; }
}
private void FieldDef(Map<String, FieldDef> fieldDefs, List<FieldAll> fieldAlls):
{
StaticValue v;
String n, fieldAlias = null, fieldName, exc;
FieldDef def;
List<String> excludeList = FastList.newInstance();
}
{
(
n=NamePart() (
<PERIOD> (
<STAR>
(
<EXCLUDE> <OPEN_PAREN>
exc=NamePart() { excludeList.add(exc); }
( <COMMA> exc=NamePart() { excludeList.add(exc); } )*
<CLOSE_PAREN>
)?
{ fieldAlls.add(new FieldAll(n, excludeList)); return; }
| fieldName=NamePart() ( <AS> fieldAlias=NamePart() )? { def = new FieldDefValue(new FieldValue(n, fieldName), fieldAlias); }
)
| v=FunctionCallRest(n) <AS> fieldAlias=NamePart() { def = new FieldDefValue(v, fieldAlias); }
| ( <AS> fieldAlias=NamePart() )? { def = new FieldDefFieldValue(new FieldValue(null, n), fieldAlias); }
)
| v=MathValue() <AS> fieldAlias=NamePart() { def = new FieldDefValue(v, fieldAlias); }
) {
if (fieldDefs.containsKey(def.getAlias())) throw new IllegalArgumentException("duplicate alias(" + def.getAlias() + ")");
fieldDefs.put(def.getAlias(), def);
}
}
private StaticValue MathValue():
{
StaticValue v;
List<StaticValue> values = FastList.newInstance();
String operator = null, newOperator;
}
{
<OPEN_PAREN>
v=StaticValue() { values.add(v); }
(
newOperator=MathOperator()
v=StaticValue() {
if (operator == null) {
operator = newOperator;
} else if (!newOperator.equals(operator)) {
throw new IllegalArgumentException("Different operators in complex alias(" + operator + ":" + newOperator + ")");
}
values.add(v);
}
)*
<CLOSE_PAREN>
{
if (values.size() == 1) return values.get(0);
return new MathValue(operator, values);
}
}
private FunctionCall FunctionCallRest(String name):
{
Value arg;
List<Value> args = FastList.newInstance();
}
{
<OPEN_PAREN>
(
arg=Value() { args.add(arg); }
( <COMMA> arg=Value() { args.add(arg); } )*
) ?
<CLOSE_PAREN>
{ return new FunctionCall(name, args); }
}
private StaticValue StaticValue():
{
String n;
StaticValue v;
}
{
n=NamePart() (
v=FunctionCallRest(n) { return v; }
| v=FieldValue(n) { return v; }
)
| v=MathValue() { return v; }
}
private String NamePart():
{}
{
<NAME> { return getToken(0).image; }
| <TYPE> { return getToken(0).image; }
}
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():
{ StringBuilder sb = new StringBuilder(); }
{
<START_SQUOTE> (
<TEXT> { sb.append(getToken(0).image); }
| <ESCAPED> { sb.append(getToken(0).image); }
| <ESCAPE_SQUOTE> { sb.append("'"); }
)* <END_SQUOTE>
{ return sb.toString(); }
}
private List<String> FieldList():
{
List<String> list = FastList.newInstance();
String n;
}
{
n=NamePart() { list.add(n); }
( <COMMA> n=NamePart() { list.add(n); } )*
{ return list; }
}
private FieldValue FieldValue(String fieldName):
{
String tableAlias = null, s;
}
{
( <PERIOD> s=NamePart() { tableAlias = fieldName; fieldName = s; } )?
{
return new FieldValue(tableAlias, fieldName);
}
}
private List<String> OrderByList():
{
List<String> orderBy = FastList.newInstance();
String obi;
}
{
obi=OrderByItem() { orderBy.add(obi); }
( <COMMA> obi=OrderByItem() { orderBy.add(obi); } )*
{ return orderBy; }
}
private String OrderByItem():
{
StringBuilder sb = new StringBuilder();
String n;
}
{
n=NamePart() { sb.append(n); }
(
<DESC> { sb.append(" DESC"); }
| <ASC> { sb.append(" ASC"); }
)?
{ return sb.toString(); }
}
private Integer Integer():
{}
{
<INTEGER> {
try {
Converter<String, Integer> converter = Converters.getConverter(String.class, Integer.class);
return converter.convert(getToken(0).image);
} catch (ClassNotFoundException e) {
return null;
} catch (ConversionException e) {
return null;
}
}
}
private Value Value():
{
String n;
Value v;
int i;
String s;
}
{
n=NamePart() (
v=FunctionCallRest(n) { return v; }
| v=FieldValue(n) { return v; }
)
| i=Integer() { return new NumberValue<Integer>(i); }
| s=SQuoted() { return new StringValue(s); }
}
private Condition ConditionExpression():
{ Condition c; }
{
c=OrExpression() { return c; }
}
private Condition AndExpression():
{
List<Condition> list = FastList.newInstance();
Condition c;
}
{
c=BooleanExpression() { list.add(c); }
( <AND> c=BooleanExpression() { list.add(c); } )*
{ return list.size() == 1 ? list.get(0) : new ConditionList(Joiner.AND, list); }
}
private Condition OrExpression():
{
List<Condition> list = FastList.newInstance();
Condition c;
}
{
c=AndExpression() { list.add(c); }
( <OR> c=AndExpression() { list.add(c); } )*
{ return list.size() == 1 ? list.get(0) : new ConditionList(Joiner.OR, list); }
}
private Value RightValue():
{
Value v;
}
{
v=Value() { return v; }
| v=ParameterValue() { return v; }
}
private ParameterValue ParameterValue():
{}
{
<PARAMETER> { return new ParameterValue(getToken(0).image.substring(1)); }
}
private Condition BooleanExpression():
{
Value v1, v2, v;
String op;
Condition c;
List<Value> list = FastList.newInstance();
}
{
v1=Value() (
<BETWEEN>
v=RightValue() { list.add(v); }
<AND>
v=RightValue() { list.add(v); }
{ v2 = new ListValue(list); op = "between"; }
| op=ComparisonOperator() (
v2=RightValue()
| <OPEN_PAREN>
v=RightValue() { list.add(v); }
( <COMMA> v=RightValue() { list.add(v); } )*
<CLOSE_PAREN>
{ v2 = new ListValue(list); }
)
)
{ return new BooleanCondition(v1, op, v2); }
| <OPEN_PAREN> c=ConditionExpression() <CLOSE_PAREN> { return c; }
}
private String ComparisonOperator():
{}
{
( <TEXT> )+ { return getToken(0).image; }
| <NAME> { return getToken(0).image; }
| <EQUALS> { return getToken(0).image.toLowerCase(); }
}
private String MathOperator():
{}
{
( <TEXT> )+ { return getToken(0).image.toLowerCase(); }
| <NAME> { return getToken(0).image.toLowerCase(); }
}
@@ -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.sql;
public interface Planner<P extends Planner<P, D, I, S, U, V>, D extends DeletePlan<D>, I extends InsertPlan<I>, S extends SelectPlan<S>, U extends UpdatePlan<U>, V extends ViewPlan<V>> {
D plan(SQLDelete<?> deleteStatement);
I plan(SQLInsert<?> insertStatement);
S plan(SQLSelect<?> selectStatement);
U plan(SQLUpdate<?> updateStatement);
V plan(SQLView<?> viewStatement);
}
@@ -0,0 +1,71 @@
/*
* 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.sql;
import java.util.Iterator;
import java.util.List;
import org.ofbiz.base.util.Appender;
public final class Relation implements Appender<StringBuilder>, Iterable<KeyMap> {
private final String type;
private final String title;
private final String entityName;
private final List<KeyMap> keyMaps;
public Relation(String type, String title, String entityName, List<KeyMap> keyMaps) {
this.type = type;
this.title = title;
this.entityName = entityName;
this.keyMaps = keyMaps;
}
public String getType() {
return type;
}
public String getTitle() {
return title;
}
public String getEntityName() {
return entityName;
}
public Iterator<KeyMap> iterator() {
return keyMaps.iterator();
}
public StringBuilder appendTo(StringBuilder sb) {
sb.append("RELATION");
if (type != null) {
sb.append(' ').append(type);
}
if (title != null) {
sb.append(' ').append(title);
}
sb.append(' ').append(entityName);
sb.append(" ON");
for (int i = 0; i < keyMaps.size(); i++) {
sb.append(' ');
keyMaps.get(i).appendTo("cur", "other", sb);
}
return sb;
}
}
@@ -0,0 +1,57 @@
/*
* 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.sql;
public final class SQLDelete<P extends DeletePlan<P>> extends SQLStatement<SQLDelete<P>, P> {
private final Table table;
private final Condition whereCondition;
public SQLDelete(Table table, Condition whereCondition) {
this.table = table;
this.whereCondition = whereCondition;
}
@SuppressWarnings("unchecked")
public <PP extends P> PP plan(Planner<?, ?, ?, ?, ?, ?> planner) {
return (PP) planner.plan(this);
}
public Table getTable() {
return table;
}
public Condition getWhereCondition() {
return whereCondition;
}
public StringBuilder appendTo(StringBuilder sb) {
sb.append("DELETE FROM ");
table.getTableName().appendTo(sb);
if (table.getJoined() != null) {
sb.append(" USING");
table.getJoined().appendToRest(table.getTableName().getAlias(), sb);
}
if (whereCondition != null) {
sb.append(" WHERE ");
whereCondition.appendTo(sb);
}
sb.append(';');
return sb;
}
}
@@ -0,0 +1,54 @@
/*
* 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.sql;
import java.util.List;
import org.ofbiz.base.util.StringUtil;
import org.ofbiz.base.util.UtilGenerics;
public final class SQLInsert<P extends InsertPlan<P>> extends SQLStatement<SQLInsert<P>, P> {
private final TableName tableName;
private final InsertSource source;
private final List<String> columns;
public SQLInsert(TableName tableName, InsertSource source, List<String> columns) {
this.tableName = tableName;
this.source = source;
this.columns = columns;
}
@SuppressWarnings("unchecked")
public <PP extends P> PP plan(Planner<?, ?, ?, ?, ?, ?> planner) {
return (PP) planner.plan(this);
}
public StringBuilder appendTo(StringBuilder sb) {
sb.append("INSERT INTO ");
tableName.appendTo(sb);
if (columns != null && !columns.isEmpty()) {
sb.append(" (");
StringUtil.append(sb, columns, null, null, ", ");
sb.append(')');
}
sb.append(' ');
source.appendTo(sb);
return sb;
}
}
@@ -0,0 +1,24 @@
/*
* 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.sql;
import java.util.Map;
public abstract class SQLPlan<P extends SQLPlan<P>> {
}
@@ -0,0 +1,136 @@
/*
* 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.sql;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import org.ofbiz.base.util.StringUtil;
public final class SQLSelect<P extends SelectPlan<P>> extends SQLStatement<SQLSelect<P>, P> implements InsertSource {
private final List<FieldAll> fieldAlls;
private final Map<String, FieldDef> fieldDefs;
private final Table table;
private final List<Relation> relations;
private final Condition whereCondition;
private final Condition havingCondition;
private final int offset;
private final int limit;
private final List<String> orderBy;
private final List<String> groupBy;
public SQLSelect(List<FieldAll> fieldAlls, Map<String, FieldDef> fieldDefs, Table table, List<Relation> relations, Condition whereCondition, Condition havingCondition, List<String> groupBy, List<String> orderBy, int offset, int limit) {
this.fieldAlls = fieldAlls;
this.fieldDefs = fieldDefs;
this.table = table;
this.relations = relations;
this.whereCondition = whereCondition;
this.havingCondition = havingCondition;
this.groupBy = groupBy;
this.orderBy = orderBy;
this.offset = offset;
this.limit = limit;
}
@SuppressWarnings("unchecked")
public <PP extends P> PP plan(Planner<?, ?, ?, ?, ?, ?> planner) {
return (PP) planner.plan(this);
}
public Collection<FieldAll> getFieldAlls() {
return fieldAlls;
}
public Collection<FieldDef> getFieldDefs() {
return fieldDefs.values();
}
public Table getTable() {
return table;
}
public List<Relation> getRelations() {
return relations;
}
public Condition getWhereCondition() {
return whereCondition;
}
public Condition getHavingCondition() {
return havingCondition;
}
public List<String> getGroupBy() {
return groupBy;
}
public List<String> getOrderBy() {
return orderBy;
}
public int getOffset() {
return offset;
}
public int getLimit() {
return limit;
}
public StringBuilder appendTo(StringBuilder sb) {
sb.append("SELECT");
StringUtil.appendTo(sb, fieldAlls, " ", null, ",");
if (!fieldAlls.isEmpty() && !fieldDefs.isEmpty()) {
sb.append(',');
}
StringUtil.appendTo(sb, fieldDefs.values(), " ", null, ",");
sb.append(" FROM ");
table.appendTo(sb);
if (!relations.isEmpty()) {
StringUtil.appendTo(sb, relations, " ", null, ",");
}
if (whereCondition != null) {
sb.append(" WHERE ");
whereCondition.appendTo(sb);
}
if (havingCondition != null) {
sb.append(" HAVING ");
havingCondition.appendTo(sb);
}
if (offset != -1) {
sb.append(" OFFSET ").append(offset);
}
if (limit != -1) {
sb.append(" LIMIT ").append(limit);
}
if (groupBy != null) {
sb.append(" GROUP BY ");
StringUtil.append(sb, groupBy, null, null, ", ");
}
if (orderBy != null) {
sb.append(" ORDER BY ");
StringUtil.append(sb, orderBy, null, null, ", ");
}
sb.append(';');
return sb;
}
}
@@ -0,0 +1,29 @@
/*
* 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.sql;
import org.ofbiz.base.util.Appender;
public abstract class SQLStatement<S extends SQLStatement<S, P>, P extends SQLPlan<P>> implements Appender<StringBuilder> {
public abstract <PP extends P> PP plan(Planner<?, ?, ?, ?, ?, ?> planner);
public String toString() {
return appendTo(new StringBuilder()).toString();
}
}
@@ -0,0 +1,96 @@
/*
* 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.sql;
import java.util.Iterator;
import java.util.List;
import org.ofbiz.base.util.StringUtil;
public final class SQLUpdate<P extends UpdatePlan<P>> extends SQLStatement<SQLUpdate<P>, P> {
private final Table table;
private final List<SetField> setFields;
private final Condition whereCondition;
public SQLUpdate(Table table, List<SetField> setFields, Condition whereCondition) {
this.table = table;
this.setFields = setFields;
this.whereCondition = whereCondition;
}
@SuppressWarnings("unchecked")
public <PP extends P> PP plan(Planner<?, ?, ?, ?, ?, ?> planner) {
return (PP) planner.plan(this);
}
public Table getTable() {
return table;
}
public List<SetField> getSetFields() {
return setFields;
}
public Condition getWhereCondition() {
return whereCondition;
}
public StringBuilder appendTo(StringBuilder sb) {
sb.append("UPDATE ");
table.getTableName().appendTo(sb);
// n=4;1+(n-1)*2+3+(n-1)*2+1;3*n+(n-1)*2
// 17
// 18
sb.append(" SET ");
if (setFields.size() <= 3) {
StringUtil.appendTo(sb, setFields, null, null, ", ");
} else {
Iterator<SetField> it = setFields.iterator();
sb.append('(');
while (it.hasNext()) {
SetField setField = it.next();
sb.append(setField.getName());
if (it.hasNext()) {
sb.append(", ");
}
}
sb.append(") = (");
it = setFields.iterator();
while (it.hasNext()) {
SetField setField = it.next();
setField.getValue().appendTo(sb);
if (it.hasNext()) {
sb.append(", ");
}
}
sb.append(')');
it = setFields.iterator();
}
if (table.getJoined() != null) {
sb.append(" FROM ");
table.getJoined().appendToRest(table.getTableName().getAlias(), sb);
}
if (whereCondition != null) {
sb.append(" WHERE ");
whereCondition.appendTo(sb);
}
sb.append(';');
return sb;
}
}
@@ -0,0 +1,50 @@
/*
* 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.sql;
import java.util.ListIterator;
public final class SQLView<P extends ViewPlan<P>> extends SQLStatement<SQLView<P>, P> {
private final String name;
private final SQLSelect sqlSelect;
public SQLView(String name, SQLSelect sqlSelect) {
this.name = name;
this.sqlSelect = sqlSelect;
}
@SuppressWarnings("unchecked")
public <PP extends P> PP plan(Planner<?, ?, ?, ?, ?, ?> planner) {
return (PP) planner.plan(this);
}
public String getName() {
return name;
}
public SQLSelect getSelect() {
return sqlSelect;
}
public StringBuilder appendTo(StringBuilder sb) {
sb.append("CREATE VIEW ").append(name).append(" AS ");
sqlSelect.appendTo(sb);
return sb;
}
}
@@ -0,0 +1,22 @@
/*
* 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.sql;
public abstract class SelectPlan<P extends SelectPlan<P>> extends SQLPlan<P> {
}
@@ -0,0 +1,45 @@
/*
* 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.sql;
import org.ofbiz.base.util.Appender;
public final class SetField implements Appender<StringBuilder> {
private final String name;
private final Value value;
public SetField(String name, Value value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public Value getValue() {
return value;
}
public StringBuilder appendTo(StringBuilder sb) {
sb.append(name).append(" = ");
value.appendTo(sb);
return sb;
}
}
@@ -0,0 +1,23 @@
/*
* 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.sql;
public abstract class StaticValue extends Value {
public abstract String getDefaultName();
}
@@ -0,0 +1,36 @@
/*
* 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.sql;
public final class StringValue extends ConstantValue {
private final String str;
public StringValue(String str) {
this.str = str;
}
public String getString() {
return str;
}
public StringBuilder appendTo(StringBuilder sb) {
sb.append('\'').append(str.replaceAll("'", "''")).append('\'');
return sb;
}
}
@@ -0,0 +1,55 @@
/*
* 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.sql;
import org.ofbiz.base.util.Appender;
public final class Table implements Appender<StringBuilder> {
private final TableName tableName;
private final Joined joined;
public Table(TableName tableName) {
this(tableName, null);
}
public Table(TableName tableName, Joined joined) {
this.tableName = tableName;
this.joined = joined;
}
public TableName getTableName() {
return tableName;
}
public Joined getJoined() {
return joined;
}
public String toString() {
return appendTo(new StringBuilder()).toString();
}
public StringBuilder appendTo(StringBuilder sb) {
tableName.appendTo(sb);
if (joined != null) {
joined.appendTo(tableName.getAlias(), sb);
}
return sb;
}
}
@@ -0,0 +1,51 @@
/*
* 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.sql;
import org.ofbiz.base.util.Appender;
public final class TableName implements Appender<StringBuilder> {
private final String tableName;
private final String alias;
public TableName(String tableName, String alias) {
this.tableName = tableName;
this.alias = alias != null ? alias : tableName;
}
public final String getTableName() {
return tableName;
}
public final String getAlias() {
return alias;
}
public String toString() {
return appendTo(new StringBuilder()).toString();
}
public StringBuilder appendTo(StringBuilder sb) {
sb.append(tableName);
if (!alias.equals(tableName)) {
sb.append(' ').append(alias);
}
return sb;
}
}
@@ -0,0 +1,22 @@
/*
* 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.sql;
public abstract class UpdatePlan<P extends UpdatePlan<P>> extends SQLPlan<P> {
}
@@ -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.sql;
import org.ofbiz.base.util.Appender;
public abstract class Value implements Appender<StringBuilder> {
public String toString() {
return appendTo(new StringBuilder()).toString();
}
}
@@ -0,0 +1,22 @@
/*
* 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.sql;
public abstract class ViewPlan<P extends ViewPlan<P>> extends SQLPlan<P> {
}