public class OrderingComparator
extends java.lang.Object
implements java.util.Comparator
Comparable
based on the ordering expressions
defined by a query tree. This instance holds references to a query tree,
a tree walker and a memory query instance for this purpose.Constructor and Description |
---|
OrderingComparator(TreeWalker walker,
MemoryQuery nodeVisitor)
Constructs an ordering comparator for a tree walker and a node visitor.
|
OrderingComparator(TreeWalker walker,
MemoryQuery nodeVisitor,
QueryTree queryTree)
Constructs an ordering comparator for a tree walker, a node visitor
and a query tree.
|
Modifier and Type | Method and Description |
---|---|
int |
compare(java.lang.Object o1,
java.lang.Object o2)
Required method for implementing the interface
Comparator . |
void |
setQueryTree(QueryTree queryTree)
Sets the query tree for this ordering comparator.
|
public OrderingComparator(TreeWalker walker, MemoryQuery nodeVisitor)
setQueryTree
.walker
- the tree walkernodeVisitor
- the node visitor evaluating the ordering expressionspublic OrderingComparator(TreeWalker walker, MemoryQuery nodeVisitor, QueryTree queryTree)
walker
- the tree walkernodeVisitor
- the node visitor evaluating the ordering expressionsqueryTree
- the query tree containing the ordering expressionspublic void setQueryTree(QueryTree queryTree)
queryTree
- the query tree containing the ordering expression listpublic int compare(java.lang.Object o1, java.lang.Object o2)
Comparator
.
This method returns a negative integer, zero, or a positive integer
as the first argument is less than, equal to, or greater than the second
argument.
If this instance is not bound to a query tree or,
if the query tree bound to this instance
does not have any ordering expression, then argument o1
is less than argument o2
by definition.compare
in interface java.util.Comparator
o1
- the first object to be comparedo2
- the second object to be comparedjava.lang.ClassCastException
- if the arguments are not instances of
Comparable
Copyright © 2005-2012 Apache Software Foundation. All Rights Reserved.