org.apache.turbine.util
Class ObjectUtils

java.lang.Object
  extended byorg.apache.turbine.util.ObjectUtils

public abstract class ObjectUtils
extends java.lang.Object

This is where common Object manipulation routines should go.

Version:
$Id: ObjectUtils.java 538432 2007-05-16 05:06:33Z seade $
Author:
Nissim Karpenstein, Henning P. Schmiedehausen

Constructor Summary
ObjectUtils()
           
 
Method Summary
static void addOnce(java.util.List l, java.lang.Object o)
          Deprecated. Use org.apache.commons.collections.SetUniqueList instead.
static java.lang.Object deserialize(byte[] objectData)
          Deserializes a single object from an array of bytes.
static boolean equals(java.lang.Object o1, java.lang.Object o2)
          Deprecated. Use org.apache.commons.lang.ObjectUtils.equals()
static java.lang.Object isNull(java.lang.Object o, java.lang.Object dflt)
          Deprecated. Use org.apache.commons.lang.ObjectUtils.defaultIfNull()
static void safeAddToHashtable(java.util.Hashtable hash, java.lang.Object key, java.lang.Object value)
          Deprecated. No replacement
static byte[] serializeHashtable(java.util.Hashtable hash)
          Converts a hashtable to a byte array for storage/serialization.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectUtils

public ObjectUtils()
Method Detail

isNull

public static java.lang.Object isNull(java.lang.Object o,
                                      java.lang.Object dflt)
Deprecated. Use org.apache.commons.lang.ObjectUtils.defaultIfNull()

Returns a default value if the object passed is null.

Parameters:
o - The object to test.
dflt - The default value to return.
Returns:
The object o if it is not null, dflt otherwise.

addOnce

public static void addOnce(java.util.List l,
                           java.lang.Object o)
Deprecated. Use org.apache.commons.collections.SetUniqueList instead.

Adds an object to a list, making sure the object is in the list only once.

Parameters:
l - The list.
o - The object.

serializeHashtable

public static byte[] serializeHashtable(java.util.Hashtable hash)
                                 throws java.lang.Exception
Converts a hashtable to a byte array for storage/serialization.

Parameters:
hash - The Hashtable to convert.
Returns:
A byte[] with the converted Hashtable.
Throws:
java.lang.Exception - A generic exception.

deserialize

public static java.lang.Object deserialize(byte[] objectData)
Deserializes a single object from an array of bytes.

Parameters:
objectData - The serialized object.
Returns:
The deserialized object, or null on failure.

equals

public static boolean equals(java.lang.Object o1,
                             java.lang.Object o2)
Deprecated. Use org.apache.commons.lang.ObjectUtils.equals()

Compares two Objects, returns true if their values are the same. It checks for null values prior to an o1.equals(o2) check

Parameters:
o1 - The first object.
o2 - The second object.
Returns:
True if the values of both xstrings are the same.

safeAddToHashtable

public static final void safeAddToHashtable(java.util.Hashtable hash,
                                            java.lang.Object key,
                                            java.lang.Object value)
                                     throws java.lang.NullPointerException
Deprecated. No replacement

Nice method for adding data to a Hashtable in such a way as to not get NPE's. The point being that if the value is null, Hashtable.put() will throw an exception. That blows in the case of this class cause you may want to essentially treat put("Not Null", null ) == put("Not Null", "") We will still throw a NPE if the key is null cause that should never happen.

Throws:
java.lang.NullPointerException


Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.