http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/manipulation/pgsql/package-info.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/manipulation/pgsql/package-info.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/manipulation/pgsql/package-info.java new file mode 100644 index 0000000..f136488 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/manipulation/pgsql/package-info.java @@ -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. + * + * + */ +/** + * This is package for syntax elements specific for data manipulation for PostgreSQL databases. + */ +package org.apache.polygene.library.sql.generator.grammar.manipulation.pgsql; \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/ColumnSource.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/ColumnSource.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/ColumnSource.java new file mode 100644 index 0000000..7e14967 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/ColumnSource.java @@ -0,0 +1,60 @@ +/* + * 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.polygene.library.sql.generator.grammar.modification; + +import org.apache.polygene.library.sql.generator.Typeable; + +/** + * This is common interface for syntax elements representing the data source for columns in {@code INSERT INTO} + * statement. + * + * @author Stanislav Muhametsin + * @see InsertStatement + */ +public interface ColumnSource + extends Typeable<ColumnSource> +{ + /** + * This syntax element represents when default values of columns are wanted to be inserted into table. + * + * @author Stanislav Muhametsin + */ + final class Defaults + implements ColumnSource + { + private Defaults() + { + + } + + /** + * Returns {@link Defaults}. + */ + public Class<? extends ColumnSource> getImplementedType() + { + return Defaults.class; + } + + /** + * The singleton reference to object of this class. + */ + public static final Defaults INSTANCE = new Defaults(); + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/ColumnSourceByQuery.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/ColumnSourceByQuery.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/ColumnSourceByQuery.java new file mode 100644 index 0000000..c503fcb --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/ColumnSourceByQuery.java @@ -0,0 +1,39 @@ +/* + * 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.polygene.library.sql.generator.grammar.modification; + +import org.apache.polygene.library.sql.generator.grammar.query.QueryExpression; + +/** + * This syntax element represents column source acquired by some query, for {@code INSERT INTO} statement. + * + * @author Stanislav Muhametsin + */ +public interface ColumnSourceByQuery + extends DynamicColumnSource +{ + + /** + * Returns the query to use as column source. + * + * @return The query to use as column source. + */ + QueryExpression getQuery(); +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/ColumnSourceByValues.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/ColumnSourceByValues.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/ColumnSourceByValues.java new file mode 100644 index 0000000..0bf1bb3 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/ColumnSourceByValues.java @@ -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.apache.polygene.library.sql.generator.grammar.modification; + +import java.util.List; +import org.apache.polygene.library.sql.generator.grammar.common.ValueExpression; + +/** + * <p> + * This syntax element represents explicitly defined values for column source in {@code INSERT INTO} + * statement. + * </p> + * + * @author Stanislav Muhametsin + */ +public interface ColumnSourceByValues + extends DynamicColumnSource +{ + /** + * Returns the values to use as column source. + * + * @return The values to use as column source. + */ + List<ValueExpression> getValues(); +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/DeleteBySearch.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/DeleteBySearch.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/DeleteBySearch.java new file mode 100644 index 0000000..4e0f1ab --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/DeleteBySearch.java @@ -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.apache.polygene.library.sql.generator.grammar.modification; + +import org.apache.polygene.library.sql.generator.grammar.booleans.BooleanExpression; + +/** + * This syntax element represents a {@code DELETE FROM} statement. + * + * @author Stanislav Muhametsin + */ +public interface DeleteBySearch + extends DeleteStatement +{ + /** + * Returns the target table for this {@code DELETE FROM} statement. + * + * @return The target table for this {@code DELETE FROM} statement. + */ + TargetTable getTargetTable(); + + /** + * Returns the search condition for rows to delete. + * + * @return The search condition for rows to delete. + */ + BooleanExpression getWhere(); +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/DeleteStatement.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/DeleteStatement.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/DeleteStatement.java new file mode 100644 index 0000000..17dc635 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/DeleteStatement.java @@ -0,0 +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.polygene.library.sql.generator.grammar.modification; + +import org.apache.polygene.library.sql.generator.Typeable; +import org.apache.polygene.library.sql.generator.grammar.common.SQLStatement; + +/** + * A common interface for all statements deleting data from tables. + * + * @author Stanislav Muhametsin + * @see DeleteBySearch + */ +public interface DeleteStatement + extends SQLStatement, Typeable<DeleteStatement> +{ + +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/DynamicColumnSource.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/DynamicColumnSource.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/DynamicColumnSource.java new file mode 100644 index 0000000..9fdcea6 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/DynamicColumnSource.java @@ -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.apache.polygene.library.sql.generator.grammar.modification; + +import org.apache.polygene.library.sql.generator.grammar.common.ColumnNameList; + +/** + * A common interface for column sources with named columns for {@code INSERT INTO} statement. + * + * @author Stanislav Muhametsin + */ +public interface DynamicColumnSource + extends ColumnSource +{ + + /** + * Returns the named columns of this column source. May be null if no column names are + * specified. + * + * @return The named columns of this column source. + */ + ColumnNameList getColumnNames(); +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/InsertStatement.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/InsertStatement.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/InsertStatement.java new file mode 100644 index 0000000..830cbff --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/InsertStatement.java @@ -0,0 +1,48 @@ +/* + * 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.polygene.library.sql.generator.grammar.modification; + +import org.apache.polygene.library.sql.generator.Typeable; +import org.apache.polygene.library.sql.generator.grammar.common.SQLStatement; +import org.apache.polygene.library.sql.generator.grammar.common.TableNameDirect; + +/** + * This syntax element represents a {@code INSERT INTO} statement. + * + * @author Stanislav Muhametsin + */ +public interface InsertStatement + extends SQLStatement, Typeable<InsertStatement> +{ + + /** + * Returns the table name where to insert. + * + * @return The table name where to insert. + */ + TableNameDirect getTableName(); + + /** + * Returns the data source for columns. + * + * @return The data source for columns. + */ + ColumnSource getColumnSource(); +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/SetClause.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/SetClause.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/SetClause.java new file mode 100644 index 0000000..56f955b --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/SetClause.java @@ -0,0 +1,46 @@ +/* + * 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.polygene.library.sql.generator.grammar.modification; + +import org.apache.polygene.library.sql.generator.Typeable; + +/** + * This syntax element represents a single {@code SET} element of {@code UPDATE} statement. + * + * @author Stanislav Muhametsin + */ +public interface SetClause + extends Typeable<SetClause> +{ + + /** + * Returns the update target, typically a name of the column. + * + * @return The update target, typically a name of the column. + */ + String getUpdateTarget(); + + /** + * Returns the update source, that is, data, for the columns. + * + * @return The data for the columns. + */ + UpdateSource getUpdateSource(); +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/TargetTable.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/TargetTable.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/TargetTable.java new file mode 100644 index 0000000..5591608 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/TargetTable.java @@ -0,0 +1,49 @@ +/* + * 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.polygene.library.sql.generator.grammar.modification; + +import org.apache.polygene.library.sql.generator.Typeable; +import org.apache.polygene.library.sql.generator.grammar.common.TableName; +import org.apache.polygene.library.sql.generator.grammar.common.TableNameDirect; + +/** + * This syntax element represents the target table of {@code DELETE FROM} and {@code UPDATE} statements. + * + * @author Stanislav Muhametsin + */ +public interface TargetTable + extends Typeable<TargetTable> +{ + + /** + * Returns whether only this table should be updated (and not, for example, inheriting tables). + * + * @return {@code true} if only this table should be updated; {@code false} otherwise. + */ + Boolean isOnly(); + + /** + * Returns the table name of the target table. + * + * @return The table name of the target table. + * @see TableName + */ + TableNameDirect getTableName(); +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/UpdateBySearch.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/UpdateBySearch.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/UpdateBySearch.java new file mode 100644 index 0000000..82398ad --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/UpdateBySearch.java @@ -0,0 +1,56 @@ +/* + * 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.polygene.library.sql.generator.grammar.modification; + +import java.util.List; +import org.apache.polygene.library.sql.generator.grammar.booleans.BooleanExpression; + +/** + * This syntax element represents {@code UPDATE} statement. + * + * @author Stanislav Muhametsin + */ +public interface UpdateBySearch + extends UpdateStatement +{ + + /** + * Returns the target table of this {@code UPDATE} statement. + * + * @return The target table of this {@code UPDATE} statement. + * @see TargetTable + */ + TargetTable getTargetTable(); + + /** + * Returns the search condition for the rows to be updated. + * + * @return The search condition for the rows to be updated. + */ + BooleanExpression getWhere(); + + /** + * Returns the {@code SET} clauses for columns of the target table. + * + * @return The {@code SET} clauses for columns of the target table. + * @see SetClause + */ + List<SetClause> getSetClauses(); +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/UpdateSource.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/UpdateSource.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/UpdateSource.java new file mode 100644 index 0000000..e6982db --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/UpdateSource.java @@ -0,0 +1,33 @@ +/* + * 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.polygene.library.sql.generator.grammar.modification; + +import org.apache.polygene.library.sql.generator.Typeable; + +/** + * This syntax element represents the data source for column in {@code SET} clause of {@code UPDATE} + * statement. + * + * @author Stanislav Muhametsin + */ +public interface UpdateSource + extends Typeable<UpdateSource> +{ +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/UpdateSourceByExpression.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/UpdateSourceByExpression.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/UpdateSourceByExpression.java new file mode 100644 index 0000000..bd6a4e8 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/UpdateSourceByExpression.java @@ -0,0 +1,39 @@ +/* + * 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.polygene.library.sql.generator.grammar.modification; + +import org.apache.polygene.library.sql.generator.grammar.common.ValueExpression; + +/** + * This syntax element represents the update source having value of whatever expression it holds. + * + * @author Stanislav Muhametsin + */ +public interface UpdateSourceByExpression + extends UpdateSource +{ + + /** + * Returns the value expression to use as value for update source. + * + * @return The value expression to use as value for update source. + */ + ValueExpression getValueExpression(); +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/UpdateStatement.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/UpdateStatement.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/UpdateStatement.java new file mode 100644 index 0000000..bab5554 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/UpdateStatement.java @@ -0,0 +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.polygene.library.sql.generator.grammar.modification; + +import org.apache.polygene.library.sql.generator.Typeable; +import org.apache.polygene.library.sql.generator.grammar.common.SQLStatement; + +/** + * This is common interface for all statements doing updates. + * + * @author Stanislav Muhametsin + * @see UpdateBySearch + */ +public interface UpdateStatement + extends SQLStatement, Typeable<UpdateStatement> +{ + +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/ValueSource.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/ValueSource.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/ValueSource.java new file mode 100644 index 0000000..93c1c06 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/ValueSource.java @@ -0,0 +1,82 @@ +/* + * 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.polygene.library.sql.generator.grammar.modification; + +import org.apache.polygene.library.sql.generator.grammar.common.ValueExpression; + +public class ValueSource +{ + + /** + * This syntax element represents the {@code DEFAULT} keyword as data source for column, meaning + * to use the default value for the column. + * + * @author Stanislav Muhametsin + */ + public static final class Default + implements ValueExpression + { + private Default() + { + + } + + /** + * Returns {@link Default}. + */ + public Class<? extends ValueExpression> getImplementedType() + { + return Default.class; + } + + /** + * Singleton instance of {@link Default}. + */ + public static final Default INSTANCE = new Default(); + } + + /** + * This syntax element represents the {@code NULL} keyword as data source for column, meaning to + * use the {@code NULL} value for the column. + * + * @author Stanislav Muhametsin + */ + public static final class Null + implements ValueExpression + { + private Null() + { + + } + + /** + * Returns {@link Null}. + */ + public Class<? extends ValueExpression> getImplementedType() + { + return Null.class; + } + + /** + * The singleton instance of {@link Null}. + */ + public static final Null INSTANCE = new Null(); + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/package-info.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/package-info.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/package-info.java new file mode 100644 index 0000000..302ab4e --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/package-info.java @@ -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. + * + * + */ +/** + * This package contains syntax elements relevant to SQL modification clauses ({@code INSERT INTO}, {@code DELETE FROM}, and {@code UPDATE}). + */ +package org.apache.polygene.library.sql.generator.grammar.modification; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/pgsql/PgSQLInsertStatement.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/pgsql/PgSQLInsertStatement.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/pgsql/PgSQLInsertStatement.java new file mode 100644 index 0000000..1f88f99 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/pgsql/PgSQLInsertStatement.java @@ -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.apache.polygene.library.sql.generator.grammar.modification.pgsql; + +import org.apache.polygene.library.sql.generator.grammar.modification.InsertStatement; +import org.apache.polygene.library.sql.generator.grammar.query.SelectColumnClause; + +/** + * <p> + * This interface represents {@code INSERT} statement with PostgreSQL-specific elements. + * </p> + * <p> + * <p> + * TODO: {@code WITH RECURSIVE} query + * </p> + * + * @author Stanislav Muhametsin + */ +public interface PgSQLInsertStatement extends InsertStatement +{ + /** + * Gets the columns for the {@code RETURNING} clause. Returns {@code null} if this + * {@code INSERT} statement has no {@code RETURNING} clause. + * + * @return The {@code RETURNING} clause for this statement, or {@code null} if none. + */ + SelectColumnClause getReturningClause(); +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/pgsql/package-info.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/pgsql/package-info.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/pgsql/package-info.java new file mode 100644 index 0000000..86ee8d8 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/modification/pgsql/package-info.java @@ -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. + * + * + */ +/** + * This is package for syntax elements specific for data modification in PostgreSQL databases. + */ +package org.apache.polygene.library.sql.generator.grammar.modification.pgsql; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/AsteriskSelect.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/AsteriskSelect.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/AsteriskSelect.java new file mode 100644 index 0000000..ae995cb --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/AsteriskSelect.java @@ -0,0 +1,31 @@ +/* + * 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.polygene.library.sql.generator.grammar.query; + +/** + * This syntax element represents the asterisk in expression {@code SELECT} *. + * + * @author Stanislav Muhametsin + */ +public interface AsteriskSelect + extends SelectColumnClause +{ + +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/ColumnReference.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/ColumnReference.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/ColumnReference.java new file mode 100644 index 0000000..31472c4 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/ColumnReference.java @@ -0,0 +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.polygene.library.sql.generator.grammar.query; + +import org.apache.polygene.library.sql.generator.grammar.common.NonBooleanExpression; + +/** + * Common interface for columns in expression {@code SELECT <column1>, <column2>, ...}. + * + * @author Stanislav Muhametsin + * @see ColumnReferenceByName + * @see ColumnReferenceByExpression + */ +public interface ColumnReference + extends NonBooleanExpression +{ + +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/ColumnReferenceByExpression.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/ColumnReferenceByExpression.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/ColumnReferenceByExpression.java new file mode 100644 index 0000000..78a72ab --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/ColumnReferenceByExpression.java @@ -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.apache.polygene.library.sql.generator.grammar.query; + +import org.apache.polygene.library.sql.generator.grammar.common.ValueExpression; + +/** + * This syntax element represents the column reference in {@code SELECT <column reference>} clause, where the column + * reference is some kind of expression (for example, a constant, or a query). + * + * @author Stanislav Muhametsin + */ +public interface ColumnReferenceByExpression + extends ColumnReference +{ + + /** + * Gets the expression for this column reference. + * + * @return The expression for this column reference. + */ + ValueExpression getExpression(); +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/ColumnReferenceByName.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/ColumnReferenceByName.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/ColumnReferenceByName.java new file mode 100644 index 0000000..14ae9f2 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/ColumnReferenceByName.java @@ -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.apache.polygene.library.sql.generator.grammar.query; + +/** + * This syntax element represents the column reference in {@code SELECT <column reference>} clause, where the column + * reference is column name, either with table name or without. + * + * @author Stanislav Muhametsin + */ +public interface ColumnReferenceByName + extends ColumnReference +{ + /** + * Gets the table name of this column. Might be {@code null}. + * + * @return The table name of this column. Might be {@code null}. + */ + String getTableName(); + + /** + * Gets the column name of this column. + * + * @return The column name of this column. + */ + String getColumnName(); +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/ColumnReferences.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/ColumnReferences.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/ColumnReferences.java new file mode 100644 index 0000000..915c4b1 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/ColumnReferences.java @@ -0,0 +1,79 @@ +/* + * 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.polygene.library.sql.generator.grammar.query; + +import java.util.List; +import java.util.Objects; + +/** + * This syntax element represents the whole {@code SELECT <column1>, <column2>, ...} clause, up until {@code FROM}. Each + * column might have an alias. + * + * @author Stanislav Muhametsin + */ +public interface ColumnReferences + extends SelectColumnClause +{ + /** + * A helper class to encapsulate column reference along with its alias. + * + * @author Stanislav Muhametsin + */ + class ColumnReferenceInfo + { + private final String _alias; + private final ColumnReference _reference; + + public ColumnReferenceInfo( String alias, ColumnReference reference ) + { + Objects.requireNonNull( reference ); + + this._alias = alias; + this._reference = reference; + } + + /** + * Returns the alias of this column reference. May be {@code null.} + * + * @return The alias of this column reference. May be {@code null.} + */ + public String getAlias() + { + return this._alias; + } + + /** + * Returns the column reference. + * + * @return The column reference. + */ + public ColumnReference getReference() + { + return this._reference; + } + } + + /** + * Returns the list of column references, along with their aliases. + * + * @return The list of column references, along with their aliases. + */ + List<ColumnReferenceInfo> getColumns(); +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/CorrespondingSpec.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/CorrespondingSpec.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/CorrespondingSpec.java new file mode 100644 index 0000000..67d4ee6 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/CorrespondingSpec.java @@ -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.apache.polygene.library.sql.generator.grammar.query; + +import org.apache.polygene.library.sql.generator.Typeable; +import org.apache.polygene.library.sql.generator.grammar.common.ColumnNameList; + +/** + * This syntax element represents the {@code CORRESPONDING BY} clause in {@code UNION}, {@code INTERSECT}, and + * {@code EXCEPT} operations on queries. + * + * @author Stanislav Muhametsin + */ +public interface CorrespondingSpec + extends Typeable<CorrespondingSpec> +{ + /** + * Gets the column name correspondence list. + * + * @return The column name correspondence list. + */ + ColumnNameList getColumnList(); +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/FromClause.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/FromClause.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/FromClause.java new file mode 100644 index 0000000..9ab567d --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/FromClause.java @@ -0,0 +1,43 @@ +/* + * 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.polygene.library.sql.generator.grammar.query; + +import java.util.List; +import org.apache.polygene.library.sql.generator.Typeable; +import org.apache.polygene.library.sql.generator.grammar.query.joins.JoinedTable; + +/** + * This syntax element represents the {@code FROM} clause in {@code SELECT} statement. + * + * @author Stanislav Muhametsin + */ +public interface FromClause + extends Typeable<FromClause> +{ + /** + * Gets all the table references. Each table reference may be a simple reference to table name, sub-query, or a + * joined table. + * + * @return The table references for this {@code FROM} clause. + * @see TableReference + * @see JoinedTable + */ + List<TableReference> getTableReferences(); +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/GroupByClause.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/GroupByClause.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/GroupByClause.java new file mode 100644 index 0000000..90264f2 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/GroupByClause.java @@ -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.apache.polygene.library.sql.generator.grammar.query; + +import java.util.List; +import org.apache.polygene.library.sql.generator.Typeable; + +/** + * This syntax element represents the {@code GROUP BY} clause in {@code SELECT} statement. + * + * @author Stanislav Muhametsin + */ +public interface GroupByClause + extends Typeable<GroupByClause> +{ + /** + * Returns the grouping elements of this {@code GROUP BY} clause. + * + * @return The grouping elements of this {@code GROUP BY} clause. + * @see GroupingElement + */ + List<GroupingElement> getGroupingElements(); +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/GroupingElement.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/GroupingElement.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/GroupingElement.java new file mode 100644 index 0000000..c5b4f55 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/GroupingElement.java @@ -0,0 +1,59 @@ +/* + * 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.polygene.library.sql.generator.grammar.query; + +import org.apache.polygene.library.sql.generator.Typeable; + +/** + * This is a common interface for a grouping element of the {@code GROUP BY} clause. + * + * @author Stanislav Muhametsin + * @see GroupByClause + */ +public interface GroupingElement + extends Typeable<GroupingElement> +{ + /** + * This syntax element represents the grand total grouping element. It is open parenthesis followed by close + * parenthesis. + * + * @author Stanislav Muhametsin + */ + final class GrandTotal + implements GroupingElement + { + private GrandTotal() + { + } + + /** + * Returns {@link GrandTotal} + */ + public Class<? extends GroupingElement> getImplementedType() + { + return GrandTotal.class; + } + + /** + * The singleton instance of {@link GrandTotal}. + */ + public static final GrandTotal INSTANCE = new GrandTotal(); + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/LimitSpecification.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/LimitSpecification.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/LimitSpecification.java new file mode 100644 index 0000000..fb8cbe4 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/LimitSpecification.java @@ -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.apache.polygene.library.sql.generator.grammar.query; + +import org.apache.polygene.library.sql.generator.Typeable; +import org.apache.polygene.library.sql.generator.grammar.common.NonBooleanExpression; + +/** + * This syntax element represents the {@code FETCH FIRST <number> ROWS ONLY} element of the query. This addition has + * been defined in SQL 2008 standard. + * + * @author 2011 Stanislav Muhametsin + */ +public interface LimitSpecification + extends Typeable<LimitSpecification> +{ + /** + * Returns the {@code <number>} element in the {@code FETCH FIRST <number> ROWS ONLY} expression. Means the maximum + * amounts of rows to be selected. + * + * @return The maximum amount of rows to be selected. May be {@code null}, in which case the behaviour is + * vendor-specific. + */ + NonBooleanExpression getCount(); +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/OffsetSpecification.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/OffsetSpecification.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/OffsetSpecification.java new file mode 100644 index 0000000..88b3ecf --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/OffsetSpecification.java @@ -0,0 +1,41 @@ +/* + * 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.polygene.library.sql.generator.grammar.query; + +import org.apache.polygene.library.sql.generator.Typeable; +import org.apache.polygene.library.sql.generator.grammar.common.NonBooleanExpression; + +/** + * This syntax element represents the {@code OFFSET <number> ROWS} element of the query. This addition has been defined + * in SQL 2008 standard. + * + * @author 2011 Stanislav Muhametsin + */ +public interface OffsetSpecification + extends Typeable<OffsetSpecification> +{ + /** + * Returns the {@code <number>} element in the {@code OFFSET <number> ROWS} expression. Means the amount of rows to + * skip before including them into select. + * + * @return The amount of rows to be skipped before starting selecting. + */ + NonBooleanExpression getSkip(); +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/OrderByClause.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/OrderByClause.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/OrderByClause.java new file mode 100644 index 0000000..b1afbb3 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/OrderByClause.java @@ -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.apache.polygene.library.sql.generator.grammar.query; + +import java.util.List; +import org.apache.polygene.library.sql.generator.Typeable; + +/** + * This syntax element represents the {@code ORDER BY} clause of {@code SELECT} statement. + * + * @author Stanislav Muhametsin + */ +public interface OrderByClause + extends Typeable<OrderByClause> +{ + + /** + * Returns the ordering columns of this {@code ORDER BY} clause. + * + * @return The ordering columns of this {@code ORDER BY} clause. + */ + List<SortSpecification> getOrderingColumns(); +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/Ordering.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/Ordering.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/Ordering.java new file mode 100644 index 0000000..01b35cb --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/Ordering.java @@ -0,0 +1,21 @@ +package org.apache.polygene.library.sql.generator.grammar.query; + +/** + * This is enum for what kind of order will be applied to each ordering column. Can be either {@link #ASCENDING} or + * {@link #DESCENDING}. + * + * @author Stanislav Muhametsin + * @see SortSpecification + */ +public final class Ordering +{ + /** + * The ordering will be ascending ({@code ASC}). + */ + public static final Ordering ASCENDING = new Ordering(); + + /** + * The ordering will be descending ({@code DESC}). + */ + public static final Ordering DESCENDING = new Ordering(); +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/OrdinaryGroupingSet.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/OrdinaryGroupingSet.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/OrdinaryGroupingSet.java new file mode 100644 index 0000000..17c9b71 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/OrdinaryGroupingSet.java @@ -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.apache.polygene.library.sql.generator.grammar.query; + +import java.util.List; +import org.apache.polygene.library.sql.generator.grammar.common.NonBooleanExpression; + +/** + * This syntax element represents the ordinary grouping set specification. In future there might be {@code CUBE} or + * {@code ROLLUP} grouping sets. + * + * @author Stanislav Muhametsin + */ +public interface OrdinaryGroupingSet + extends GroupingElement +{ + /** + * Returns the grouping column reference expressions. + * + * @return The grouping column reference expressions. + */ + List<NonBooleanExpression> getColumns(); +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/QueryExpression.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/QueryExpression.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/QueryExpression.java new file mode 100644 index 0000000..b3807e5 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/QueryExpression.java @@ -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.apache.polygene.library.sql.generator.grammar.query; + +import org.apache.polygene.library.sql.generator.grammar.common.NonBooleanExpression; +import org.apache.polygene.library.sql.generator.grammar.common.SQLStatement; + +/** + * This syntax element represents the {@link QueryExpressionBody} and, in future, the WithClause ({@code WITH}) to be + * used with query. + * + * @author Stanislav Muhametsin + */ +public interface QueryExpression + extends NonBooleanExpression, SQLStatement +{ + /** + * Returns the body of this query. + * + * @return The body of this query. + */ + QueryExpressionBody getQueryExpressionBody(); + + // public WithClause getWithClause(); +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/QueryExpressionBody.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/QueryExpressionBody.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/QueryExpressionBody.java new file mode 100644 index 0000000..1df2130 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/QueryExpressionBody.java @@ -0,0 +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.polygene.library.sql.generator.grammar.query; + +import org.apache.polygene.library.sql.generator.grammar.common.NonBooleanExpression; +import org.apache.polygene.library.sql.generator.grammar.query.joins.JoinedTable; + +/** + * This is common interface for a queries and joined tables. + * + * @author Stanislav Muhametsin + * @see QueryExpressionBodyActual + * @see JoinedTable + */ +public interface QueryExpressionBody + extends NonBooleanExpression +{ + /** + * This syntax element represents the empty query expression body. It is defined for convenience. For example, an + * {@code UNION} (or any other set operation) between empty query and another query is always just another query. + * + * @author Stanislav Muhametsin + */ + final class EmptyQueryExpressionBody + implements QueryExpressionBody + { + private EmptyQueryExpressionBody() + { + } + + /** + * Returns {@link EmptyQueryExpressionBody}. + */ + public Class<? extends QueryExpressionBody> getImplementedType() + { + return EmptyQueryExpressionBody.class; + } + + /** + * The singleton instance of {@link EmptyQueryExpressionBody}. + */ + public static final EmptyQueryExpressionBody INSTANCE = new EmptyQueryExpressionBody(); + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/QueryExpressionBodyActual.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/QueryExpressionBodyActual.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/QueryExpressionBodyActual.java new file mode 100644 index 0000000..857aa16 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/QueryExpressionBodyActual.java @@ -0,0 +1,33 @@ +/* + * 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.polygene.library.sql.generator.grammar.query; + +/** + * This is common interface for a query, which is either one {@code SELECT} statement, or many {@code SELECT} statements + * joined together with {@link SetOperation}s. + * + * @author Stanislav Muhametsin + * @see QuerySpecification + */ +public interface QueryExpressionBodyActual + extends QueryExpressionBody +{ + +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/QueryExpressionBodyBinary.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/QueryExpressionBodyBinary.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/QueryExpressionBodyBinary.java new file mode 100644 index 0000000..cc1e211 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/QueryExpressionBodyBinary.java @@ -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.apache.polygene.library.sql.generator.grammar.query; + +import org.apache.polygene.library.sql.generator.grammar.common.SetQuantifier; + +/** + * This syntax element represents two queries which have a set operation ({@code UNION}, {@code INTERSECT}, or + * {@code EXCEPT}) between them. + * + * @author Stanislav Muhametsin + * @see SetOperation + */ +public interface QueryExpressionBodyBinary + extends QueryExpressionBodyActual +{ + /** + * Returns the set operation to put between queries. + * + * @return The set operation to put between queries. + * @see SetOperation + */ + SetOperation getSetOperation(); + + /** + * Returns the correspondence columns. + * + * @return The correspondence columns. + * @see CorrespondingSpec + */ + CorrespondingSpec getCorrespondingColumns(); + + /** + * Returns the query on the left side of the set operation. + * + * @return The query on the left side of the set operation. + */ + QueryExpressionBody getLeft(); + + /** + * Returns the query on the right side of the set operation. + * + * @return The query on the right side of the set operation. + */ + QueryExpressionBody getRight(); + + /** + * Returns the set quantifier for the set operation. + * + * @return The set quantifier for the set operation. + * @see SetQuantifier + */ + SetQuantifier getSetQuantifier(); +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/QueryExpressionBodyQuery.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/QueryExpressionBodyQuery.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/QueryExpressionBodyQuery.java new file mode 100644 index 0000000..f25637a --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/QueryExpressionBodyQuery.java @@ -0,0 +1,32 @@ +/* + * 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.polygene.library.sql.generator.grammar.query; + +/** + * This syntax element represents the single query (currently only {@code SELECT} statement, represented by + * {@link QuerySpecification}. + * + * @author Stanislav Muhametsin + */ +public interface QueryExpressionBodyQuery + extends QueryExpressionBodyActual +{ + +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/QuerySpecification.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/QuerySpecification.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/QuerySpecification.java new file mode 100644 index 0000000..b35be17 --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/QuerySpecification.java @@ -0,0 +1,95 @@ +/* + * 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.polygene.library.sql.generator.grammar.query; + +import org.apache.polygene.library.sql.generator.grammar.booleans.BooleanExpression; +import org.apache.polygene.library.sql.generator.grammar.builders.query.QuerySpecificationBuilder; + +/** + * This syntax element represents the single {@code SELECT} statement. + * + * @author Stanislav Muhametsin + * @see QuerySpecificationBuilder + * @see SelectColumnClause + * @see FromClause + * @see BooleanExpression + * @see GroupByClause + * @see OrderByClause + */ +public interface QuerySpecification + extends QueryExpressionBodyQuery +{ + + /** + * Returns the columns in this {@code SELECT} statement. + * + * @return The columns in this {@code SELECT} statement. + */ + SelectColumnClause getColumns(); + + /** + * Returns the {@code FROM} clause of this {@code SELECT} statement. + * + * @return The {@code FROM} clause of this {@code SELECT} statement. + */ + FromClause getFrom(); + + /** + * Returns the search condition for resulting rows of this {@code SELECT} statement. + * + * @return The search condition for resulting rows of this {@code SELECT} statement. + */ + BooleanExpression getWhere(); + + /** + * Returns the {@code GROUP BY} clause of this {@code SELECT} statement. + * + * @return The {@code GROUP BY} clause of this {@code SELECT} statement. + */ + GroupByClause getGroupBy(); + + /** + * Returns the grouping condition for {@code GROUP BY} clause of this {@code SELECT} statement. + * + * @return The grouping condition for {@code GROUP BY} clause of this {@code SELECT} statement. + */ + BooleanExpression getHaving(); + + /** + * Returns the {@code ORDER BY} clause of this {@code SELECT} statement. + * + * @return The {@code ORDER BY} clause of this {@code SELECT} statement. + */ + OrderByClause getOrderBy(); + + /** + * Returns the {@code FETCH FIRST <number> ROWS ONLY} expression for this {@code SELECT} statement. + * + * @return The {@code FETCH FIRST <number> ROWS ONLY} expression for this {@code SELECT} statement. + */ + LimitSpecification getLimitSpecification(); + + /** + * Returns the {@code OFFSET <number> ROWS} expression for this {@code SELECT} statement. + * + * @return The {@code OFFSET <number> ROWS} expression for this {@code SELECT} statement. + */ + OffsetSpecification getOffsetSpecification(); +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/RowDefinition.java ---------------------------------------------------------------------- diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/RowDefinition.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/RowDefinition.java new file mode 100644 index 0000000..dcdf6bb --- /dev/null +++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/RowDefinition.java @@ -0,0 +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.polygene.library.sql.generator.grammar.query; + +import java.util.List; +import org.apache.polygene.library.sql.generator.grammar.common.ValueExpression; + +/** + * This syntax element represents a comma-separated row value definition of {@code VALUES} expression in query. + * + * @author Stanislav Muhametsin + */ +public interface RowDefinition + extends RowValueConstructor +{ + + List<ValueExpression> getRowElements(); +}
