You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by ni...@apache.org on 2017/04/15 08:26:09 UTC
[18/19] polygene-java git commit: Bring in Stanislav's sql-generator
from GutHub, after his consent in
https://lists.apache.org/thread.html/797352ce2ad7aa7b755720a98f545a176e6050e35f56db113ba115fb@%3Cdev.polygene.apache.org%3E
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/booleans/BooleanExpression.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/BooleanExpression.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/BooleanExpression.java
new file mode 100644
index 0000000..79cd276
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/BooleanExpression.java
@@ -0,0 +1,86 @@
+/*
+ * 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.booleans;
+
+import org.apache.polygene.library.sql.generator.grammar.common.ValueExpression;
+
+/**
+ * A common interface for all boolean expressions in SQL language.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface BooleanExpression
+ extends ValueExpression
+{
+
+ /**
+ * This class represents a boolean expression which always evaluates to true ({@code TRUE}).
+ *
+ * @author Stanislav Muhametsin
+ */
+ final class True
+ implements BooleanExpression
+ {
+ private True()
+ {
+
+ }
+
+ /**
+ * Returns {@link True}.
+ */
+ public Class<? extends ValueExpression> getImplementedType()
+ {
+ return True.class;
+ }
+
+ /**
+ * Returns the singleton instance representing {@code TRUE}.
+ */
+ public static final True INSTANCE = new True();
+ }
+
+ /**
+ * This class represents a boolean expression which always evaluates to false ({@code FALSE}.
+ *
+ * @author Stanislav Muhametsin
+ */
+ final class False
+ implements BooleanExpression
+ {
+ private False()
+ {
+
+ }
+
+ /**
+ * Returns {@link False}.
+ */
+ public Class<? extends ValueExpression> getImplementedType()
+ {
+ return False.class;
+ }
+
+ /**
+ * Returns the singleton instance representing {@code FALSE}.
+ */
+ public static final False INSTANCE = new False();
+ }
+}
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/booleans/BooleanTest.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/BooleanTest.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/BooleanTest.java
new file mode 100644
index 0000000..9d0a05b
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/BooleanTest.java
@@ -0,0 +1,94 @@
+/*
+ * 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.booleans;
+
+/**
+ * The interface for syntax element representing {@code <X> IS [NOT] (TRUE | FALSE | UNKNOWN)} expression (boolean
+ * test), where {@code <X>} is some boolean expression.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface BooleanTest
+ extends ComposedBooleanExpression
+{
+ /**
+ * The type of the test.
+ *
+ * @author Stanislav Muhametsin
+ */
+ final class TestType
+ {
+
+ /**
+ * The test which tests the expression against the truth value.
+ */
+ public static final TestType IS = new TestType();
+
+ /**
+ * The test which tests the expression against the negation of the truth value.
+ */
+ public static final TestType IS_NOT = new TestType();
+ }
+
+ /**
+ * The tested truth value.
+ *
+ * @author Stanislav Muhametsin
+ */
+ final class TruthValue
+ {
+
+ /**
+ * The {@code TRUE} truth value.
+ */
+ public static final TruthValue TRUE = new TruthValue();
+
+ /**
+ * The {@code FALSE} truth value.
+ */
+ public static final TruthValue FALSE = new TruthValue();
+
+ /**
+ * The {@code UNKNOWN} truth value.
+ */
+ public static final TruthValue UNKNOWN = new TruthValue();
+ }
+
+ /**
+ * Returns the boolean expression to be tested.
+ *
+ * @return The boolean expression to be tested.
+ */
+ BooleanExpression getBooleanExpression();
+
+ /**
+ * Returns the test type - whether it should, or should not, be something.
+ *
+ * @return The test type.
+ */
+ TestType getTestType();
+
+ /**
+ * The truth value which must evaluate from the expression.
+ *
+ * @return The truth value which must evaluate from the expression.
+ */
+ TruthValue getTruthValue();
+}
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/booleans/ComposedBooleanExpression.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/ComposedBooleanExpression.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/ComposedBooleanExpression.java
new file mode 100644
index 0000000..1dbeb76
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/ComposedBooleanExpression.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.booleans;
+
+/**
+ * A common interface for all boolean expressions composing of other boolean expressions.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface ComposedBooleanExpression
+ extends BooleanExpression, Iterable<BooleanExpression>
+{
+
+}
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/booleans/Conjunction.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/Conjunction.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/Conjunction.java
new file mode 100644
index 0000000..33b6e29
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/Conjunction.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.booleans;
+
+/**
+ * A conjunction ({@code AND}) of two boolean expressions.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface Conjunction
+ extends ComposedBooleanExpression
+{
+
+ /**
+ * Returns the boolean expression on the left side of {@code AND}.
+ *
+ * @return The boolean expression on the left side of {@code AND}.
+ */
+ BooleanExpression getLeft();
+
+ /**
+ * Returns the boolean expression on the right side of {@code AND}.
+ *
+ * @return The boolean expression on the right side of {@code AND}.
+ */
+ BooleanExpression getRight();
+}
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/booleans/Disjunction.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/Disjunction.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/Disjunction.java
new file mode 100644
index 0000000..b9725ff
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/Disjunction.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.booleans;
+
+/**
+ * A disjunction ({@code OR} of two boolean expressions.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface Disjunction
+ extends ComposedBooleanExpression
+{
+ /**
+ * Returns the boolean expression on the left side of {@code OR}.
+ *
+ * @return The boolean expression on the left side of {@code OR}.
+ */
+ BooleanExpression getLeft();
+
+ /**
+ * Returns the boolean expression on the right side of {@code OR}.
+ *
+ * @return The boolean expression on the right side of {@code OR}.
+ */
+ BooleanExpression getRight();
+}
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/booleans/EqualsPredicate.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/EqualsPredicate.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/EqualsPredicate.java
new file mode 100644
index 0000000..9aad53b
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/EqualsPredicate.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.booleans;
+
+/**
+ * The interface for syntax element representing equality test (x {@code =} y).
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface EqualsPredicate
+ extends BinaryPredicate
+{
+
+}
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/booleans/ExistsPredicate.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/ExistsPredicate.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/ExistsPredicate.java
new file mode 100644
index 0000000..bb203d5
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/ExistsPredicate.java
@@ -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.apache.polygene.library.sql.generator.grammar.booleans;
+
+import org.apache.polygene.library.sql.generator.grammar.query.QueryExpression;
+
+/**
+ * The interface for syntax element representing existence test ({@code EXISTS}).
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface ExistsPredicate
+ extends UnaryPredicate
+{
+ /**
+ * Returns the query on which {@code EXISTS} operates on.
+ */
+ QueryExpression 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/booleans/GreaterOrEqualPredicate.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/GreaterOrEqualPredicate.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/GreaterOrEqualPredicate.java
new file mode 100644
index 0000000..ac5d684
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/GreaterOrEqualPredicate.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.booleans;
+
+/**
+ * The interface for syntax element representing the test of left value being greater than, or equal to right value (x
+ * {@code >=} y).
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface GreaterOrEqualPredicate
+ extends BinaryPredicate
+{
+
+}
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/booleans/GreaterThanPredicate.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/GreaterThanPredicate.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/GreaterThanPredicate.java
new file mode 100644
index 0000000..9132336
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/GreaterThanPredicate.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.booleans;
+
+/**
+ * The interface for syntax element representing the test of left value being greater than right value (x {@code >} y).
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface GreaterThanPredicate
+ extends BinaryPredicate
+{
+
+}
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/booleans/InPredicate.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/InPredicate.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/InPredicate.java
new file mode 100644
index 0000000..2326f5f
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/InPredicate.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.booleans;
+
+/**
+ * The interface for syntax element representing the test of something being one of the specified set of values (x
+ * {@code IN (}y, z, {@code ...)}).
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface InPredicate
+ extends MultiPredicate
+{
+}
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/booleans/IsNotNullPredicate.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/IsNotNullPredicate.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/IsNotNullPredicate.java
new file mode 100644
index 0000000..956cfb7
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/IsNotNullPredicate.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.booleans;
+
+/**
+ * The interface for syntax element representing test for something being not {@code NULL} (x {@code IS NOT NULL}).
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface IsNotNullPredicate
+ extends UnaryPredicate
+{
+
+}
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/booleans/IsNullPredicate.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/IsNullPredicate.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/IsNullPredicate.java
new file mode 100644
index 0000000..7612fbe
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/IsNullPredicate.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.booleans;
+
+/**
+ * The interface for syntax element representing test for something being {@code NULL} (x {@code IS NULL}).
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface IsNullPredicate
+ extends UnaryPredicate
+{
+
+}
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/booleans/LessOrEqualPredicate.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/LessOrEqualPredicate.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/LessOrEqualPredicate.java
new file mode 100644
index 0000000..61f78dc
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/LessOrEqualPredicate.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.booleans;
+
+/**
+ * The interface for syntax element representing the test of left value being lesser than, or equal to right value (x
+ * {@code <=} y).
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface LessOrEqualPredicate
+ extends BinaryPredicate
+{
+
+}
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/booleans/LessThanPredicate.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/LessThanPredicate.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/LessThanPredicate.java
new file mode 100644
index 0000000..fc89053
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/LessThanPredicate.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.booleans;
+
+/**
+ * The interface for syntax element representing the test of left value being less than right value (x {@code <} y).
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface LessThanPredicate
+ extends BinaryPredicate
+{
+
+}
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/booleans/LikePredicate.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/LikePredicate.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/LikePredicate.java
new file mode 100644
index 0000000..3c213d4
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/LikePredicate.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.booleans;
+
+/**
+ * The interface for syntax element representing the test of left expression matching the supplied pattern using basic
+ * SQL match (x {@code LIKE} y).
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface LikePredicate
+ extends BinaryPredicate
+{
+
+}
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/booleans/MultiPredicate.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/MultiPredicate.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/MultiPredicate.java
new file mode 100644
index 0000000..955c103
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/MultiPredicate.java
@@ -0,0 +1,47 @@
+/*
+ * 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.booleans;
+
+import java.util.List;
+import org.apache.polygene.library.sql.generator.grammar.common.NonBooleanExpression;
+
+/**
+ * A common interface for all predicates accepting more than two expressions.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface MultiPredicate
+ extends Predicate
+{
+
+ /**
+ * Returns the expression on the left side (the first expression).
+ *
+ * @return The first expression.
+ */
+ NonBooleanExpression getLeft();
+
+ /**
+ * Returns the remaining expressions after the first one.
+ *
+ * @return The remaining expressions after the first one.
+ */
+ List<NonBooleanExpression> getRights();
+}
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/booleans/Negation.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/Negation.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/Negation.java
new file mode 100644
index 0000000..2a34115
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/Negation.java
@@ -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.apache.polygene.library.sql.generator.grammar.booleans;
+
+/**
+ * A negation ({@code NOT} x) of a boolean expression.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface Negation
+ extends ComposedBooleanExpression
+{
+
+ /**
+ * Returns the boolean expression being negated.
+ *
+ * @return The boolean expression being negated.
+ */
+ BooleanExpression getNegated();
+}
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/booleans/NotBetweenPredicate.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/NotBetweenPredicate.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/NotBetweenPredicate.java
new file mode 100644
index 0000000..c1f7c1f
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/NotBetweenPredicate.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.booleans;
+
+import org.apache.polygene.library.sql.generator.grammar.common.NonBooleanExpression;
+
+/**
+ * The interface for syntax element representing SQL expression {@code NOT BETWEEN} x {@code AND} y.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface NotBetweenPredicate
+ extends MultiPredicate
+{
+ /**
+ * Returns the minimum value (the expression on the left side of {@code AND}).
+ *
+ * @return The minimum value.
+ */
+ NonBooleanExpression getMinimum();
+
+ /**
+ * Returns the maxmimum value (the expression on the right side of {@code AND}).
+ *
+ * @return The maximum value.
+ */
+ NonBooleanExpression getMaximum();
+}
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/booleans/NotEqualsPredicate.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/NotEqualsPredicate.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/NotEqualsPredicate.java
new file mode 100644
index 0000000..c6e69fc
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/NotEqualsPredicate.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.booleans;
+
+/**
+ * The interface for syntax element representing inequality test (x {@code <>} y).
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface NotEqualsPredicate
+ extends BinaryPredicate
+{
+
+}
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/booleans/NotInPredicate.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/NotInPredicate.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/NotInPredicate.java
new file mode 100644
index 0000000..cb9addd
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/NotInPredicate.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.booleans;
+
+/**
+ * The interface for syntax element representing the test of something not being one of the specified set of values (x
+ * {@code NOT IN (}y, z, {@code ...)}).
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface NotInPredicate
+ extends MultiPredicate
+{
+
+}
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/booleans/NotLikePredicate.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/NotLikePredicate.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/NotLikePredicate.java
new file mode 100644
index 0000000..efc3a4d
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/NotLikePredicate.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.booleans;
+
+/**
+ * The interface for syntax element representing the test of left expression not matching the supplied pattern using
+ * basic SQL match (x {@code NOT LIKE} y).
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface NotLikePredicate
+ extends BinaryPredicate
+{
+
+}
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/booleans/NotRegexpPredicate.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/NotRegexpPredicate.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/NotRegexpPredicate.java
new file mode 100644
index 0000000..7f83dcc
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/NotRegexpPredicate.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.booleans;
+
+/**
+ * The interface for syntax element representing the test of left expression not matching the supplied pattern using
+ * advanced regular expression match (operator varies). By default this kind of matching is not supported.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface NotRegexpPredicate
+ extends BinaryPredicate
+{
+
+}
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/booleans/Predicate.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/Predicate.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/Predicate.java
new file mode 100644
index 0000000..c58cf58
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/Predicate.java
@@ -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.apache.polygene.library.sql.generator.grammar.booleans;
+
+/**
+ * A common interfaces for predicates (boolean expressions not containing other boolean expressions).
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface Predicate
+ extends BooleanExpression
+{
+ /**
+ * A class representing empty predicate. The result of empty predicate is empty string. If empty predicate is
+ * encountered inside {@link Conjunction} or {@link Disjunction}, their operator is omitted. So, <i>empty
+ * predicate</i> {@code AND} <i>something</i> becomes just <i>something</i>.
+ *
+ * @author Stanislav Muhametsin
+ */
+ final class EmptyPredicate
+ implements Predicate
+ {
+ private EmptyPredicate()
+ {
+ }
+
+ /**
+ * Returns {@link EmptyPredicate}.
+ */
+ public Class<? extends BooleanExpression> getImplementedType()
+ {
+ return EmptyPredicate.class;
+ }
+
+ /**
+ * Singleton instance of {@link EmptyPredicate}.
+ */
+ public static final EmptyPredicate INSTANCE = new EmptyPredicate();
+ }
+}
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/booleans/RegexpPredicate.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/RegexpPredicate.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/RegexpPredicate.java
new file mode 100644
index 0000000..f44732b
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/RegexpPredicate.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.booleans;
+
+/**
+ * The interface for syntax element representing the test of left expression matching the supplied pattern using
+ * advanced regular expression match (operator varies). By default this kind of matching is not supported.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface RegexpPredicate
+ extends BinaryPredicate
+{
+}
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/booleans/UnaryPredicate.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/UnaryPredicate.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/UnaryPredicate.java
new file mode 100644
index 0000000..37aed37
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/UnaryPredicate.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.booleans;
+
+import org.apache.polygene.library.sql.generator.grammar.common.NonBooleanExpression;
+
+/**
+ * A common interface for all boolean expressions requiring exactly one value expression.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface UnaryPredicate
+ extends Predicate
+{
+
+ /**
+ * Returns the value expression for this predicate.
+ *
+ * @return The value expression for this predicate.
+ */
+ NonBooleanExpression 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/booleans/UniquePredicate.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/UniquePredicate.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/UniquePredicate.java
new file mode 100644
index 0000000..f91eeab
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/UniquePredicate.java
@@ -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.apache.polygene.library.sql.generator.grammar.booleans;
+
+import org.apache.polygene.library.sql.generator.grammar.query.QueryExpression;
+
+/**
+ * The interface for syntax element representing the test for uniqueness ({@code UNIQUE} sub-query).
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface UniquePredicate
+ extends UnaryPredicate
+{
+
+ /**
+ * Gets the query on which {@code UNIQUE} operates on.
+ */
+ QueryExpression 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/booleans/package-info.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/package-info.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/package-info.java
new file mode 100644
index 0000000..5d5fd7f
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/booleans/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 provides interfaces for syntax elements of boolean expressions in SQL language. As all syntax elements, they provide a read-only API to their contents.
+ */
+package org.apache.polygene.library.sql.generator.grammar.booleans;
\ 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/builders/AbstractBuilder.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/builders/AbstractBuilder.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/builders/AbstractBuilder.java
new file mode 100644
index 0000000..a938b1b
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/builders/AbstractBuilder.java
@@ -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.apache.polygene.library.sql.generator.grammar.builders;
+
+/**
+ * A common interface for all builders.
+ *
+ * @param <ExpressionType> The type of the expression being built.
+ * @author Stanislav Muhametsin
+ */
+public interface AbstractBuilder<ExpressionType>
+{
+ /**
+ * Returns the expression which was being built by this builder.
+ *
+ * @return The expression built by this builder.
+ */
+ ExpressionType createExpression();
+}
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/builders/booleans/BooleanBuilder.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/builders/booleans/BooleanBuilder.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/builders/booleans/BooleanBuilder.java
new file mode 100644
index 0000000..7788daa
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/builders/booleans/BooleanBuilder.java
@@ -0,0 +1,65 @@
+/*
+ * 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.builders.booleans;
+
+import org.apache.polygene.library.sql.generator.grammar.booleans.BooleanExpression;
+import org.apache.polygene.library.sql.generator.grammar.builders.AbstractBuilder;
+
+/**
+ * A builder-pattern interface to build boolean expressions. It holds the current expression, modifying it as per user's
+ * instructions, and returns it once the {@link #createExpression()} method is called.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface BooleanBuilder
+ extends AbstractBuilder<BooleanExpression>
+{
+
+ /**
+ * Sets current expression as current expression {@code AND next}.
+ *
+ * @param next The expression on a right hand of {@code AND}.
+ * @return This builder.
+ */
+ BooleanBuilder and( BooleanExpression next );
+
+ /**
+ * Sets current expression as current expression {@code OR next}
+ *
+ * @param next The expression on a right hand of {@code OR}
+ * @return This builder.
+ */
+ BooleanBuilder or( BooleanExpression next );
+
+ /**
+ * Sets current expression as {@code NOT} current expression.
+ *
+ * @return This builder.
+ */
+ BooleanBuilder not();
+
+ /**
+ * Sets current expression as given parameter.
+ *
+ * @param newExpression The new expression.
+ * @return This builder.
+ */
+ BooleanBuilder reset( BooleanExpression newExpression );
+}
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/builders/booleans/InBuilder.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/builders/booleans/InBuilder.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/builders/booleans/InBuilder.java
new file mode 100644
index 0000000..23295ed
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/builders/booleans/InBuilder.java
@@ -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.apache.polygene.library.sql.generator.grammar.builders.booleans;
+
+import org.apache.polygene.library.sql.generator.grammar.booleans.InPredicate;
+import org.apache.polygene.library.sql.generator.grammar.builders.AbstractBuilder;
+import org.apache.polygene.library.sql.generator.grammar.common.NonBooleanExpression;
+
+/**
+ * The builder to build {@code IN} expressions
+ *
+ * @author Stanislav Muhametsin
+ * @see InPredicate
+ */
+public interface InBuilder
+ extends AbstractBuilder<InPredicate>
+{
+
+ InBuilder addValues( NonBooleanExpression... expressions );
+}
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/builders/booleans/package-info.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/builders/booleans/package-info.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/builders/booleans/package-info.java
new file mode 100644
index 0000000..2f741fb
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/builders/booleans/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 builders for various boolean expressions.
+ */
+package org.apache.polygene.library.sql.generator.grammar.builders.booleans;
\ 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/builders/definition/ForeignKeyConstraintBuilder.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/builders/definition/ForeignKeyConstraintBuilder.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/builders/definition/ForeignKeyConstraintBuilder.java
new file mode 100644
index 0000000..50cbeeb
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/builders/definition/ForeignKeyConstraintBuilder.java
@@ -0,0 +1,133 @@
+/*
+ * 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.builders.definition;
+
+import java.util.List;
+import org.apache.polygene.library.sql.generator.grammar.builders.AbstractBuilder;
+import org.apache.polygene.library.sql.generator.grammar.common.TableNameDirect;
+import org.apache.polygene.library.sql.generator.grammar.definition.table.ForeignKeyConstraint;
+import org.apache.polygene.library.sql.generator.grammar.definition.table.MatchType;
+import org.apache.polygene.library.sql.generator.grammar.definition.table.ReferentialAction;
+
+/**
+ * The builder for table constraint {@code FOREIGN KEY(source columns) REFERENCES table_name(target columns) etc....}).
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface ForeignKeyConstraintBuilder
+ extends AbstractBuilder<ForeignKeyConstraint>
+{
+
+ /**
+ * Adds source column names to this foreign key constraint.
+ *
+ * @param columnNames The source column names to be added to this foreign key constraint.
+ * @return This builder.
+ */
+ ForeignKeyConstraintBuilder addSourceColumns( String... columnNames );
+
+ /**
+ * Adds target column names to this foreign key constraint.
+ *
+ * @param columnNames The target column names to be added to this foreign key constraint.
+ * @return This builder.
+ */
+ ForeignKeyConstraintBuilder addTargetColumns( String... columnNames );
+
+ /**
+ * Sets the target table name for this foreign key constraint.
+ *
+ * @param tableName The target table name for this foreign key constraint.
+ * @return This builder.
+ */
+ ForeignKeyConstraintBuilder setTargetTableName( TableNameDirect tableName );
+
+ /**
+ * Sets the match type for this foreign key constraint.
+ *
+ * @param matchType The match type for this foreign key constraint.
+ * @return This builder.
+ * @see MatchType
+ */
+ ForeignKeyConstraintBuilder setMatchType( MatchType matchType );
+
+ /**
+ * Sets the {@code ON UPDATE} action.
+ *
+ * @param action The action to perform {@code ON UPDATE}.
+ * @return This builder.
+ * @see ReferentialAction
+ */
+ ForeignKeyConstraintBuilder setOnUpdate( ReferentialAction action );
+
+ /**
+ * Sets the {@code ON DELETE} action.
+ *
+ * @param action The action to perform {@code ON DELETE}.
+ * @return This builder.
+ * @see ReferentialAction
+ */
+ ForeignKeyConstraintBuilder setOnDelete( ReferentialAction action );
+
+ /**
+ * Returns the source column names for this foreign key constraint.
+ *
+ * @return The source column names for this foreign key constraint.
+ */
+ List<String> getSourceColumns();
+
+ /**
+ * Returns the target column names for this foreign key constraint.
+ *
+ * @return The target column names for this foreign key constraint.
+ */
+ List<String> getTargetColumns();
+
+ /**
+ * Returns the target table name for this foreign key constraint.
+ *
+ * @return The target table name for this foreign key constraint.
+ */
+ TableNameDirect getTableName();
+
+ /**
+ * Returns the match type for this foreign key constraint.
+ *
+ * @return The match type for this foreign key constraint.
+ * @see MatchType
+ */
+ MatchType getMatchType();
+
+ /**
+ * Returns the {@code ON UPDATE} action for this foreign key constraint.
+ *
+ * @return The {@code ON UPDATE} action for this foreign key constraint.
+ * @see ReferentialAction
+ */
+ ReferentialAction getOnUpdate();
+
+ /**
+ * Returns the {@code ON DELETE} action for this foreign key constraint.
+ *
+ * @return The {@code ON DELETE} action for this foreign key constraint.
+ * @see ReferentialAction
+ */
+ ReferentialAction getOnDelete();
+}
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/builders/definition/SchemaDefinitionBuilder.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/builders/definition/SchemaDefinitionBuilder.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/builders/definition/SchemaDefinitionBuilder.java
new file mode 100644
index 0000000..6f1080a
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/builders/definition/SchemaDefinitionBuilder.java
@@ -0,0 +1,81 @@
+/*
+ * 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.builders.definition;
+
+import java.util.List;
+import org.apache.polygene.library.sql.generator.grammar.builders.AbstractBuilder;
+import org.apache.polygene.library.sql.generator.grammar.definition.schema.SchemaDefinition;
+import org.apache.polygene.library.sql.generator.grammar.definition.schema.SchemaElement;
+
+/**
+ * This is builder interface for creating schema definition statements ({@code CREATE SCHEMA} ...).
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface SchemaDefinitionBuilder
+ extends AbstractBuilder<SchemaDefinition>
+{
+
+ /**
+ * Sets the name for the schema to be created.
+ *
+ * @param schemaName The name for the schema to be created.
+ * @return This builder.
+ */
+ SchemaDefinitionBuilder setSchemaName( String schemaName );
+
+ /**
+ * Sets the character set for the schema to be created.
+ *
+ * @param charset The charset for the schema to be created.
+ * @return This builder.
+ */
+ SchemaDefinitionBuilder setSchemaCharset( String charset );
+
+ /**
+ * Adds schema elements for the schema to be created.
+ *
+ * @param elements The schema elements for the schema to be created.
+ * @return This builder.
+ * @see SchemaElement
+ */
+ SchemaDefinitionBuilder addSchemaElements( SchemaElement... elements );
+
+ /**
+ * Returns the name of the schema to be created.
+ *
+ * @return The name of the schema to be created.
+ */
+ String getSchemaName();
+
+ /**
+ * Returns the name of the character set for the schema to be created.
+ *
+ * @return The name of the character set for the schema to be created.
+ */
+ String getSchemaCharset();
+
+ /**
+ * Returns all the schema elements for the schema to be created.
+ *
+ * @return All the schema elements for the schema to be created.
+ */
+ List<SchemaElement> getSchemaElements();
+}
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/builders/definition/TableDefinitionBuilder.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/builders/definition/TableDefinitionBuilder.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/builders/definition/TableDefinitionBuilder.java
new file mode 100644
index 0000000..ed65f94
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/builders/definition/TableDefinitionBuilder.java
@@ -0,0 +1,104 @@
+/*
+ * 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.builders.definition;
+
+import org.apache.polygene.library.sql.generator.grammar.builders.AbstractBuilder;
+import org.apache.polygene.library.sql.generator.grammar.common.TableName;
+import org.apache.polygene.library.sql.generator.grammar.common.TableNameDirect;
+import org.apache.polygene.library.sql.generator.grammar.definition.table.TableCommitAction;
+import org.apache.polygene.library.sql.generator.grammar.definition.table.TableContentsSource;
+import org.apache.polygene.library.sql.generator.grammar.definition.table.TableDefinition;
+import org.apache.polygene.library.sql.generator.grammar.definition.table.TableElementList;
+import org.apache.polygene.library.sql.generator.grammar.definition.table.TableScope;
+
+/**
+ * This is the builder for table definition statements ({@code CREATE TABLE} ...).
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface TableDefinitionBuilder
+ extends AbstractBuilder<TableDefinition>
+{
+
+ /**
+ * Sets the scope for this table.
+ *
+ * @param scope The scope for this table.
+ * @return This builder.
+ * @see TableScope
+ */
+ TableDefinitionBuilder setTableScope( TableScope scope );
+
+ /**
+ * Sets the name for this table.
+ *
+ * @param tableName The name for this table.
+ * @return This builder.
+ * @see TableName
+ */
+ TableDefinitionBuilder setTableName( TableNameDirect tableName );
+
+ /**
+ * Sets the commit action for this table.
+ *
+ * @param commitAction The commit action for this table.
+ * @return This builder.
+ * @see TableCommitAction
+ */
+ TableDefinitionBuilder setCommitAction( TableCommitAction commitAction );
+
+ /**
+ * Sets the contents source for this table.
+ *
+ * @param contents The contents source for this table.
+ * @return This builder.
+ * @see TableContentsSource
+ * @see TableElementList
+ */
+ TableDefinitionBuilder setTableContentsSource( TableContentsSource contents );
+
+ /**
+ * Returns the scope for this table.
+ *
+ * @return The scope for this table.
+ */
+ TableScope getTableScope();
+
+ /**
+ * Returns the name for this table.
+ *
+ * @return The name for this table.
+ */
+ TableNameDirect getTableName();
+
+ /**
+ * Returns the commit action for this table.
+ *
+ * @return The commit action for this table.
+ */
+ TableCommitAction getCommitAction();
+
+ /**
+ * Returns the table contents source for this table.
+ *
+ * @return The table contents source for this table.
+ */
+ TableContentsSource getTableContentsSource();
+}
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/builders/definition/TableElementListBuilder.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/builders/definition/TableElementListBuilder.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/builders/definition/TableElementListBuilder.java
new file mode 100644
index 0000000..50defa2
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/builders/definition/TableElementListBuilder.java
@@ -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.apache.polygene.library.sql.generator.grammar.builders.definition;
+
+import java.util.List;
+import org.apache.polygene.library.sql.generator.grammar.builders.AbstractBuilder;
+import org.apache.polygene.library.sql.generator.grammar.definition.table.TableElement;
+import org.apache.polygene.library.sql.generator.grammar.definition.table.TableElementList;
+
+/**
+ * This is the builder for table element list used in {@code CREATE TABLE} statements.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface TableElementListBuilder
+ extends AbstractBuilder<TableElementList>
+{
+
+ /**
+ * Adds the table element to this list.
+ *
+ * @param element The table element to add to this list.
+ * @return This builder.
+ */
+ TableElementListBuilder addTableElement( TableElement element );
+
+ /**
+ * Returns all the elements that this builder has.
+ *
+ * @return All the elements that this builder has.
+ */
+ List<TableElement> getTableElements();
+}
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/builders/definition/UniqueConstraintBuilder.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/builders/definition/UniqueConstraintBuilder.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/builders/definition/UniqueConstraintBuilder.java
new file mode 100644
index 0000000..4dfc67c
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/builders/definition/UniqueConstraintBuilder.java
@@ -0,0 +1,66 @@
+/*
+ * 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.builders.definition;
+
+import java.util.List;
+import org.apache.polygene.library.sql.generator.grammar.builders.AbstractBuilder;
+import org.apache.polygene.library.sql.generator.grammar.definition.table.UniqueConstraint;
+import org.apache.polygene.library.sql.generator.grammar.definition.table.UniqueSpecification;
+
+/**
+ * This is builder for {@code UNIQUE(...)} and {@code PRIMARY KEY(...)} table constraints in table definition.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface UniqueConstraintBuilder
+ extends AbstractBuilder<UniqueConstraint>
+{
+
+ /**
+ * Sets the uniqueness kind for this uniqueness constraint.
+ *
+ * @param uniqueness The uniqueness kind for this uniqueness constraint.
+ * @return This builder.
+ * @see UniqueSpecification
+ */
+ UniqueConstraintBuilder setUniqueness( UniqueSpecification uniqueness );
+
+ /**
+ * Adds the columns that have to be unique.
+ *
+ * @param columnNames The column names that have to be unique.
+ * @return This builder.
+ */
+ UniqueConstraintBuilder addColumns( String... columnNames );
+
+ /**
+ * Returns the uniqueness type for this uniqueness constraint.
+ *
+ * @return The uniqueness type for this uniqueness constraint.
+ */
+ UniqueSpecification getUniqueness();
+
+ /**
+ * Returns the column names that have to be unique.
+ *
+ * @return The column names that have to be unique.
+ */
+ List<String> 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/builders/definition/ViewDefinitionBuilder.java
----------------------------------------------------------------------
diff --git a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/builders/definition/ViewDefinitionBuilder.java b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/builders/definition/ViewDefinitionBuilder.java
new file mode 100644
index 0000000..ae61aa2
--- /dev/null
+++ b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/builders/definition/ViewDefinitionBuilder.java
@@ -0,0 +1,117 @@
+/*
+ * 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.builders.definition;
+
+import org.apache.polygene.library.sql.generator.grammar.builders.AbstractBuilder;
+import org.apache.polygene.library.sql.generator.grammar.common.TableNameDirect;
+import org.apache.polygene.library.sql.generator.grammar.definition.view.RegularViewSpecification;
+import org.apache.polygene.library.sql.generator.grammar.definition.view.ViewCheckOption;
+import org.apache.polygene.library.sql.generator.grammar.definition.view.ViewDefinition;
+import org.apache.polygene.library.sql.generator.grammar.definition.view.ViewSpecification;
+import org.apache.polygene.library.sql.generator.grammar.query.QueryExpression;
+
+/**
+ * This is a builder for {@code CREATE VIEW} statements.
+ *
+ * @author Stanislav Muhametsin
+ * @see ViewDefinition
+ */
+public interface ViewDefinitionBuilder
+ extends AbstractBuilder<ViewDefinition>
+{
+
+ /**
+ * Sets whether this view is {@code RECURSIVE}.
+ *
+ * @param isRecursive True if view is to be {@code RECURSIVE}; false otherwise.
+ * @return This builder.
+ */
+ ViewDefinitionBuilder setRecursive( Boolean isRecursive );
+
+ /**
+ * Sets the name for this view.
+ *
+ * @param viewName The name for this view.
+ * @return This builder.
+ */
+ ViewDefinitionBuilder setViewName( TableNameDirect viewName );
+
+ /**
+ * Sets the query for this view.
+ *
+ * @param query The query for this view.
+ * @return This builder.
+ */
+ ViewDefinitionBuilder setQuery( QueryExpression query );
+
+ /**
+ * Sets the view check option for this view.
+ *
+ * @param viewCheck The view check option for this view.
+ * @return This builder.
+ * @see ViewCheckOption
+ */
+ ViewDefinitionBuilder setViewCheckOption( ViewCheckOption viewCheck );
+
+ /**
+ * Sets the view specification for this view. Typically is a list of columns (via {@link RegularViewSpecification}).
+ *
+ * @param spec The view specification.
+ * @return This builder.
+ * @see ViewSpecification
+ */
+ ViewDefinitionBuilder setViewSpecification( ViewSpecification spec );
+
+ /**
+ * Returns whether this view is to be {@code RECURSIVE}.
+ *
+ * @return True if this view is to be {@code RECURSIVE}; false otherwise.
+ */
+ Boolean isRecursive();
+
+ /**
+ * Returns the name of the view.
+ *
+ * @return The name of the view.
+ */
+ TableNameDirect getViewName();
+
+ /**
+ * Returns the query for the view.
+ *
+ * @return The query for the view.
+ */
+ QueryExpression getQueryExpression();
+
+ /**
+ * Returns the view check option.
+ *
+ * @return The view check option.
+ * @see ViewCheckOption
+ */
+ ViewCheckOption getViewCheckOption();
+
+ /**
+ * Returns the view specification. Typically is a list of columns (via {@link RegularViewSpecification}).
+ *
+ * @return The view specification.
+ */
+ ViewSpecification getViewSpecification();
+}