atg.repository
Class SortDirectives

java.lang.Object
  extended by atg.repository.SortDirectives
All Implemented Interfaces:
atg.core.util.SortOrder, SortingConstants, java.util.Comparator

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.

See Also:
SortDirective, RepositoryView.executeQuery(atg.repository.Query), RepositorySorter

Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Fields inherited from interface atg.repository.SortingConstants
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 Summary
SortDirectives()
           
 
Method Summary
 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.
 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.
 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
 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.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string

Constructor Detail

SortDirectives

public SortDirectives()
Method Detail

copy

public SortDirectives copy()
Returns a deep copy of this object


isEmpty

public boolean isEmpty()
Returns true if there are no sort directives.


getNumDirectives

public int getNumDirectives()
Returns the number of sort directives.


getDirective

public SortDirective getDirective(int pIndex)
Returns the sort directive at the specified index.


addDirective

public void addDirective(SortDirective pDirective)
Adds the specified SortDirective to the end of the list of sort directives.


addDirective

public void addDirective(SortDirective pDirective,
                         int pIndex)
Adds the specified SortDirective at the specified index in the list of sort directives.


removeDirective

public void removeDirective(int pIndex)
Removes the sort directive at the specified index.


setCollator

public void setCollator(java.text.Collator pCollator)
Set property collator

Parameters:
pCollator - new value to set

getCollator

public java.text.Collator getCollator()
Get property collator

Returns:
collator

toString

public java.lang.String toString(java.lang.String pIndent)
Returns the string representation of the object, indenting the text using the specified pIndent string.


order

public 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. Returns an integer that is < 0 if pObject1 should come before pObject2, > 0 if pObject should come after pObject2, or = 0 if the order is indeterminate.

RepositorySorter uses this procedure to sort an array of RepositoryItems according to an order determined by a given SortDirectives object.

Specified by:
order in interface atg.core.util.SortOrder
See Also:
RepositoryItem, RepositorySorter.sort(atg.repository.RepositoryItem[], atg.repository.SortDirectives), RepositorySorter.compare(java.lang.Object, java.lang.Object, int, boolean)

compare

public 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().

Parameters:
pString1 - first string to compare, cannot be null
pString2 - second string to compare, cannot be null
Returns:
an integer value less than zero if pString1 is less than pString2, zero if pString1 and pString2 are equal, greater than zero if pString1 is greater than pString2.

compare

public final int compare(java.lang.Object pObject1,
                         java.lang.Object pObject2)
Specified by:
compare in interface java.util.Comparator

hashCode

public int hashCode()
Return an integer hash code for this object

Overrides:
hashCode in class java.lang.Object
Returns:
the hash code

equals

public 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. Otherwise, returns false.

Specified by:
equals in interface java.util.Comparator
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Returns the string representation of the object.

Overrides:
toString in class java.lang.Object