com.sap.tc.col.client.generic.api
Class SortingCriteria
java.lang.Object
|
+--com.sap.tc.col.client.generic.api.SortingCriteria
- public class SortingCriteria
- extends java.lang.Object
Defines the sort order for data contained in an aspect.
The sort order is defined by specifing an indexed list of sorting crtieria. Criteria
with lower indexes have higher priority. Each criterion defines a column of the aspect
(by naming the field), a comparison rule that defines how data in that column is compared
and a sorting direction that indicates whether lower values (with respect to the comparison
rule) are listed before (ascending) or after (descending) higher values.
Data is sorted according to criterion 0 first. If two rows are equal with respect to the
sorting rule of criterion 0, then these rows are sorted according to the sorting rule
specified in criterion 1 and so on.
Backend implementations might add further criteria to guarantee a stable sort order.
They can do this by forcing all key fields to be part of the sort order or by appending
a sorting criterion for a unique row identifier (GUID, local row index etc.).
Such additional sorting criteria are not expected to be visible through this class.
Note that it is allowed to define several criteria with the same field name. In the current
implementation which supports only a single comparison rule (default rule) this makes no sense,
but doesn't break the above definition. If in the future, several comparison rules might be
supported, it makes perfectly sense to define several criteria (with differing rules) for
the same field.
Example usage:
// create and define a sort order
SortingCriteria sorting = new SortingCriteria();
sorting.addCriterion("CUSTID", SortingCriteria.ASCENDING);
sorting.addCriterion("CONNID", SortingCriteria.DESCENDING);
IAspect bookings = aspect.getRelatedAspect("Bookings", sorting, LockMode.NONE);
System.out.println(bookings.getSortingCriteria());
Expected usage in API:
IAspect
SortingCriteria getSortingCriteria();
IAspect getAspect(String aspectName, SortingCriteria sorting, LockMode lockMode);
IAspect getRelatedAspect(String relationName, SortingCriteria sorting, LockMode lockMode);
IAspectRow
IAspect getRelatedAspect(String relationName, SortingCriteria sorting, LockMode lockMode);
IQuery
void setSortingCriteria(SortingCriteria sorting); // better way ????
IServiceModule
IAspect getAspect(String aspectName, IKeyList keys, SortingCriteria sorting, LockMode lockMode);
|
Method Summary |
void |
addCriterion(java.lang.String fieldName)
Adds a new criterion at the end of the list (with lowest priority). |
void |
addCriterion(java.lang.String fieldName,
boolean ascending)
Adds a new criterion at the end of the list (with lowest priority). |
java.lang.String |
getComparisonRule(int i)
Returnes the (currently unspecified) name of the comparison rule to be used or null if the
(backend or data type defined) default comparison rule is to be used. |
boolean |
getDirection(int i)
Returns true if the criterion with the given index defines ascending order, false for descending order. |
java.lang.String |
getFieldName(int i)
Returns the name of the field that is sorted by the criterion with the given index. |
void |
removeCriterion(int i)
Removes the criterion with the given index. |
int |
size()
Returns the number of sorting criteria. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
ASCENDING
public static final boolean ASCENDING
DESCENDING
public static final boolean DESCENDING
SortingCriteria
public SortingCriteria()
size
public int size()
- Returns the number of sorting criteria. A value of zero means that no sorting criteria
have been defined. The implementation is allowed to ignore sort orders with size() == 0.
getFieldName
public java.lang.String getFieldName(int i)
- Returns the name of the field that is sorted by the criterion with the given
index.
- Throws:
IndexOutOfBoundsException - if the index is not in the range 0 <= index < size().
getDirection
public boolean getDirection(int i)
- Returns true if the criterion with the given index defines ascending order, false for descending order.
- Throws:
IndexOutOfBoundsException - if the index is not in the range 0 <= index < size().
getComparisonRule
public java.lang.String getComparisonRule(int i)
- Returnes the (currently unspecified) name of the comparison rule to be used or null if the
(backend or data type defined) default comparison rule is to be used.
As of today, only the default comparison rule is supported. Therefore this method will always
return
null and there is no method to set a comparison rule.
In the future there might be support for other comparison rules, like
- binary (chars ar compared by their binary representation)
- lexical (lexical sort order, only defined for fields of type String)
- lexical-ignore-case (same as above, but ignoring case)
- number (by value, defined for fields with numeric types)
- day-of-week (sort strings according to the list Mo, Tu, We, ...
- month-of-year ...
...
- Throws:
IndexOutOfBoundsException - if the index is not in the range 0 <= index < size().
addCriterion
public void addCriterion(java.lang.String fieldName)
- Adds a new criterion at the end of the list (with lowest priority).
The criterion is based on the field with the given name and the sort
direction defaults to ASCENDING.
- Throws:
IllegalArgumenException - if the fieldname is null or empty.
addCriterion
public void addCriterion(java.lang.String fieldName,
boolean ascending)
- Adds a new criterion at the end of the list (with lowest priority).
The criterion is based on the field with the given name and has the given sort
direction.
- Throws:
IllegalArgumenException - if the fieldname is null or empty.
removeCriterion
public void removeCriterion(int i)
- Removes the criterion with the given index. All following criteria are moved
to the next lower index postion, so SortingCriteria is always compact.
- Throws:
IndexOutOfBoundsException - if the index is not in the range 0 <= index < size().
toString
public java.lang.String toString()
- Overrides:
toString in class java.lang.Object
Copyright © 2002 SAP AG. Automatically generated Thu Mar 3 2005, 21:55