com.go.trove.util
Class Utils

java.lang.Object
  |
  +--com.go.trove.util.Utils

public class Utils
extends java.lang.Object

Some generic utilities.

Version:
28 , 00/12/18
Author:
Brian S O'Neill
See Also:
Collections

Field Summary
static java.util.Enumeration EMPTY_ENUMERATION
           
static java.util.Map EMPTY_MAP
          This Map is already provided in JDK1.3.
static java.util.Map VOID_MAP
          Similar to EMPTY_MAP, except the put operation is supported, but the values are immediately forgotten.
 
Constructor Summary
protected Utils()
           
 
Method Summary
static java.lang.Object intern(java.lang.Object obj)
          Just like String.intern, except it generates flyweights for any kind of object, and it does not prevent them from being garbage collected.
static java.util.Comparator nullEqualOrder()
          Returns a Comparator that uses a Comparable object's natural ordering, except null values are always considered equal order.
static java.util.Comparator nullEqualOrder(java.util.Comparator c)
          Returns a Comparator that wraps the given Comparator except null values are always considered equal order.
static java.util.Comparator nullHighOrder()
          Returns a Comparator that uses a Comparable object's natural ordering, except null values are always considered high order.
static java.util.Comparator nullHighOrder(java.util.Comparator c)
          Returns a Comparator that wraps the given Comparator except null values are always considered high order.
static java.util.Comparator nullLowOrder()
          Returns a Comparator that uses a Comparable object's natural ordering, except null values are always considered low order.
static java.util.Comparator nullLowOrder(java.util.Comparator c)
          Returns a Comparator that wraps the given Comparator except null values are always considered low order.
static java.util.Comparator reverseOrder(java.util.Comparator c)
          Returns a Comparator that wraps the given Comparator, but orders in reverse.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_ENUMERATION

public static final java.util.Enumeration EMPTY_ENUMERATION

EMPTY_MAP

public static final java.util.Map EMPTY_MAP
This Map is already provided in JDK1.3.

VOID_MAP

public static final java.util.Map VOID_MAP
Similar to EMPTY_MAP, except the put operation is supported, but the values are immediately forgotten.
Constructor Detail

Utils

protected Utils()
Method Detail

nullLowOrder

public static java.util.Comparator nullLowOrder()
Returns a Comparator that uses a Comparable object's natural ordering, except null values are always considered low order. This Comparator allows naturally ordered TreeMaps to support null values.

nullLowOrder

public static java.util.Comparator nullLowOrder(java.util.Comparator c)
Returns a Comparator that wraps the given Comparator except null values are always considered low order. This fixes Comparators that don't support comparisons against null and allows them to be used in TreeMaps.

nullHighOrder

public static java.util.Comparator nullHighOrder()
Returns a Comparator that uses a Comparable object's natural ordering, except null values are always considered high order. This Comparator allows naturally ordered TreeMaps to support null values.

nullHighOrder

public static java.util.Comparator nullHighOrder(java.util.Comparator c)
Returns a Comparator that wraps the given Comparator except null values are always considered high order. This fixes Comparators that don't support comparisons against null and allows them to be used in TreeMaps.

nullEqualOrder

public static java.util.Comparator nullEqualOrder()
Returns a Comparator that uses a Comparable object's natural ordering, except null values are always considered equal order. This Comparator should not be used in a TreeMap, but can be used in a sorter.

nullEqualOrder

public static java.util.Comparator nullEqualOrder(java.util.Comparator c)
Returns a Comparator that wraps the given Comparator except null values are always considered equal order. This Comparator should not be used in a TreeMap, but can be used in a sorter.

reverseOrder

public static java.util.Comparator reverseOrder(java.util.Comparator c)
Returns a Comparator that wraps the given Comparator, but orders in reverse.

intern

public static java.lang.Object intern(java.lang.Object obj)
Just like String.intern, except it generates flyweights for any kind of object, and it does not prevent them from being garbage collected. Calling intern on a String does not use the same String pool used by String.intern because those Strings are not always garbage collected. Some virtual machines free up Strings from the interned String pool, others do not.

For objects that do not customize the hashCode and equals methods, calling intern is not very useful because the object returned will always be the same as the one passed in.

The object type returned from intern is guaranteed to be exactly the same type as the one passed in. Calling intern on null returns null.

Parameters:
obj - Object to intern
Returns:
Interned object.
See Also:
FlyweightSet