org.apache.turbine.util
Class ObjectUtils

java.lang.Object
  |
  +--org.apache.turbine.util.ObjectUtils

public class ObjectUtils
extends java.lang.Object

This is where common Object manipulation routines should go.

Version:
$Id: ObjectUtils.java,v 1.2 2002/07/11 16:53:21 mpoeschl Exp $
Author:
Nissim Karpenstein

Constructor Summary
ObjectUtils()
           
 
Method Summary
static void addOnce(java.util.Vector v, java.lang.Object o)
          Adds an object to a vector, making sure the object is in the vector only once.
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)
          Compares two Objects, returns true if their values are the same.
static java.lang.Object isNull(java.lang.Object o, java.lang.Object dflt)
          Returns a default value if the object passed is null.
static void safeAddToHashtable(java.util.Hashtable hash, java.lang.Object key, java.lang.Object value)
          Nice method for adding data to a Hashtable in such a way as to not get NPE's.
 
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)
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.Vector v,
                           java.lang.Object o)
Adds an object to a vector, making sure the object is in the vector only once.
Parameters:
v - The vector.
o - The object.

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)
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
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.


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