Class OrderQueryNode
- java.lang.Object
-
- org.apache.jackrabbit.spi.commons.query.QueryNode
-
- org.apache.jackrabbit.spi.commons.query.OrderQueryNode
-
public class OrderQueryNode extends QueryNode
Implements a query node that defines the order of nodes according to the values of properties.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classOrderQueryNode.OrderSpecImplements a single order specification.
-
Field Summary
-
Fields inherited from class org.apache.jackrabbit.spi.commons.query.QueryNode
TYPE_AND, TYPE_DEREF, TYPE_EXACT, TYPE_LOCATION, TYPE_NODETYPE, TYPE_NOT, TYPE_OR, TYPE_ORDER, TYPE_PATH, TYPE_PROP_FUNCTION, TYPE_RELATION, TYPE_ROOT, TYPE_TEXTSEARCH
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedOrderQueryNode(QueryNode parent)Creates a newOrderQueryNodewith a reference to a parent node and sort properties.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Objectaccept(QueryNodeVisitor visitor, Object data)Accepts aQueryNodeVisitorand calls the appropriatevisitmethod on the visitor depending on the concrete implementation of thisQueryNode.voidaddOrderSpec(OrderQueryNode.OrderSpec spec)Adds an order specification to this query node.voidaddOrderSpec(Name property, boolean ascending)Deprecated.useaddOrderSpec(Path , boolean)instead.voidaddOrderSpec(Path property, boolean ascending)Adds an order specification to this query node.booleanequals(Object obj)Returnstrueifobjis the same type ofQueryNodeasthisnode and is equal tothisnode.OrderQueryNode.OrderSpec[]getOrderSpecs()Returns aOrderSpecarray that contains order by specifications.intgetType()Returns the type of this node.booleanisAscending(int i)Returnstrueif the propertyishould be ordered ascending.booleanisValid()Checks whether all order specifications of this query node have at least its path specified (i.e.booleanneedsSystemTree()Returnstrueif this query node needs items under /jcr:system to be queried.voidnewOrderSpec()Create and add a new (empty) order specification to this query node.voidsetAscending(boolean value)Set the last order specification of this query node to ascending/descendingvoidsetFunction(String name)Set the function of the last order specification of this query node.voidsetPath(Path path)Set the path of the last order specification of this query node.
-
-
-
Constructor Detail
-
OrderQueryNode
protected OrderQueryNode(QueryNode parent)
Creates a newOrderQueryNodewith a reference to a parent node and sort properties.- Parameters:
parent- the parent node of this query node.
-
-
Method Detail
-
getType
public int getType()
Returns the type of this node.
-
newOrderSpec
public void newOrderSpec()
Create and add a new (empty) order specification to this query node.
-
setAscending
public void setAscending(boolean value)
Set the last order specification of this query node to ascending/descending- Parameters:
value-truefor ascending andfalsefor descending.- Throws:
IllegalStateException- if no order specification is set- See Also:
OrderQueryNode.OrderSpec.setAscending(boolean)
-
setPath
public void setPath(Path path)
Set the path of the last order specification of this query node.- Parameters:
path- a path- Throws:
IllegalStateException- if no order specification is set- See Also:
OrderQueryNode.OrderSpec.setPath(org.apache.jackrabbit.spi.Path)
-
setFunction
public void setFunction(String name)
Set the function of the last order specification of this query node.- Parameters:
name- a function name- Throws:
IllegalStateException- if no order specification is set- See Also:
OrderQueryNode.OrderSpec.setFunction(String)
-
isValid
public boolean isValid()
Checks whether all order specifications of this query node have at least its path specified (i.e. nonnull.)- Returns:
trueiff all order specification of this query node are valid.
-
addOrderSpec
@Deprecated public void addOrderSpec(Name property, boolean ascending)
Deprecated.useaddOrderSpec(Path , boolean)instead.Adds an order specification to this query node.- Parameters:
property- the name of the property.ascending- iftruevalues of this properties are ordered ascending; descending iffalse.
-
addOrderSpec
public void addOrderSpec(Path property, boolean ascending)
Adds an order specification to this query node.- Parameters:
property- the relative path of the property.ascending- iftruevalues of this properties are ordered ascending; descending iffalse.
-
addOrderSpec
public void addOrderSpec(OrderQueryNode.OrderSpec spec)
Adds an order specification to this query node.- Parameters:
spec- the order spec.
-
accept
public Object accept(QueryNodeVisitor visitor, Object data) throws RepositoryException
Accepts aQueryNodeVisitorand calls the appropriatevisitmethod on the visitor depending on the concrete implementation of thisQueryNode.- Specified by:
acceptin classQueryNode- Parameters:
visitor- the visitor to call back.data- arbitrary data for the visitor.- Returns:
- the return value of the
visitor.visit()call. - Throws:
RepositoryException
-
isAscending
public boolean isAscending(int i) throws IndexOutOfBoundsExceptionReturnstrueif the propertyishould be ordered ascending. Iffalsethe property is ordered descending.- Parameters:
i- index of the property- Returns:
- the order spec for the property
i. - Throws:
IndexOutOfBoundsException- if there is no property with indexi.
-
getOrderSpecs
public OrderQueryNode.OrderSpec[] getOrderSpecs()
Returns aOrderSpecarray that contains order by specifications.- Returns:
- order by specs.
-
equals
public boolean equals(Object obj)
Returnstrueifobjis the same type ofQueryNodeasthisnode and is equal tothisnode.
-
needsSystemTree
public boolean needsSystemTree()
Returnstrueif this query node needs items under /jcr:system to be queried.- Specified by:
needsSystemTreein classQueryNode- Returns:
trueif this query node needs content under /jcr:system to be queried;falseotherwise.
-
-