|
Extension SDK 10.1.2 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
oracle.ide.model.DefaultFilter.SortedComparator
Builtin Comparator
class for ordering the children of a container node according to the sort option specified.
The sort option can be specified by the constants: #SORT_ALPHABETICALLY
and SORT_BY_TYPE
. The former indicates to sort in locale-sensitive collation order. While the latter indicates to sort by element type. Clients can combine these constants to sort both ways. This class provides a number of template methods that may be overridden by subclasses to provide custom behavior. This makes it possible for subclasses to leverage the existing functionality without having to reimplement it.
Note: This implementation is not as efficient as it could be. Rather than calling Collator.compare(String, String)
to compare the Element
labels directly, for better efficiency we should generate a CollationKey
for each Element
label and use those keys during the comparison. In practice, however, this is somewhat difficult to achieve, since we need to maintain the collation keys somewhere, and the most convenient place to put them would require a change to the Element
interface.
Field Summary | |
protected static java.text.Collator |
collator Collator instance used for comparing strings in locale-sensitive collation order. |
static int |
SORT_ALPHA Sort in local-sensitive collartion order. |
static int |
SORT_BY_TYPE Sort by element type. |
Constructor Summary | |
DefaultFilter.SortedComparator() |
Method Summary | |
int |
compare(java.lang.Object o1, java.lang.Object o2) Implementation of the Comparator.compare(Object, Object) method, which may not be overriden by subclasses. |
protected int |
compareElements(Element e1, Element e2) Template method for comparing the Element objects associated with each TNode , representing the second level of comparison in the compare() call chain. |
protected int |
compareElementToElement(Element e1, Element e2) Template method for comparing two like Element objects in locale-sensitive collation order, representing the third level of comparison in the compare() call chain. |
protected int |
compareStrings(java.lang.String s1, java.lang.String s2) Template method for comparing two String objects in locale-sensitive collation order, representing the fourth level of comparison in the compare() call chain. |
protected int |
compareTNodes(TNode t1, TNode t2) Template method for comparing two TNode objects to each other, representing the first level of comparison in the compare() call chain. |
boolean |
equals(java.lang.Object obj) Implementation of the Comparator.equals(Object) method. |
int |
getOptions() Get the sort options currently set. |
void |
setOptions(int options) Set the sort specified options. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int SORT_ALPHA
public static final int SORT_BY_TYPE
protected static final java.text.Collator collator
Collator
instance used for comparing strings in locale-sensitive collation order.Constructor Detail |
public DefaultFilter.SortedComparator()
Method Detail |
public int getOptions()
public void setOptions(int options)
options
- The options to set.public final int compare(java.lang.Object o1, java.lang.Object o2)
Comparator.compare(Object, Object)
method, which may not be overriden by subclasses. Subclasses should instead override one or more of the template comparison methods to provide custom behavior.
The default implementation calls the template method for comparing the TNode
objects.
compare
in interface java.util.Comparator
public boolean equals(java.lang.Object obj)
Comparator.equals(Object)
method. Subclasses may need to override this method.
The default implementation returns true
if this Comparator
has the same class as the other Object
.
equals
in interface java.util.Comparator
protected int compareTNodes(TNode t1, TNode t2)
TNode
objects to each other, representing the first level of comparison in the compare()
call chain.
Most subclasses should not need to override this method. The default implementation simply calls the template method for comparing the Element
objects associated with the nodes.
protected int compareElements(Element e1, Element e2)
Element
objects associated with each TNode
, representing the second level of comparison in the compare()
call chain. Each Element
object may either represent a Folder
or a regular Element
.
Subclasses may wish to override this method to provide custom behavior. The default implementation simply calls the template method for comparing the elements in locale-sensitive collation order.
protected int compareElementToElement(Element e1, Element e2)
Element
objects in locale-sensitive collation order, representing the third level of comparison in the compare()
call chain.
Most subclasses should not need to override this method. The default implementation first compares the element short labels, followed by the element long labels if the short labels were the same.
protected int compareStrings(java.lang.String s1, java.lang.String s2)
String
objects in locale-sensitive collation order, representing the fourth level of comparison in the compare()
call chain.
Most subclasses should not need to override this method. The default implementation checks for null
and orders those items at the end; otherwise, the strings are compared using the default Collator
for the current locale.
|
Extension SDK | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 1997, 2004, Oracle. All rights reserved.