net.charlesames.utility.common
Class StringMethods

java.lang.Object
  extended by net.charlesames.utility.common.StringMethods

public abstract class StringMethods
extends java.lang.Object

Miscellaneous string-manipulation functions

Author:
Charles Ames

Constructor Summary
StringMethods()
           
 
Method Summary
static byte[] ascii7BitFromString(java.lang.String text)
          downgrades a string from unicode to 7-bit ASCII.
static byte[] asciiFromString(java.lang.String text)
          downgrades a string from unicode to 8-bit ASCII.
static void checkName(java.lang.String name, boolean allowSpaces, boolean allowInitialDigit)
          Check that the indicated name is a sequence of letters and digits.
static boolean containsWhitespace(java.lang.String text)
          Checks a string for whitespace.
static boolean isNullOrBlank(java.lang.String arg0)
          Checks if a string is blank, while accommodating a null argument.
static java.lang.String padLeft(java.lang.String text, int length)
          Pad the indicated text with blanks on the left to obtain the indicated length.
static java.lang.String padRight(java.lang.String text, int length)
          Pad the indicated text with blanks on the right to obtain the indicated length.
static boolean stringEquals(java.lang.String arg0, java.lang.String arg1)
          Tests if two strings are equal, while accommodating null arguments.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringMethods

public StringMethods()
Method Detail

containsWhitespace

public static boolean containsWhitespace(java.lang.String text)
Checks a string for whitespace.

Parameters:
text - The string to be checked.
Returns:
True if the string contains whitespace; false otherwise.

stringEquals

public static boolean stringEquals(java.lang.String arg0,
                                   java.lang.String arg1)
Tests if two strings are equal, while accommodating null arguments.

Parameters:
arg0 - A string.
arg1 - A string.
Returns:
True if both arguments are null or if both arguments are non null and the strings are equal; false otherwise.

isNullOrBlank

public static boolean isNullOrBlank(java.lang.String arg0)
Checks if a string is blank, while accommodating a null argument.

Parameters:
arg0 - A string.
Returns:
True if the argument is null, or if a not-null argument is an empty string; false otherwise.

ascii7BitFromString

public static byte[] ascii7BitFromString(java.lang.String text)
downgrades a string from unicode to 7-bit ASCII.

Parameters:
text - The unicode text.
Returns:
A byte array of 7-bit ASCII values.

asciiFromString

public static byte[] asciiFromString(java.lang.String text)
downgrades a string from unicode to 8-bit ASCII.

Parameters:
text - The unicode text.
Returns:
A byte array of 8-bit ASCII values.

checkName

public static void checkName(java.lang.String name,
                             boolean allowSpaces,
                             boolean allowInitialDigit)
Check that the indicated name is a sequence of letters and digits.

Parameters:
name - The indicated name.
allowSpaces - True if spaces are allowed after the initial character; false otherwise.
allowInitialDigit - False if name must start with letter; true otherwise.

padRight

public static java.lang.String padRight(java.lang.String text,
                                        int length)
Pad the indicated text with blanks on the right to obtain the indicated length.
Source: http://stackoverflow.com/questions/388461/how-can-i-pad-a-string-in-java

Parameters:
text - The indicated text.
length - The indicated length.
Returns:
The padded text.

padLeft

public static java.lang.String padLeft(java.lang.String text,
                                       int length)
Pad the indicated text with blanks on the left to obtain the indicated length.
Source: http://stackoverflow.com/questions/388461/how-can-i-pad-a-string-in-java

Parameters:
text - The indicated text.
length - The indicated length.
Returns:
The padded text.