org.apache.jackrabbit.spi.commons.query
Class OrderQueryNode

java.lang.Object
  extended by org.apache.jackrabbit.spi.commons.query.QueryNode
      extended by 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
static class OrderQueryNode.OrderSpec
          Implements 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
protected OrderQueryNode(QueryNode parent)
          Creates a new OrderQueryNode with a reference to a parent node and sort properties.
 
Method Summary
 Object accept(QueryNodeVisitor visitor, Object data)
          Accepts a QueryNodeVisitor and calls the appropriate visit method on the visitor depending on the concrete implementation of this QueryNode.
 void addOrderSpec(org.apache.jackrabbit.spi.Name property, boolean ascending)
          Deprecated. use addOrderSpec(Path , boolean) instead.
 void addOrderSpec(OrderQueryNode.OrderSpec spec)
          Adds an order specification to this query node.
 void addOrderSpec(org.apache.jackrabbit.spi.Path property, boolean ascending)
          Adds an order specification to this query node.
 boolean equals(Object obj)
          Returns true if obj is the same type of QueryNode as this node and is equal to this node.
 OrderQueryNode.OrderSpec[] getOrderSpecs()
          Returns a OrderSpec array that contains order by specifications.
 int getType()
          Returns the type of this node.
 boolean isAscending(int i)
          Returns true if the property i should be ordered ascending.
 boolean isValid()
          Checks whether all order specifications of this query node have at least its path specified (i.e.
 boolean needsSystemTree()
          Returns true if this query node needs items under /jcr:system to be queried.
 void newOrderSpec()
          Create and add a new (empty) order specification to this query node.
 void setAscending(boolean value)
          Set the last order specification of this query node to ascending/descending
 void setFunction(String name)
          Set the function of the last order specification of this query node.
 void setPath(org.apache.jackrabbit.spi.Path path)
          Set the path of the last order specification of this query node.
 
Methods inherited from class org.apache.jackrabbit.spi.commons.query.QueryNode
dump, getParent
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OrderQueryNode

protected OrderQueryNode(QueryNode parent)
Creates a new OrderQueryNode with 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.

Specified by:
getType in class QueryNode
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 - truetrue> for ascending and false for descending.
Throws:
IllegalStateException - if no order specification is set
See Also:
OrderQueryNode.OrderSpec.setAscending(boolean)

setPath

public void setPath(org.apache.jackrabbit.spi.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. non null.)

Returns:
true iff all order specification of this query node are valid.

addOrderSpec

public void addOrderSpec(org.apache.jackrabbit.spi.Name property,
                         boolean ascending)
Deprecated. use addOrderSpec(Path , boolean) instead.

Adds an order specification to this query node.

Parameters:
property - the name of the property.
ascending - if true values of this properties are ordered ascending; descending if false.

addOrderSpec

public void addOrderSpec(org.apache.jackrabbit.spi.Path property,
                         boolean ascending)
Adds an order specification to this query node.

Parameters:
property - the relative path of the property.
ascending - if true values of this properties are ordered ascending; descending if false.

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 a QueryNodeVisitor and calls the appropriate visit method on the visitor depending on the concrete implementation of this QueryNode.

Specified by:
accept in class QueryNode
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 IndexOutOfBoundsException
Returns true if the property i should be ordered ascending. If false the 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 index i.

getOrderSpecs

public OrderQueryNode.OrderSpec[] getOrderSpecs()
Returns a OrderSpec array that contains order by specifications.

Returns:
order by specs.

equals

public boolean equals(Object obj)
Description copied from class: QueryNode
Returns true if obj is the same type of QueryNode as this node and is equal to this node.

Specified by:
equals in class QueryNode
Parameters:
obj - the reference object with which to compare.
Returns:
true if obj is equal to this; false otherwise.

needsSystemTree

public boolean needsSystemTree()
Returns true if this query node needs items under /jcr:system to be queried.

Specified by:
needsSystemTree in class QueryNode
Returns:
true if this query node needs content under /jcr:system to be queried; false otherwise.


Copyright © 2004-2014 The Apache Software Foundation. All Rights Reserved.