Class Ordering
java.lang.Object
ch.tocco.nice2.persist.core.api.query.Ordering
This class specifies the ordering policy of a query. It may be bound to an entity
 model, but it doesn't have to. If it is bound to a model, it will check that
 the specified fields exist. Ordering objects obtained by 
Query.getOrdering()
 are always bound. You may also order by fields of a related entity by using the
 dot-notation known from the query language: myRelation.myField. Note that
 fields of entities of a one-to-many or many-to-many relation may not be used
 for ordering.
 This class is designed to reflect the behaviour of table ordering in GUIs.
 Example:
 
   Ordering o = new Ordering();
   o.append("myField", Direction.ASCENDING);
   o.append("myRel.otherField", Direction.valueOf("DESC"+"ENDING"));
   o.apply(myQeury);
 
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic enumOne of ASCENDING, DESCENDINGstatic classRepresents an ordering rule.
- 
Field SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionOrdering()Create an unbound ordering object.Ordering(EntityModel model) Create an ordering object bound to the specified entity model.
- 
Method SummaryModifier and TypeMethodDescriptionappend(Path path, Ordering.Direction direction) Append an ordering rule to the policy.Append ordering rules to the policy.append(String path, Ordering.Direction direction) Append an ordering rule to the policy.voidApply this ordering policy to a query in strict mode.voidApply this ordering policy to a query.clear()Clear the ordering policy.booleangetRules()Get an array of the current ordering rules.inthashCode()booleanisEmpty()Check whether the ordering policy is empty.static OrderingCreate a new Ordering instance with ordering rules.prepend(Path path, Ordering.Direction direction) Prepend an ordering rule to the policy.Prepend ordering rules to the policy.prepend(String path, Ordering.Direction direction) Prepend an ordering rule to the policy.booleanRemove a field/path from this ordering policy.booleanRemove a field/path from this ordering policy.booleansetDirection(Path path, Ordering.Direction direction) Set the direction of the ordering rule for the specified field/path.booleansetDirection(String path, Ordering.Direction direction) Set the direction of the ordering rule for the specified field/path.intsize()Get the size (field count) of this ordering policy.booleantruncate(int maxSize) Truncate the ordering policy to the specified size.
- 
Field Details- 
model
 
- 
- 
Constructor Details- 
Orderingpublic Ordering()Create an unbound ordering object.
- 
OrderingCreate an ordering object bound to the specified entity model.- Parameters:
- model- The model.
 
 
- 
- 
Method Details- 
ofCreate a new Ordering instance with ordering rules.- Parameters:
- paths- The fields/paths to append. All paths are appended with- Ordering.Direction.ASCENDING, unless they're prefixed with a dash ('-').
- Returns:
- the new Ordering instance.
 
- 
applyApply this ordering policy to a query in strict mode.- Parameters:
- query- The query to apply this ordering policy to.
- Throws:
- PersistException- If an error occurs.
- See Also:
 
- 
applyApply this ordering policy to a query. Thelenientflag specifies, how unknown or invalid fields will be handled: Iflenientis set totrue, unknown or invalid fields will simply be discarded, if it's set tofalse, an exception will be thrown.- Parameters:
- query- The query to apply this ordering policy to.
- lenient-- true, for applying the ordering policy leniently,- falsefor applying it strictly.
- Throws:
- PersistException- If an error occurs or, if applying strictly, an unknown or invalid field was encountered.
 
- 
clearClear the ordering policy.
- 
isEmptypublic boolean isEmpty()Check whether the ordering policy is empty.- Returns:
- true, if the ordering policy is empty.
 
- 
sizepublic int size()Get the size (field count) of this ordering policy.- Returns:
- The field count.
 
- 
truncatepublic boolean truncate(int maxSize) Truncate the ordering policy to the specified size.- Parameters:
- maxSize- The maximum size.
- Returns:
- true, if the ordering policy was truncated,- false, if the policy remained unchanged.
 
- 
appendAppend an ordering rule to the policy. If the policy already contains a ordering rule for the specified field/path, it will be removed before appending.- Parameters:
- path- The field/path to append.
- direction- The ordering- direction.
- Throws:
- PersistException- If an error occurred.
 
- 
appendAppend an ordering rule to the policy. If the policy already contains a ordering rule for the specified field/path, it will be removed before appending.- Parameters:
- path- The field/path to append.
- direction- The ordering- direction.
- Throws:
- PersistException- If an error occurred.
 
- 
appendAppend ordering rules to the policy. If the policy already contains a ordering rule for the specified field/path, it will be removed before appending. All paths are appended withOrdering.Direction.ASCENDING, unless they're prefixed with a dash ('-').- Parameters:
- paths- The fields/paths to append. All paths are appended with- Ordering.Direction.ASCENDING, unless they're prefixed with a dash ('-').
- Throws:
- PersistException- If an error occurred.
 
- 
prependPrepend an ordering rule to the policy. If the policy already contains a ordering rule for the specified field/path, the existing will be removed before prepending.- Parameters:
- path- The field/path to append.
- direction- The ordering- direction.
- Throws:
- PersistException- If an error occurred.
 
- 
prependPrepend an ordering rule to the policy. If the policy already contains a ordering rule for the specified field/path, the existing will be removed before prepending.- Parameters:
- path- The field/path to append.
- direction- The ordering- direction.
- Throws:
- PersistException- If an error occurred.
 
- 
prependPrepend ordering rules to the policy. If the policy already contains an ordering rule for the specified field/path, the existing will be removed before prepending. All paths are prepended withOrdering.Direction.ASCENDING, unless they're prefixed with a dash ('-').- Parameters:
- paths- The fields/paths to append. All paths are appended with- Ordering.Direction.ASCENDING, unless they're prefixed with a dash ('-').
- Throws:
- PersistException- If an error occurred.
 
- 
removeRemove a field/path from this ordering policy. If the policy contains no rule for the specified field/path, no action will be taken.- Parameters:
- path- The field/path.
- Returns:
- true, if the field/path has been removed.
 
- 
removeRemove a field/path from this ordering policy. If the policy contains no rule for the specified field/path, no action will be taken.- Parameters:
- path- The field/path.
- Returns:
- true, if the field/path has been removed.
 
- 
setDirectionSet the direction of the ordering rule for the specified field/path. If the policy contains no rule for that field/path, no action will be taken.- Parameters:
- path- The path.
- direction- The new- direction.
- Returns:
- true, if the direction has been set.
 
- 
setDirectionSet the direction of the ordering rule for the specified field/path. If the policy contains no rule for that field/path, no action will be taken.- Parameters:
- path- The path.
- direction- The new- direction.
- Returns:
- true, if the direction has been set.
 
- 
getRulesGet an array of the current ordering rules.- Returns:
- An array of the current ordering rules.
 
- 
equals
- 
hashCodepublic int hashCode()
 
-