public class SortDirectives extends java.lang.Object implements atg.core.util.SortOrder, SortingConstants, java.util.Comparator
A structure representing a set of sorting directives. Contains an ordered list of SortDirective objects; the order of the objects implies the sorting order.
Sorting can be performed either by the Repository, through the executeQuery methods or as a post-processing step on the results. One can use the RepositorySorter class to sort an array of RepositoryItems.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLASS_VERSION
Class version string
|
ASCENDING_ATTRIBUTE_VALUE, CASE_INSENSITIVE_ATTRIBUTE_VALUE, CASE_SENSITIVE_ATTRIBUTE_VALUE, DESCENDING_ATTRIBUTE_VALUE, DIR_ATTRIBUTE_NAME, SORTBY_TAG, SORTBYVALUE_TAG, VALUE_ATTRIBUTE_NAME
Constructor and Description |
---|
SortDirectives()
Create a new instance.
|
SortDirectives(java.util.List<SortDirective> pDirectives)
Create a new instance with the specified directives.
|
SortDirectives(SortDirective... pDirectives)
Create a SortDirectives instance with the specified directives.
|
Modifier and Type | Method and Description |
---|---|
void |
addDirective(SortDirective pDirective)
Adds the specified SortDirective to the end of the list of
sort directives.
|
void |
addDirective(SortDirective pDirective,
int pIndex)
Adds the specified SortDirective at the specified index in
the list of sort directives.
|
int |
compare(java.lang.Object pObject1,
java.lang.Object pObject2) |
int |
compare(java.lang.String pString1,
java.lang.String pString2)
Compare two Strings in a locale-sensitive manner if we have a Collator,
otherwise using
String.compareTo() . |
SortDirectives |
copy()
Returns a deep copy of this object
|
boolean |
equals(java.lang.Object obj)
Returns true if the given SortDirectives has same number of
elements as this one and each individual SortDirective object
in the given SortDirectives equals (via its equals method) the
corresponding SortDirective in this SortDirectives object.
|
java.text.Collator |
getCollator()
Get property
collator |
SortDirective |
getDirective(int pIndex)
Returns the sort directive at the specified index.
|
boolean |
getLocaleSensitiveSorting()
Get property
localeSensitiveSorting |
int |
getNumDirectives()
Returns the number of sort directives.
|
int |
hashCode()
Return an integer hash code for this object
|
boolean |
isEmpty()
Returns true if there are no sort directives.
|
boolean |
isLocaleSensitiveSorting()
Property
localeSensitiveSorting |
int |
order(java.lang.Object pObject1,
java.lang.Object pObject2)
Compares two objects as Dynamic Beans, based on the sorting
directives contained in this object.
|
void |
removeDirective(int pIndex)
Removes the sort directive at the specified index.
|
void |
setCollator(java.text.Collator pCollator)
Set property
collator |
void |
setLocaleSensitiveSorting(boolean pLocaleSensitiveSorting)
Set property
localeSensitiveSorting |
void |
sortByLocale(java.util.Locale pLocale)
Sets this query to sort by the given locale using in-memory
locale-sensitive sorting.
|
java.lang.String |
toString()
Returns the string representation of the object.
|
java.lang.String |
toString(java.lang.String pIndent)
Returns the string representation of the object, indenting the text using the specified pIndent string.
|
java.lang.String |
toString(java.lang.String pIndent,
int pNumIndents)
Returns the string representation of the object, indenting the text using the specified pIndent string.
|
public SortDirectives()
public SortDirectives(java.util.List<SortDirective> pDirectives)
pDirectives
- to thepublic SortDirectives(SortDirective... pDirectives)
pDirectives
- the individual SortDirective instances to use.public SortDirectives copy()
public boolean isEmpty()
public int getNumDirectives()
public SortDirective getDirective(int pIndex)
public void addDirective(SortDirective pDirective)
public void addDirective(SortDirective pDirective, int pIndex)
public void removeDirective(int pIndex)
public void setCollator(java.text.Collator pCollator)
collator
pCollator
- new value to setpublic java.text.Collator getCollator()
collator
collator
public void setLocaleSensitiveSorting(boolean pLocaleSensitiveSorting)
localeSensitiveSorting
pLocaleSensitiveSorting
- new value to setpublic boolean getLocaleSensitiveSorting()
localeSensitiveSorting
localeSensitiveSorting
public boolean isLocaleSensitiveSorting()
localeSensitiveSorting
localeSensitiveSorting
public void sortByLocale(java.util.Locale pLocale)
pLocale
- the locale to use for sortingpublic java.lang.String toString(java.lang.String pIndent)
pIndent
- string to place in front of each line of the string representation of this objectpublic java.lang.String toString(java.lang.String pIndent, int pNumIndents)
pIndent
- string to place in front of each line of the string representation of this objectpNumIndents
- how many versions of the pIndent string to place in front of linespublic int order(java.lang.Object pObject1, java.lang.Object pObject2)
RepositorySorter uses this procedure to sort an array of RepositoryItems according to an order determined by a given SortDirectives object.
order
in interface atg.core.util.SortOrder
RepositoryItem
,
RepositorySorter.sort(atg.repository.RepositoryItem[], atg.repository.SortDirectives)
,
RepositorySorter.compare(java.lang.Object, java.lang.Object, int, boolean)
public int compare(java.lang.String pString1, java.lang.String pString2)
String.compareTo()
.pString1
- first string to compare, cannot be nullpString2
- second string to compare, cannot be nullpublic final int compare(java.lang.Object pObject1, java.lang.Object pObject2)
compare
in interface java.util.Comparator
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in interface java.util.Comparator
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object