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.
Version:
$Revision: 1.5 $
Author:
Karsten Lentzsch
Since:
1.2

Method Summary

static void
assertNotBlank(String text, String description)
Throws an exception if the specified text is blank using the given text description.
static void
assertNotNull(Object object, String description)
Throws an NPE if the given object is null that uses the specified text to describe the object.
static boolean
equals(Object o1, Object o2)
Checks and answers if the two objects are both null or equal.
static boolean
isBlank(String str)
Checks and answers if the given string is whitespace, empty (""), or null.
static boolean
isLafAqua()
Lazily checks and answers whether the Aqua look&feel is active.
static boolean
isNotBlank(String str)
Checks and answers if the given string is not empty (""), not null and not whitespace only.

Method Details

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

assertNotNull

public static void assertNotNull(Object object,
                                 String description)
Throws an NPE if the given object is 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

equals

public static boolean equals(Object o1,
                             Object o2)
Checks and answers if the two objects are both 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 true if and only if both objects are null or equal

isBlank

public static boolean isBlank(String str)
Checks and answers if the given string is whitespace, empty (""), or 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 benull
Returns:
true if the string is whitespace, empty, or null

isLafAqua

public static boolean isLafAqua()
Lazily checks and answers whether the Aqua look&feel is active.
Returns:
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 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 null
Returns:
true if the string is not empty and not null and not whitespace only

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