org.norther.tammi.core.util
Class ObjectNameComparator

java.lang.Object
  extended by org.norther.tammi.core.util.ObjectNameComparator
All Implemented Interfaces:
Serializable, Comparator

public class ObjectNameComparator
extends Object
implements Comparator, Serializable

A comparator for object names of MBeans.

Author:
Ilkka Priha
See Also:
Serialized Form

Constructor Summary
ObjectNameComparator()
          Constructs a new comparator.
ObjectNameComparator(String key)
          Constructs a new comparator with a sort key.
ObjectNameComparator(String key, boolean ign)
          Constructs a new comparator with a sort key.
 
Method Summary
protected  int compare(ObjectName name1, ObjectName name2)
          Compares two object names in ascending order.
 int compare(Object name1, Object name2)
          Compares two object names.
protected  String getSortKey()
          Gets the sort key.
protected  boolean isIgnoreDomain()
          Checks ignore domain.
 
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

ObjectNameComparator

public ObjectNameComparator()
Constructs a new comparator.


ObjectNameComparator

public ObjectNameComparator(String key)
Constructs a new comparator with a sort key.

Parameters:
key - the sort key.

ObjectNameComparator

public ObjectNameComparator(String key,
                            boolean ign)
Constructs a new comparator with a sort key.

Parameters:
key - the sort key.
ign - if true, ignore domain.
Method Detail

compare

public int compare(Object name1,
                   Object name2)
Compares two object names.

Specified by:
compare in interface Comparator
Parameters:
name1 - the first name to be compared.
name2 - the second name to be compared.
Returns:
-1, 0 or 1 based on comparison.
Throws:
NullPointerException - for null names.
IllegalArgumentException - for invalid names.
ClassCastException - if parameters are not names.

compare

protected int compare(ObjectName name1,
                      ObjectName name2)
Compares two object names in ascending order.

Parameters:
name1 - the first name to be compared.
name2 - the second name to be compared.
Returns:
-1, 0 or 1 based on comparison.
Throws:
NullPointerException - for null names.

getSortKey

protected String getSortKey()
Gets the sort key.

Returns:
the sort key.

isIgnoreDomain

protected boolean isIgnoreDomain()
Checks ignore domain.

Returns:
true if domain is ignored.


Copyright © 2004 The Norther Organization. All rights reserved.