org.modeshape.jcr.query.qom
Class JcrQueryObjectModelFactory

java.lang.Object
  extended by org.modeshape.jcr.query.qom.JcrQueryObjectModelFactory
All Implemented Interfaces:
QueryObjectModelConstants, QueryObjectModelFactory

public class JcrQueryObjectModelFactory
extends Object
implements QueryObjectModelFactory

An implementation of the JCR QueryObjectModelFactory. Note that this implementation constructs the query components but does not validate any of the parameters or the resulting query definition. All validation is performed when the query is executed.


Field Summary
static String LANGUAGE
           
 
Fields inherited from interface javax.jcr.query.qom.QueryObjectModelConstants
JCR_JOIN_TYPE_INNER, JCR_JOIN_TYPE_LEFT_OUTER, JCR_JOIN_TYPE_RIGHT_OUTER, JCR_OPERATOR_EQUAL_TO, JCR_OPERATOR_GREATER_THAN, JCR_OPERATOR_GREATER_THAN_OR_EQUAL_TO, JCR_OPERATOR_LESS_THAN, JCR_OPERATOR_LESS_THAN_OR_EQUAL_TO, JCR_OPERATOR_LIKE, JCR_OPERATOR_NOT_EQUAL_TO, JCR_ORDER_ASCENDING, JCR_ORDER_DESCENDING
 
Constructor Summary
JcrQueryObjectModelFactory(JcrQueryContext context)
           
 
Method Summary
 ArithmeticOperand add(DynamicOperand left, DynamicOperand right)
          Create an arithmetic dynamic operand that adds the numeric value of the two supplied operand(s).
 And and(Constraint constraint1, Constraint constraint2)
          
 ArithmeticOperand arithmeticOperand(DynamicOperand left, ArithmeticOperator operator, DynamicOperand right)
           
 JcrOrdering ascending(DynamicOperand operand)
          
 Between between(DynamicOperand operand, StaticOperand lowerBound, StaticOperand upperBound, boolean includeLowerBound, boolean includeUpperBound)
          Tests that the value (or values) defined by the supplied dynamic operand are within a specified range.
 BindVariableValue bindVariable(String bindVariableName)
          
 ChildNode childNode(String selectorName, String path)
          
 ChildNodeJoinCondition childNodeJoinCondition(String childSelectorName, String parentSelectorName)
          
 JcrColumn column(String selectorName, String propertyName, String columnName)
          
 Comparison comparison(DynamicOperand operand1, String operator, StaticOperand operand2)
          
 JcrQueryObjectModel createQuery(Source source, Constraint constraint, Ordering[] orderings, Column[] columns)
          
 DescendantNode descendantNode(String selectorName, String path)
          
 DescendantNodeJoinCondition descendantNodeJoinCondition(String descendantSelectorName, String ancestorSelectorName)
          
 JcrOrdering descending(DynamicOperand operand)
          
 ArithmeticOperand divide(DynamicOperand left, DynamicOperand right)
          Create an arithmetic dynamic operand that divides the numeric value of the first operand by the numeric value of the second.
 EquiJoinCondition equiJoinCondition(String selector1Name, String property1Name, String selector2Name, String property2Name)
          
 SetQuery except(QueryCommand left, QueryCommand right, Ordering[] orderings, Limit limit, boolean all)
          Creates a query command that returns all rows that are in the result of the left-hand query but not in the result of the right-hand query.
 FullTextSearch fullTextSearch(String selectorName, String propertyName, StaticOperand fullTextSearchExpression)
          
 FullTextSearchScore fullTextSearchScore(String selectorName)
          
 SetCriteria in(DynamicOperand operand, StaticOperand... values)
          Tests that the value (or values) defined by the supplied dynamic operand are found within the specified set of values.
 SetQuery intersect(QueryCommand left, QueryCommand right, Ordering[] orderings, Limit limit, boolean all)
          Creates a query command that returns all rows that are both in the result of the left-hand query and in the result of the right-hand query.
 Join join(Source left, Source right, String joinType, JoinCondition joinCondition)
          
 Length length(PropertyValue propertyValue)
          
 Limit limit(int rowLimit, int offset)
          Evaluates to a limit on the maximum number of tuples in the results and the number of rows that are skipped before the first tuple in the results.
 Literal literal(Value literalValue)
          
 LowerCase lowerCase(DynamicOperand operand)
          
 ArithmeticOperand multiply(DynamicOperand left, DynamicOperand right)
          Create an arithmetic dynamic operand that multplies the numeric value of the first operand by the numeric value of the second.
 NodeDepth nodeDepth(String selectorName)
          Evaluates to a LONG value equal to the depth of a node in the specified selector.
 NodeLocalName nodeLocalName(String selectorName)
          
 NodeName nodeName(String selectorName)
          
 NodePath nodePath(String selectorName)
          Evaluates to a PATH value equal to the prefix-qualified path of a node in the specified selector.
 Not not(Constraint constraint)
          
 Or or(Constraint constraint1, Constraint constraint2)
          
 PropertyExistence propertyExistence(String selectorName, String propertyName)
          
 PropertyValue propertyValue(String selectorName, String propertyName)
          
 JcrReferenceValue referenceValue(String selectorName)
          Creates a dynamic operand that evaluates to the REFERENCE value of the any property on the specified selector.
 JcrReferenceValue referenceValue(String selectorName, String propertyName)
          Creates a dynamic operand that evaluates to the REFERENCE value of the specified property on the specified selector.
 SameNode sameNode(String selectorName, String path)
          
 SameNodeJoinCondition sameNodeJoinCondition(String selector1Name, String selector2Name, String selector2Path)
          
 JcrSelectQuery select(Source source, Constraint constraint, Ordering[] orderings, Column[] columns, Limit limit, boolean distinct)
          Creates a query with one or more selectors.
 JcrNamedSelector selector(String nodeTypeName, String selectorName)
          
protected  SelectorName selectorName(String name)
           
 JcrSetQuery setQuery(QueryCommand left, SetQuery.Operation operation, QueryCommand right, Ordering[] orderings, Limit limit, boolean all)
           
 Subquery subquery(QueryCommand subqueryCommand)
          Creates a subquery that can be used as a StaticOperand in another query.
 ArithmeticOperand subtract(DynamicOperand left, DynamicOperand right)
          Create an arithmetic dynamic operand that subtracts the numeric value of the second operand from the numeric value of the first.
 SetQuery union(QueryCommand left, QueryCommand right, Ordering[] orderings, Limit limit, boolean all)
          Creates a query command that effectively appends the results of the right-hand query to those of the left-hand query.
 UpperCase upperCase(DynamicOperand operand)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LANGUAGE

public static final String LANGUAGE
See Also:
Constant Field Values
Constructor Detail

JcrQueryObjectModelFactory

public JcrQueryObjectModelFactory(JcrQueryContext context)
Method Detail

selectorName

protected SelectorName selectorName(String name)

createQuery

public JcrQueryObjectModel createQuery(Source source,
                                       Constraint constraint,
                                       Ordering[] orderings,
                                       Column[] columns)

Specified by:
createQuery in interface QueryObjectModelFactory
See Also:
QueryObjectModelFactory.createQuery(javax.jcr.query.qom.Source, javax.jcr.query.qom.Constraint, javax.jcr.query.qom.Ordering[], javax.jcr.query.qom.Column[])

select

public JcrSelectQuery select(Source source,
                             Constraint constraint,
                             Ordering[] orderings,
                             Column[] columns,
                             Limit limit,
                             boolean distinct)
Creates a query with one or more selectors.

Parameters:
source - the node-tuple source; non-null
constraint - the constraint, or null if none
orderings - zero or more orderings; null is equivalent to a zero-length array
columns - the columns; null is equivalent to a zero-length array
limit - the limit; null is equivalent to having no limit
distinct - true if the query should return distinct values; or false if no duplicate removal should be performed
Returns:
the select query; non-null
See Also:
QueryObjectModelFactory.select(javax.jcr.query.qom.Source, javax.jcr.query.qom.Constraint, javax.jcr.query.qom.Ordering[], javax.jcr.query.qom.Column[], org.modeshape.jcr.api.query.qom.Limit, boolean)

union

public SetQuery union(QueryCommand left,
                      QueryCommand right,
                      Ordering[] orderings,
                      Limit limit,
                      boolean all)
Creates a query command that effectively appends the results of the right-hand query to those of the left-hand query.

Parameters:
left - the query command that represents left-side of the set operation; non-null and must have columns that are equivalent and union-able to those of the right-side query
right - the query command that represents right-side of the set operation; non-null and must have columns that are equivalent and union-able to those of the left-side query
orderings - zero or more orderings; null is equivalent to a zero-length array
limit - the limit; null is equivalent to having no limit
all - true if duplicate rows in the left- and right-hand side results should be included, or false if duplicate rows should be eliminated
Returns:
the select query; non-null
See Also:
QueryObjectModelFactory.union(QueryCommand, QueryCommand, Ordering[], Limit, boolean)

intersect

public SetQuery intersect(QueryCommand left,
                          QueryCommand right,
                          Ordering[] orderings,
                          Limit limit,
                          boolean all)
Creates a query command that returns all rows that are both in the result of the left-hand query and in the result of the right-hand query.

Parameters:
left - the query command that represents left-side of the set operation; non-null and must have columns that are equivalent and union-able to those of the right-side query
right - the query command that represents right-side of the set operation; non-null and must have columns that are equivalent and union-able to those of the left-side query
orderings - zero or more orderings; null is equivalent to a zero-length array
limit - the limit; null is equivalent to having no limit
all - true if duplicate rows in the left- and right-hand side results should be included, or false if duplicate rows should be eliminated
Returns:
the select query; non-null
See Also:
QueryObjectModelFactory.intersect(org.modeshape.jcr.api.query.qom.QueryCommand, org.modeshape.jcr.api.query.qom.QueryCommand, javax.jcr.query.qom.Ordering[], org.modeshape.jcr.api.query.qom.Limit, boolean)

except

public SetQuery except(QueryCommand left,
                       QueryCommand right,
                       Ordering[] orderings,
                       Limit limit,
                       boolean all)
Creates a query command that returns all rows that are in the result of the left-hand query but not in the result of the right-hand query.

Parameters:
left - the query command that represents left-side of the set operation; non-null and must have columns that are equivalent and union-able to those of the right-side query
right - the query command that represents right-side of the set operation; non-null and must have columns that are equivalent and union-able to those of the left-side query
orderings - zero or more orderings; null is equivalent to a zero-length array
limit - the limit; null is equivalent to having no limit
all - true if duplicate rows in the left- and right-hand side results should be included, or false if duplicate rows should be eliminated
Returns:
the select query; non-null
See Also:
QueryObjectModelFactory.except(org.modeshape.jcr.api.query.qom.QueryCommand, org.modeshape.jcr.api.query.qom.QueryCommand, javax.jcr.query.qom.Ordering[], org.modeshape.jcr.api.query.qom.Limit, boolean)

setQuery

public JcrSetQuery setQuery(QueryCommand left,
                            SetQuery.Operation operation,
                            QueryCommand right,
                            Ordering[] orderings,
                            Limit limit,
                            boolean all)

selector

public JcrNamedSelector selector(String nodeTypeName,
                                 String selectorName)

Specified by:
selector in interface QueryObjectModelFactory
See Also:
QueryObjectModelFactory.selector(java.lang.String, java.lang.String)

column

public JcrColumn column(String selectorName,
                        String propertyName,
                        String columnName)

Specified by:
column in interface QueryObjectModelFactory
See Also:
QueryObjectModelFactory.column(java.lang.String, java.lang.String, java.lang.String)

ascending

public JcrOrdering ascending(DynamicOperand operand)

Specified by:
ascending in interface QueryObjectModelFactory
See Also:
QueryObjectModelFactory.ascending(javax.jcr.query.qom.DynamicOperand)

descending

public JcrOrdering descending(DynamicOperand operand)

Specified by:
descending in interface QueryObjectModelFactory
See Also:
QueryObjectModelFactory.descending(javax.jcr.query.qom.DynamicOperand)

and

public And and(Constraint constraint1,
               Constraint constraint2)

Specified by:
and in interface QueryObjectModelFactory
See Also:
QueryObjectModelFactory.and(javax.jcr.query.qom.Constraint, javax.jcr.query.qom.Constraint)

bindVariable

public BindVariableValue bindVariable(String bindVariableName)

Specified by:
bindVariable in interface QueryObjectModelFactory
See Also:
QueryObjectModelFactory.bindVariable(java.lang.String)

childNode

public ChildNode childNode(String selectorName,
                           String path)

Specified by:
childNode in interface QueryObjectModelFactory
See Also:
QueryObjectModelFactory.childNode(java.lang.String, java.lang.String)

childNodeJoinCondition

public ChildNodeJoinCondition childNodeJoinCondition(String childSelectorName,
                                                     String parentSelectorName)

Specified by:
childNodeJoinCondition in interface QueryObjectModelFactory
See Also:
QueryObjectModelFactory.childNodeJoinCondition(java.lang.String, java.lang.String)

comparison

public Comparison comparison(DynamicOperand operand1,
                             String operator,
                             StaticOperand operand2)

Specified by:
comparison in interface QueryObjectModelFactory
See Also:
QueryObjectModelFactory.comparison(javax.jcr.query.qom.DynamicOperand, java.lang.String, javax.jcr.query.qom.StaticOperand)

descendantNode

public DescendantNode descendantNode(String selectorName,
                                     String path)

Specified by:
descendantNode in interface QueryObjectModelFactory
See Also:
QueryObjectModelFactory.descendantNode(java.lang.String, java.lang.String)

descendantNodeJoinCondition

public DescendantNodeJoinCondition descendantNodeJoinCondition(String descendantSelectorName,
                                                               String ancestorSelectorName)

Specified by:
descendantNodeJoinCondition in interface QueryObjectModelFactory
See Also:
QueryObjectModelFactory.descendantNodeJoinCondition(java.lang.String, java.lang.String)

equiJoinCondition

public EquiJoinCondition equiJoinCondition(String selector1Name,
                                           String property1Name,
                                           String selector2Name,
                                           String property2Name)

Specified by:
equiJoinCondition in interface QueryObjectModelFactory
See Also:
QueryObjectModelFactory.equiJoinCondition(java.lang.String, java.lang.String, java.lang.String, java.lang.String)

fullTextSearch

public FullTextSearch fullTextSearch(String selectorName,
                                     String propertyName,
                                     StaticOperand fullTextSearchExpression)
                              throws RepositoryException

Specified by:
fullTextSearch in interface QueryObjectModelFactory
Throws:
RepositoryException
See Also:
QueryObjectModelFactory.fullTextSearch(java.lang.String, java.lang.String, javax.jcr.query.qom.StaticOperand)

fullTextSearchScore

public FullTextSearchScore fullTextSearchScore(String selectorName)

Specified by:
fullTextSearchScore in interface QueryObjectModelFactory
See Also:
QueryObjectModelFactory.fullTextSearchScore(java.lang.String)

join

public Join join(Source left,
                 Source right,
                 String joinType,
                 JoinCondition joinCondition)

Specified by:
join in interface QueryObjectModelFactory
See Also:
QueryObjectModelFactory.join(javax.jcr.query.qom.Source, javax.jcr.query.qom.Source, java.lang.String, javax.jcr.query.qom.JoinCondition)

length

public Length length(PropertyValue propertyValue)

Specified by:
length in interface QueryObjectModelFactory
See Also:
QueryObjectModelFactory.length(javax.jcr.query.qom.PropertyValue)

literal

public Literal literal(Value literalValue)
                throws RepositoryException

Specified by:
literal in interface QueryObjectModelFactory
Throws:
RepositoryException
See Also:
QueryObjectModelFactory.literal(javax.jcr.Value)

lowerCase

public LowerCase lowerCase(DynamicOperand operand)

Specified by:
lowerCase in interface QueryObjectModelFactory
See Also:
QueryObjectModelFactory.lowerCase(javax.jcr.query.qom.DynamicOperand)

nodeLocalName

public NodeLocalName nodeLocalName(String selectorName)

Specified by:
nodeLocalName in interface QueryObjectModelFactory
See Also:
QueryObjectModelFactory.nodeLocalName(java.lang.String)

nodeName

public NodeName nodeName(String selectorName)

Specified by:
nodeName in interface QueryObjectModelFactory
See Also:
QueryObjectModelFactory.nodeName(java.lang.String)

not

public Not not(Constraint constraint)

Specified by:
not in interface QueryObjectModelFactory
See Also:
QueryObjectModelFactory.not(javax.jcr.query.qom.Constraint)

or

public Or or(Constraint constraint1,
             Constraint constraint2)

Specified by:
or in interface QueryObjectModelFactory
See Also:
QueryObjectModelFactory.or(javax.jcr.query.qom.Constraint, javax.jcr.query.qom.Constraint)

propertyExistence

public PropertyExistence propertyExistence(String selectorName,
                                           String propertyName)

Specified by:
propertyExistence in interface QueryObjectModelFactory
See Also:
QueryObjectModelFactory.propertyExistence(java.lang.String, java.lang.String)

propertyValue

public PropertyValue propertyValue(String selectorName,
                                   String propertyName)

Specified by:
propertyValue in interface QueryObjectModelFactory
See Also:
QueryObjectModelFactory.propertyValue(java.lang.String, java.lang.String)

sameNode

public SameNode sameNode(String selectorName,
                         String path)

Specified by:
sameNode in interface QueryObjectModelFactory
See Also:
QueryObjectModelFactory.sameNode(java.lang.String, java.lang.String)

sameNodeJoinCondition

public SameNodeJoinCondition sameNodeJoinCondition(String selector1Name,
                                                   String selector2Name,
                                                   String selector2Path)

Specified by:
sameNodeJoinCondition in interface QueryObjectModelFactory
See Also:
QueryObjectModelFactory.sameNodeJoinCondition(java.lang.String, java.lang.String, java.lang.String)

upperCase

public UpperCase upperCase(DynamicOperand operand)

Specified by:
upperCase in interface QueryObjectModelFactory
See Also:
QueryObjectModelFactory.upperCase(javax.jcr.query.qom.DynamicOperand)

nodePath

public NodePath nodePath(String selectorName)
Evaluates to a PATH value equal to the prefix-qualified path of a node in the specified selector.

The query is invalid if selector is not the name of a selector in the query.

Parameters:
selectorName - the selector name; non-null
Returns:
the operand; non-null
See Also:
QueryObjectModelFactory.nodePath(java.lang.String)

nodeDepth

public NodeDepth nodeDepth(String selectorName)
Evaluates to a LONG value equal to the depth of a node in the specified selector.

The query is invalid if selector is not the name of a selector in the query.

Parameters:
selectorName - the selector name; non-null
Returns:
the operand; non-null
See Also:
QueryObjectModelFactory.nodeDepth(java.lang.String)

limit

public Limit limit(int rowLimit,
                   int offset)
Evaluates to a limit on the maximum number of tuples in the results and the number of rows that are skipped before the first tuple in the results.

Parameters:
rowLimit - the maximum number of rows; must be a positive number, or Integer.MAX_VALUE if there is to be a non-zero offset but no limit
offset - the number of rows to skip before beginning the results; must be 0 or a positive number
Returns:
the operand; non-null
See Also:
QueryObjectModelFactory.limit(int, int)

between

public Between between(DynamicOperand operand,
                       StaticOperand lowerBound,
                       StaticOperand upperBound,
                       boolean includeLowerBound,
                       boolean includeUpperBound)
Tests that the value (or values) defined by the supplied dynamic operand are within a specified range. The range is specified by a lower and upper bound, and whether each of the boundary values is included in the range.

Parameters:
operand - the dynamic operand describing the values that are to be constrained
lowerBound - the lower bound of the range
upperBound - the upper bound of the range
includeLowerBound - true if the lower boundary value is not be included
includeUpperBound - true if the upper boundary value is not be included
Returns:
the constraint; non-null
See Also:
QueryObjectModelFactory.between(javax.jcr.query.qom.DynamicOperand, javax.jcr.query.qom.StaticOperand, javax.jcr.query.qom.StaticOperand, boolean, boolean)

in

public SetCriteria in(DynamicOperand operand,
                      StaticOperand... values)
Tests that the value (or values) defined by the supplied dynamic operand are found within the specified set of values.

Parameters:
operand - the dynamic operand describing the values that are to be constrained
values - the static operand values; may not be null or empty
Returns:
the constraint; non-null
See Also:
QueryObjectModelFactory.in(javax.jcr.query.qom.DynamicOperand, javax.jcr.query.qom.StaticOperand[])

subquery

public Subquery subquery(QueryCommand subqueryCommand)
Creates a subquery that can be used as a StaticOperand in another query.

Parameters:
subqueryCommand - the query command that is to be used as the subquery
Returns:
the constraint; non-null
See Also:
QueryObjectModelFactory.subquery(org.modeshape.jcr.api.query.qom.QueryCommand)

add

public ArithmeticOperand add(DynamicOperand left,
                             DynamicOperand right)
Create an arithmetic dynamic operand that adds the numeric value of the two supplied operand(s).

Parameters:
left - the left-hand-side operand; not null
right - the right-hand-side operand; not null
Returns:
the dynamic operand; non-null
See Also:
QueryObjectModelFactory.add(javax.jcr.query.qom.DynamicOperand, javax.jcr.query.qom.DynamicOperand)

subtract

public ArithmeticOperand subtract(DynamicOperand left,
                                  DynamicOperand right)
Create an arithmetic dynamic operand that subtracts the numeric value of the second operand from the numeric value of the first.

Parameters:
left - the left-hand-side operand; not null
right - the right-hand-side operand; not null
Returns:
the dynamic operand; non-null
See Also:
QueryObjectModelFactory.subtract(javax.jcr.query.qom.DynamicOperand, javax.jcr.query.qom.DynamicOperand)

multiply

public ArithmeticOperand multiply(DynamicOperand left,
                                  DynamicOperand right)
Create an arithmetic dynamic operand that multplies the numeric value of the first operand by the numeric value of the second.

Parameters:
left - the left-hand-side operand; not null
right - the right-hand-side operand; not null
Returns:
the dynamic operand; non-null
See Also:
QueryObjectModelFactory.multiply(javax.jcr.query.qom.DynamicOperand, javax.jcr.query.qom.DynamicOperand)

divide

public ArithmeticOperand divide(DynamicOperand left,
                                DynamicOperand right)
Create an arithmetic dynamic operand that divides the numeric value of the first operand by the numeric value of the second.

Parameters:
left - the left-hand-side operand; not null
right - the right-hand-side operand; not null
Returns:
the dynamic operand; non-null
See Also:
QueryObjectModelFactory.divide(javax.jcr.query.qom.DynamicOperand, javax.jcr.query.qom.DynamicOperand)

arithmeticOperand

public ArithmeticOperand arithmeticOperand(DynamicOperand left,
                                           ArithmeticOperator operator,
                                           DynamicOperand right)

referenceValue

public JcrReferenceValue referenceValue(String selectorName)
Creates a dynamic operand that evaluates to the REFERENCE value of the any property on the specified selector.

The query is invalid if:

Parameters:
selectorName - the selector name; non-null
Returns:
the operand; non-null
See Also:
QueryObjectModelFactory.referenceValue(java.lang.String)

referenceValue

public JcrReferenceValue referenceValue(String selectorName,
                                        String propertyName)
Creates a dynamic operand that evaluates to the REFERENCE value of the specified property on the specified selector.

The query is invalid if:

Parameters:
selectorName - the selector name; non-null
propertyName - the reference property name; non-null
Returns:
the operand; non-null
See Also:
QueryObjectModelFactory.referenceValue(java.lang.String, java.lang.String)


Copyright © 2008-2012 JBoss, a division of Red Hat. All Rights Reserved.