com.jgoodies.forms.util

Class FormUtils

public final class FormUtils extends Object

Consists only of static utility methods. This class may be merged with the FormLayoutUtils extra - or not.

Since: 1.2

Version: $Revision: 1.5 $

Author: Karsten Lentzsch

Method Summary
static voidassertNotBlank(String text, String description)
Throws an exception if the specified text is blank using the given text description.
static voidassertNotNull(Object object, String description)
Throws an NPE if the given object is {@code null} that uses the specified text to describe the object.
static booleanequals(Object o1, Object o2)
Checks and answers if the two objects are both {@code null} or equal.
static booleanisBlank(String str)
Checks and answers if the given string is whitespace, empty (""), or {@code null}.
static booleanisLafAqua()
Lazily checks and answers whether the Aqua look&feel is active.
static booleanisNotBlank(String str)
Checks and answers if the given string is not empty (""), not {@code null} and not whitespace only.

Method Detail

assertNotBlank

public static void assertNotBlank(String text, String description)
Throws an exception if the specified text is blank using the given text description.

Parameters: text the text to check description describes the text, used in the exception message

Throws: NullPointerException if {@code text} is {@code null} IllegalArgumentException if {@code text} is empty, or blank

assertNotNull

public static void assertNotNull(Object object, String description)
Throws an NPE if the given object is {@code null} that uses the specified text to describe the object.

Parameters: object the text to check description describes the object, used in the exception message

Throws: NullPointerException if {@code object} is {@code null}

equals

public static boolean equals(Object o1, Object o2)
Checks and answers if the two objects are both {@code null} or equal.
 #equals(null, null)  == true
 #equals("Hi", "Hi")  == true
 #equals("Hi", null)  == false
 #equals(null, "Hi")  == false
 #equals("Hi", "Ho")  == false
 

Parameters: o1 the first object to compare o2 the second object to compare

Returns: boolean {@code true} if and only if both objects are {@code null} or equal

isBlank

public static boolean isBlank(String str)
Checks and answers if the given string is whitespace, empty (""), or {@code null}.
 FormUtils.isBlank(null)    == true
 FormUtils.isBlank("")      == true
 FormUtils.isBlank(" ")     == true
 FormUtils.isBlank(" abc")  == false
 FormUtils.isBlank("abc ")  == false
 FormUtils.isBlank(" abc ") == false
 

Parameters: str the string to check, may be{@code null}

Returns: {@code true} if the string is whitespace, empty, or {@code null}

isLafAqua

public static boolean isLafAqua()
Lazily checks and answers whether the Aqua look&feel is active.

Returns: {@code true} if the current look&feel is Aqua

isNotBlank

public static boolean isNotBlank(String str)
Checks and answers if the given string is not empty (""), not {@code null} and not whitespace only.
 FormUtils.isNotBlank(null)    == false
 FormUtils.isNotBlank("")      == false
 FormUtils.isNotBlank(" ")     == false
 FormUtils.isNotBlank(" abc")  == true
 FormUtils.isNotBlank("abc ")  == true
 FormUtils.isNotBlank(" abc ") == true
 

Parameters: str the string to check, may be {@code null}

Returns: {@code true} if the string is not empty and not {@code null} and not whitespace only

Copyright © 2002-2008 JGoodies Karsten Lentzsch. All Rights Reserved.