Overview | Package | Class | Tree | Deprecated | Index | Help
| Copyright © 2000, 2008, Oracle and/or its affiliates. All rights reserved.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.bea.content.manager.sort
Class NodeComparator

    java.lang.Object
      com.bea.content.manager.sort.NodeComparator

All Implemented Interfaces
  Serializable, Comparator

    public class NodeComparator

extends Object
implements Comparator, Serializable

Compares Nodes in ascending order (case-insensitive) based on the Node name.

If SearchCriteria is set then the Nodes are compared based on the criteria against their properties. The criteria is iterated through, until a property is found that compares to less than or greater than and that result is returned. If a property compares to be equal, the next criteria will be used.

The NodeComparator can also be used for sorting standard properites as well as any explicit properties defined in the system. The following standard properties are supported for sorting :

cm_uid, cm_parent_uid, cm_createdDate, cm_createdBy, cm_modifiedDate, cm_path and cm_objectClass

See Also
  Serialized Form

Field Summary
`protected SortCriteria[]` | `sortCriteria` The sort criteria used when sorting nodes.

Constructor Summary
`NodeComparator()`
`NodeComparator(SortCriteria[] sortCriteria)`

Method Summary
`int` | `compare(Object obj1, Object obj2)` Compares its two arguments for order.
`int` | `compareNodeName(Object obj1, Object obj2)` Compares its two arguments for order.
`int` | `compareProperties(Object obj1, Object obj2)` Compares properties.
`boolean` | `equals(Object obj)` Indicates whether some other object is "equal to" this Comparator.
`int` | `hashCode()` Returns a hash code value for this comparator.

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### sortCriteria

    protected SortCriteria[] sortCriteria

  The sort criteria used when sorting nodes.

Constructor Detail

### NodeComparator

    public NodeComparator()

### NodeComparator

    public NodeComparator(SortCriteria[] sortCriteria)

Method Detail

### compare

    public int compare(Object obj1,
                       Object obj2)

  Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

  Specified by:
    `compare` in interface `Comparator`

### compareNodeName

    public int compareNodeName(Object obj1,
                               Object obj2)

  Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

  In this case the arguments are nodes, and we're comparing node names.

  Parameters
    `obj1` - The first node to compare.
    `obj2` - The second node to compare.
  Returns
    The comparison result. 0 if the node names are equivalent.

### compareProperties

    public int compareProperties(Object obj1,
                                 Object obj2)

  Compares properties. Assumes sortCritiera is not null.

  Parameters
    `obj1` - The first node to compare.
    `obj2` - The second node to compare.
  Returns
    0 if the node's properties are equal.

### equals

    public boolean equals(Object obj)

  Indicates whether some other object is "equal to" this Comparator. This method must obey the general contract of `Object.equals(Object)`. Additionally, this method can return `true` only if the specified Object is also a comparator and it imposes the same ordering as this comparator. Thus, `comp1.equals(comp2)` implies that `sgn(comp1.compare(o1, o2))==sgn(comp2.compare(o1, o2))` for every object reference `o1` and `o2`.

  Specified by:
    `equals` in interface `Comparator`
  Overrides:
    `equals` in class `Object`

### hashCode

    public int hashCode()

  Returns a hash code value for this comparator.

  Overrides:
    `hashCode` in class `Object`
  Returns
    The hash code.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000, 2008, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.