2004.04.29


com.jdc.lang
Class ObjectHelper

java.lang.Object
  |
  +--jdc.java.lang.Object
        |
        +--com.jdc.lang.ObjectHelper
Direct Known Subclasses:
StringHelper

public class ObjectHelper
extends Object

ObjectHelper is a utility class that provides basic String manipulation methods to the Object class.  For example, rather than coding the following to test for a non-null, non-blank String value:


 		if (!(string == null) && !(string.trim().equals("")))
		{
			// do something
		}
 
This object helper utility class simplifies the coding as follows:

 		if (helper.isValue(string))
		{
			// do something
		}
 
where helper is an instance of this class.   For additional String manipulation methods not provided by this utility class, refer to the StringHelper class.

Version:
1.0
Author:
Jay Damon
See Also:
Object, StringHelper, Serialized Form

Constructor Summary
ObjectHelper()
          Constructs a new ObjectHelper instance.
 
Method Summary
 boolean equals(String stringOne, String stringTwo)
          Returns true if the two input String field values are equal.
 boolean isNoValue(String string)
          Returns true if the String field contains a null or blank value.
 boolean isValue(String string)
          Returns true if the String field contains a non-null, non-blank value.
 String noValue()
          Returns an empty String value.
 String toValue(String string)
          Returns a non-null String value given a String field value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectHelper

public ObjectHelper()
Constructs a new ObjectHelper instance.

Method Detail

equals

public boolean equals(String stringOne,
                      String stringTwo)
Returns true if the two input String field values are equal. This convenience method is provided to simplify the comparison of two String field values, one or both of which may be null.

The two String field values are considered equal if one of the following is true:

Leading and trailing blanks (or spaces) are ignored by the String comparison. The comparison is case-sensitive.

For example:

Returns:
True if the String fields are considered equal.
False if the String fields are not considered equal.

noValue

public String noValue()
Returns an empty String value. An empty String is defined as "", i.e. a non-null String with no length. This convenience method is provided to return the defined static String constant NO_VALUE in the Object class and its subclasses which include an instance of this class.

Returns:
An empty String value.

isNoValue

public boolean isNoValue(String string)
Returns true if the String field contains a null or blank value. A String field that contains any number of blanks (or spaces) is considered a blank value.

Returns:
True if the String field contains a null or blank value.
False if the String field contains a non-null, non-blank value.

See Also:
isValue(java.lang.String)

isValue

public boolean isValue(String string)
Returns true if the String field contains a non-null, non-blank value. A String field that contains any number of blanks (or spaces) is considered a blank value.

Returns:
True if the String field contains a non-null, non-blank value.
False if the String field contains a null or blank value.

See Also:
isNoValue(java.lang.String)

toValue

public String toValue(String string)
Returns a non-null String value given a String field value. If the String field value is null, an empty String value is returned, i.e. a null value is never returned. Otherwise, the original String field value is returned with leading and trailing blanks (spaces) removed.

Returns:
A non-null String value.

2004.04.29



Copyright © 2004 J. Damon & Co.; All Rights Reserved WorldWide.