/**
* Ensure void strings, namely blank, empty and null are
* canonically represented as the empty string, i.e. "".
* Advantage: fast testing for the void string.
* i.e. x.length() == 0 or == ""
* can always use String methods on the result.
* Unencumber base String of void String permitting garbage collection.
* No NullPointerException when you attempt String methods on a void String.
*
* @param pString to put into canonical form.
*
* @return "" if pString is null, empty or blank, pString.trim() otherwise.
*/
public final static String possiblyEmpty( String pString )
{
if ( pString == null ) return "";
pString = pString.trim();
if ( pString.length() == 0 ) return "";
return pString;
}
/**
* Ensure void strings, namely blank, empty and null
* are canonically represented as as null.
* Advantage: fast testing for the void string, == null.
* Unencumber base String of void String permitting garbage collection.
* NullPointerException when you attempt String methods on a void String.
*
* @param pString String to put into canonical form.
*
* @return null if pString is null, empty or blank, pString.trim() otherwise.
*/
public final static String possiblyNull( String pString )
{
if ( pString == null ) return null;
pString = pString.trim();
if ( pString.length() == 0 ) return null;
return pString;
}
/**
* Ensure void strings, namely blank, empty and null are
* caught. Throw NullPointerException if pString is void,
* namely null, empty or blank.
* @param pString to put into canonical form.
*
* @return pString.trim()
*/
public final static String neverNull( String pString )
{
pString = pString.trim();
if ( pString.length() == 0 ) throw new NullPointerException();
return pString;
}