You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by th...@apache.org on 2012/03/20 14:49:49 UTC
svn commit: r1302895 [2/2] - in /jackrabbit/oak/trunk/oak-jcr/src:
main/java/org/apache/jackrabbit/oak/jcr/query/
main/java/org/apache/jackrabbit/oak/jcr/query/qom/
test/java/org/apache/jackrabbit/oak/jcr/query/
test/java/org/apache/jackrabbit/oak/jcr/...
Added: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/qom/QueryObjectModelImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/qom/QueryObjectModelImpl.java?rev=1302895&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/qom/QueryObjectModelImpl.java (added)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/qom/QueryObjectModelImpl.java Tue Mar 20 13:49:47 2012
@@ -0,0 +1,142 @@
+/*
+ * 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.jackrabbit.oak.jcr.query.qom;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+import javax.jcr.query.InvalidQueryException;
+import javax.jcr.query.QueryResult;
+import javax.jcr.query.qom.Column;
+import javax.jcr.query.qom.Constraint;
+import javax.jcr.query.qom.Ordering;
+import javax.jcr.query.qom.QueryObjectModel;
+import javax.jcr.query.qom.Selector;
+import javax.jcr.query.qom.Source;
+import org.apache.jackrabbit.commons.SimpleValueFactory;
+
+/**
+ * The implementation of the corresponding JCR interface.
+ */
+public class QueryObjectModelImpl implements QueryObjectModel {
+
+ final Source source;
+ final Constraint constraint;
+ final HashMap<String, Value> bindVariableMap = new HashMap<String, Value>();
+ final ArrayList<Selector> selectors = new ArrayList<Selector>();
+
+ private final Ordering[] orderings;
+ private final Column[] columns;
+ private long limit;
+ private long offset;
+ private final ValueFactory valueFactory = new SimpleValueFactory();
+
+ public QueryObjectModelImpl(Source source, Constraint constraint, Ordering[] orderings,
+ Column[] columns) {
+ this.source = source;
+ this.constraint = constraint;
+ this.orderings = orderings;
+ this.columns = columns;
+ }
+
+ public void bindVariables() {
+ ((ConstraintImpl) constraint).bindVariables(this);
+ }
+
+ @Override
+ public Column[] getColumns() {
+ return columns;
+ }
+
+ @Override
+ public Constraint getConstraint() {
+ return constraint;
+ }
+
+ @Override
+ public Ordering[] getOrderings() {
+ return orderings;
+ }
+
+ @Override
+ public Source getSource() {
+ return source;
+ }
+
+ @Override
+ public String[] getBindVariableNames() {
+ String[] array = new String[bindVariableMap.size()];
+ array = bindVariableMap.keySet().toArray(array);
+ return array;
+ }
+
+ @Override
+ public void setLimit(long limit) {
+ this.limit = limit;
+ }
+
+ @Override
+ public void setOffset(long offset) {
+ this.offset = offset;
+ }
+
+ public ValueFactory getValueFactory() {
+ return valueFactory;
+ }
+
+ @Override
+ public void bindValue(String arg0, javax.jcr.Value arg1) throws IllegalArgumentException,
+ RepositoryException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public QueryResult execute() throws InvalidQueryException, RepositoryException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getLanguage() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getStatement() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getStoredQueryPath() throws RepositoryException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Node storeAsNode(String arg0) throws RepositoryException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void addBindVariable(BindVariableValueImpl var) {
+ this.bindVariableMap.put(var.getBindVariableName(), null);
+ }
+
+}
Added: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/qom/SameNodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/qom/SameNodeImpl.java?rev=1302895&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/qom/SameNodeImpl.java (added)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/qom/SameNodeImpl.java Tue Mar 20 13:49:47 2012
@@ -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.jackrabbit.oak.jcr.query.qom;
+
+import javax.jcr.query.qom.SameNode;
+
+/**
+ * The implementation of the corresponding JCR interface.
+ */
+public class SameNodeImpl extends ConstraintImpl implements SameNode {
+
+ private final String path;
+ private final String selectorName;
+
+ public SameNodeImpl(String selectorName, String path) {
+ this.selectorName = selectorName;
+ this.path = path;
+ }
+
+ @Override
+ public String getSelectorName() {
+ return selectorName;
+ }
+
+ @Override
+ public String getPath() {
+ return path;
+ }
+
+ @Override
+ public String toString() {
+ return "ISSAMENODE(" + getSelectorName() + ", " + quotePath(path) + ')';
+ }
+
+ @Override
+ public void bindVariables(QueryObjectModelImpl qom) {
+ // ignore
+ }
+
+}
Added: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/qom/SameNodeJoinConditionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/qom/SameNodeJoinConditionImpl.java?rev=1302895&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/qom/SameNodeJoinConditionImpl.java (added)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/qom/SameNodeJoinConditionImpl.java Tue Mar 20 13:49:47 2012
@@ -0,0 +1,69 @@
+/*
+ * 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.jackrabbit.oak.jcr.query.qom;
+
+import javax.jcr.query.qom.SameNodeJoinCondition;
+
+/**
+ * The implementation of the corresponding JCR interface.
+ */
+public class SameNodeJoinConditionImpl extends JoinConditionImpl implements SameNodeJoinCondition {
+
+ private final String selector1Name;
+ private final String selector2Name;
+ private final String selector2Path;
+
+ public SameNodeJoinConditionImpl(String selector1Name, String selector2Name,
+ String selector2Path) {
+ this.selector1Name = selector1Name;
+ this.selector2Name = selector2Name;
+ this.selector2Path = selector2Path;
+ }
+
+ @Override
+ public String getSelector1Name() {
+ return selector1Name;
+ }
+
+ @Override
+ public String getSelector2Name() {
+ return selector2Name;
+ }
+
+ @Override
+ public String getSelector2Path() {
+ return selector2Path;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("ISSAMENODE(");
+ builder.append(getSelector1Name());
+ builder.append(", ");
+ builder.append(getSelector2Name());
+ if (selector2Path != null) {
+ builder.append(", ");
+ builder.append(quotePath(selector2Path));
+ }
+ builder.append(')');
+ return builder.toString();
+ }
+
+}
Added: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/qom/SelectorImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/qom/SelectorImpl.java?rev=1302895&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/qom/SelectorImpl.java (added)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/qom/SelectorImpl.java Tue Mar 20 13:49:47 2012
@@ -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.jackrabbit.oak.jcr.query.qom;
+
+import javax.jcr.query.qom.Selector;
+
+/**
+ * The implementation of the corresponding JCR interface.
+ */
+public class SelectorImpl extends SourceImpl implements Selector {
+
+ private final String nodeTypeName, selectorName;
+
+ public SelectorImpl(String nodeTypeName, String selectorName) {
+ this.nodeTypeName = nodeTypeName;
+ this.selectorName = selectorName;
+ }
+
+ public String getNodeTypeName() {
+ return nodeTypeName;
+ }
+
+ public String getSelectorName() {
+ return selectorName;
+ }
+
+ @Override
+ public String toString() {
+ // TODO quote nodeTypeName?
+ return nodeTypeName + " AS " + getSelectorName();
+ }
+
+}
Added: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/qom/SourceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/qom/SourceImpl.java?rev=1302895&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/qom/SourceImpl.java (added)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/qom/SourceImpl.java Tue Mar 20 13:49:47 2012
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.jackrabbit.oak.jcr.query.qom;
+
+import javax.jcr.query.qom.Source;
+
+public abstract class SourceImpl extends QOMNode implements Source {
+
+ // base class without methods
+
+}
Added: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/qom/StaticOperandImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/qom/StaticOperandImpl.java?rev=1302895&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/qom/StaticOperandImpl.java (added)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/qom/StaticOperandImpl.java Tue Mar 20 13:49:47 2012
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.jackrabbit.oak.jcr.query.qom;
+
+import javax.jcr.query.qom.StaticOperand;
+
+public abstract class StaticOperandImpl extends QOMNode implements StaticOperand {
+
+ public abstract void bindVariables(QueryObjectModelImpl qom);
+
+}
Added: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/qom/UpperCaseImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/qom/UpperCaseImpl.java?rev=1302895&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/qom/UpperCaseImpl.java (added)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/qom/UpperCaseImpl.java Tue Mar 20 13:49:47 2012
@@ -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.jackrabbit.oak.jcr.query.qom;
+
+import javax.jcr.query.qom.UpperCase;
+
+/**
+ * The implementation of the corresponding JCR interface.
+ */
+public class UpperCaseImpl extends DynamicOperandImpl implements UpperCase {
+
+ private final DynamicOperandImpl operand;
+
+ public UpperCaseImpl(DynamicOperandImpl operand) {
+ this.operand = operand;
+ }
+
+ @Override
+ public DynamicOperandImpl getOperand() {
+ return operand;
+ }
+
+ @Override
+ public String toString() {
+ return "UPPER(" + operand + ')';
+ }
+
+}
Added: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/qom/QomTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/qom/QomTest.java?rev=1302895&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/qom/QomTest.java (added)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/qom/QomTest.java Tue Mar 20 13:49:47 2012
@@ -0,0 +1,305 @@
+/*
+ * 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.jackrabbit.oak.jcr.query.qom;
+
+import static org.junit.Assert.assertEquals;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+import javax.jcr.query.qom.And;
+import javax.jcr.query.qom.BindVariableValue;
+import javax.jcr.query.qom.ChildNode;
+import javax.jcr.query.qom.ChildNodeJoinCondition;
+import javax.jcr.query.qom.Column;
+import javax.jcr.query.qom.Comparison;
+import javax.jcr.query.qom.Constraint;
+import javax.jcr.query.qom.DescendantNode;
+import javax.jcr.query.qom.DescendantNodeJoinCondition;
+import javax.jcr.query.qom.EquiJoinCondition;
+import javax.jcr.query.qom.FullTextSearch;
+import javax.jcr.query.qom.FullTextSearchScore;
+import javax.jcr.query.qom.Join;
+import javax.jcr.query.qom.Length;
+import javax.jcr.query.qom.Literal;
+import javax.jcr.query.qom.LowerCase;
+import javax.jcr.query.qom.NodeLocalName;
+import javax.jcr.query.qom.NodeName;
+import javax.jcr.query.qom.Not;
+import javax.jcr.query.qom.Or;
+import javax.jcr.query.qom.Ordering;
+import javax.jcr.query.qom.PropertyExistence;
+import javax.jcr.query.qom.PropertyValue;
+import javax.jcr.query.qom.QueryObjectModel;
+import javax.jcr.query.qom.QueryObjectModelConstants;
+import javax.jcr.query.qom.QueryObjectModelFactory;
+import javax.jcr.query.qom.SameNode;
+import javax.jcr.query.qom.SameNodeJoinCondition;
+import javax.jcr.query.qom.Selector;
+import javax.jcr.query.qom.Source;
+import javax.jcr.query.qom.UpperCase;
+import org.apache.jackrabbit.commons.SimpleValueFactory;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests the QueryObjectModelFactory and other QOM classes.
+ */
+public class QomTest {
+
+ QueryObjectModelFactory f = new QueryObjectModelFactoryImpl();
+ private ValueFactory vf;
+
+ @Before
+ public void setup() {
+ vf = new SimpleValueFactory();
+ }
+
+ @Test
+ public void and() throws RepositoryException {
+ Constraint c0 = f.propertyExistence("x", "c0");
+ Constraint c1 = f.propertyExistence("x", "c1");
+ And and = f.and(c0, c1);
+ assertEquals(and.getConstraint1(), c0);
+ assertEquals(and.getConstraint2(), c1);
+ }
+
+ @Test
+ public void ascending() throws RepositoryException {
+ PropertyValue p = f.propertyValue("selectorName", "propertyName");
+ Ordering o = f.ascending(p);
+ assertEquals(p, o.getOperand());
+ assertEquals(QueryObjectModelConstants.JCR_ORDER_ASCENDING, o.getOrder());
+ }
+
+ @Test
+ public void bindVariable() throws RepositoryException {
+ BindVariableValue b = f.bindVariable("bindVariableName");
+ assertEquals("bindVariableName", b.getBindVariableName());
+ }
+
+ @Test
+ public void childNode() throws RepositoryException {
+ ChildNode cn = f.childNode("selectorName", "parentPath");
+ assertEquals("selectorName", cn.getSelectorName());
+ assertEquals("parentPath", cn.getParentPath());
+ }
+
+ @Test
+ public void childNodeJoinCondition() throws RepositoryException {
+ ChildNodeJoinCondition c = f.childNodeJoinCondition("childSelectorName",
+ "parentSelectorName");
+ assertEquals("childSelectorName", c.getChildSelectorName());
+ assertEquals("parentSelectorName", c.getParentSelectorName());
+ }
+
+ @Test
+ public void column() throws RepositoryException {
+ Column c = f.column("selectorName", "propertyName", "columnName");
+ assertEquals("selectorName", c.getSelectorName());
+ assertEquals("propertyName", c.getPropertyName());
+ assertEquals("columnName", c.getColumnName());
+ }
+
+ @Test
+ public void comparison() throws RepositoryException {
+ PropertyValue p = f.propertyValue("selectorName", "propertyName");
+ Literal l = f.literal(vf.createValue(1));
+ Comparison c = f.comparison(p, QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, l);
+ assertEquals(p, c.getOperand1());
+ assertEquals(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, c.getOperator());
+ assertEquals(l, c.getOperand2());
+ }
+
+ @Test
+ public void descendantNode() throws RepositoryException {
+ DescendantNode d = f.descendantNode("selectorName", "path");
+ assertEquals("selectorName", d.getSelectorName());
+ assertEquals("path", d.getAncestorPath());
+ }
+
+ @Test
+ public void descendantNodeJoinCondition() throws RepositoryException {
+ DescendantNodeJoinCondition d = f.descendantNodeJoinCondition("descendantSelectorName",
+ "ancestorSelectorName");
+ assertEquals("descendantSelectorName", d.getDescendantSelectorName());
+ assertEquals("ancestorSelectorName", d.getAncestorSelectorName());
+ }
+
+ @Test
+ public void descending() throws RepositoryException {
+ PropertyValue p = f.propertyValue("selectorName", "propertyName");
+ Ordering o = f.descending(p);
+ assertEquals(p, o.getOperand());
+ assertEquals(QueryObjectModelConstants.JCR_ORDER_DESCENDING, o.getOrder());
+ }
+
+ @Test
+ public void equiJoinCondition() throws RepositoryException {
+ EquiJoinCondition e = f.equiJoinCondition("selector1Name", "property1Name",
+ "selector2Name", "property2Name");
+ assertEquals("selector1Name", e.getSelector1Name());
+ assertEquals("property1Name", e.getProperty1Name());
+ assertEquals("selector2Name", e.getSelector2Name());
+ assertEquals("property2Name", e.getProperty2Name());
+ }
+
+ @Test
+ public void fullTextSearch() throws RepositoryException {
+ Literal l = f.literal(vf.createValue(1));
+ FullTextSearch x = f.fullTextSearch("selectorName", "propertyName", l);
+ assertEquals("selectorName", x.getSelectorName());
+ assertEquals("propertyName", x.getPropertyName());
+ assertEquals(l, x.getFullTextSearchExpression());
+ }
+
+ @Test
+ public void fullTextSearchScore() throws RepositoryException {
+ FullTextSearchScore x = f.fullTextSearchScore("selectorName");
+ assertEquals("selectorName", x.getSelectorName());
+ }
+
+ @Test
+ public void join() throws RepositoryException {
+ Source left = f.selector("nodeTypeName", "selectorName");
+ Source right = f.selector("nodeTypeName2", "selectorName2");
+ ChildNodeJoinCondition jc = f.childNodeJoinCondition("childSelectorName", "parentSelectorName");
+ Join j = f.join(left, right, QueryObjectModelConstants.JCR_JOIN_TYPE_INNER, jc);
+ assertEquals(left, j.getLeft());
+ assertEquals(right, j.getRight());
+ assertEquals(QueryObjectModelConstants.JCR_JOIN_TYPE_INNER, j.getJoinType());
+ assertEquals(jc, j.getJoinCondition());
+ }
+
+ @Test
+ public void length() throws RepositoryException {
+ PropertyValue p = f.propertyValue("selectorName", "propertyName");
+ Length l = f.length(p);
+ assertEquals(p, l.getPropertyValue());
+ }
+
+ @Test
+ public void literal() throws RepositoryException {
+ Value v = vf.createValue(1);
+ Literal l = f.literal(v);
+ assertEquals(v, l.getLiteralValue());
+ }
+
+ @Test
+ public void lowerCase() throws RepositoryException {
+ PropertyValue p = f.propertyValue("selectorName", "propertyName");
+ Length length = f.length(p);
+ LowerCase l = f.lowerCase(length);
+ assertEquals(length, l.getOperand());
+ }
+
+ @Test
+ public void nodeLocalName() throws RepositoryException {
+ NodeLocalName n = f.nodeLocalName("selectorName");
+ assertEquals("selectorName", n.getSelectorName());
+ }
+
+ @Test
+ public void nodeName() throws RepositoryException {
+ NodeName n = f.nodeName("selectorName");
+ assertEquals("selectorName", n.getSelectorName());
+ }
+
+ @Test
+ public void not() throws RepositoryException {
+ Constraint c = f.propertyExistence("x", "c0");
+ Not n = f.not(c);
+ assertEquals(c, n.getConstraint());
+ }
+
+ @Test
+ public void or() throws RepositoryException {
+ Constraint c0 = f.propertyExistence("x", "c0");
+ Constraint c1 = f.propertyExistence("x", "c1");
+ Or or = f.or(c0, c1);
+ assertEquals(or.getConstraint1(), c0);
+ assertEquals(or.getConstraint2(), c1);
+ }
+
+ @Test
+ public void propertyExistence() throws RepositoryException {
+ PropertyExistence pe = f.propertyExistence("selectorName", "propertyName");
+ assertEquals("selectorName", pe.getSelectorName());
+ assertEquals("propertyName", pe.getPropertyName());
+ }
+
+ @Test
+ public void propertyValue() throws RepositoryException {
+ PropertyValue pv = f.propertyValue("selectorName", "propertyName");
+ assertEquals("selectorName", pv.getSelectorName());
+ assertEquals("propertyName", pv.getPropertyName());
+ }
+
+ @Test
+ public void sameNode() throws RepositoryException {
+ SameNode s = f.sameNode("selectorName", "path");
+ assertEquals("selectorName", s.getSelectorName());
+ assertEquals("path", s.getPath());
+ }
+
+ @Test
+ public void sameNodeJoinCondition() throws RepositoryException {
+ SameNodeJoinCondition s = f.sameNodeJoinCondition("selector1Name", "selector2Name", "selector2Path");
+ assertEquals("selector1Name", s.getSelector1Name());
+ assertEquals("selector2Name", s.getSelector2Name());
+ assertEquals("selector2Path", s.getSelector2Path());
+ }
+
+ @Test
+ public void selector() throws RepositoryException {
+ Selector s = f.selector("nodeTypeName", "selectorName");
+ assertEquals("nodeTypeName", s.getNodeTypeName());
+ assertEquals("selectorName", s.getSelectorName());
+ }
+
+ @Test
+ public void upperCase() throws RepositoryException {
+ PropertyValue p = f.propertyValue("selectorName", "propertyName");
+ Length length = f.length(p);
+ UpperCase u = f.upperCase(length);
+ assertEquals(length, u.getOperand());
+ }
+
+ @Test
+ public void createQuery() throws RepositoryException {
+ Selector s = f.selector("nodeTypeName", "x");
+ BindVariableValue b = f.bindVariable("var");
+ Constraint c = f.propertyExistence("x", "c");
+ PropertyValue p = f.propertyValue("x", "propertyName");
+ c = f.and(f.comparison(p, QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, b), c);
+ Ordering o = f.ascending(p);
+ Column col = f.column("selectorName", "propertyName", "columnName");
+ Ordering[] ords = new Ordering[]{o};
+ Column[] cols = new Column[]{col};
+ QueryObjectModel q = f.createQuery(s, c, ords, cols);
+ // assertEquals(Query.JCR_SQL2, q.getLanguage());
+ String[] bv = q.getBindVariableNames();
+ assertEquals(1, bv.length);
+ assertEquals("var", bv[0]);
+ assertEquals(s, q.getSource());
+ assertEquals(c, q.getConstraint());
+ assertEquals(o, q.getOrderings()[0]);
+ assertEquals(col, q.getColumns()[0]);
+ }
+
+}