org.norther.tammi.core.rt.util
Class AttributeComparator

java.lang.Object
  extended by org.norther.tammi.acorn.util.PropertyComparator
      extended by org.norther.tammi.core.rt.util.AttributeComparator
All Implemented Interfaces:
Serializable, Comparator

public class AttributeComparator
extends PropertyComparator

A comparator for attributes.

Author:
Ilkka Priha
See Also:
Serialized Form

Constructor Summary
AttributeComparator(String attr)
          Constructs a new comparator.
AttributeComparator(String[] attrs)
          Constructs a new comparator for multiple attributes.
AttributeComparator(String[] attrs, Comparator comp)
          Constructs a new comparator for multiple attributes with a value comparator.
AttributeComparator(String attr, Comparator comp)
          Constructs a new comparator with a value comparator.
 
Method Summary
 int compare(Object var1, Object var2)
          Compares two variables.
protected  Object getProperty(Object obj, String prop)
          Gets the named property value.
 
Methods inherited from class org.norther.tammi.acorn.util.PropertyComparator
compare, getNestedProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

AttributeComparator

public AttributeComparator(String attr)
Constructs a new comparator.

Parameters:
attr - the attribute to compare.

AttributeComparator

public AttributeComparator(String attr,
                           Comparator comp)
Constructs a new comparator with a value comparator.

Parameters:
attr - the attribute to compare.
comp - the attribute value comparator.

AttributeComparator

public AttributeComparator(String[] attrs)
Constructs a new comparator for multiple attributes.

Parameters:
attrs - the attributes to compare.

AttributeComparator

public AttributeComparator(String[] attrs,
                           Comparator comp)
Constructs a new comparator for multiple attributes with a value comparator.

Parameters:
attrs - the attributes to compare.
comp - the attribute value comparator.
Method Detail

compare

public int compare(Object var1,
                   Object var2)
Compares two variables.

Specified by:
compare in interface Comparator
Overrides:
compare in class PropertyComparator
Parameters:
var1 - the first variable to be compared.
var2 - the second variable to be compared.
Returns:
-1, 0 or 1 based on comparison.

getProperty

protected Object getProperty(Object obj,
                             String prop)
                      throws Exception
Description copied from class: PropertyComparator
Gets the named property value.

Overrides:
getProperty in class PropertyComparator
Parameters:
obj - the object.
prop - the property.
Returns:
the value or null.
Throws:
Exception - on errors.


Copyright © 2004 The Norther Organization. All rights reserved.