org.almendra.commons.util
Class StringUtility

java.lang.Object
  extended by org.almendra.commons.util.StringUtility

public class StringUtility
extends java.lang.Object

Contains several helper methods not found in java.lang.String to manipulate strings. As java.lang.String is a system class it cannot be subclassed or extended. Class StringUtility is therefore used to hold these helper methods.

Author:
Oliver Plohmann

Field Summary
static java.lang.String TAB
           
 
Constructor Summary
StringUtility()
          Creates a new StringUtility object.
 
Method Summary
static boolean contains(java.lang.String str, java.lang.String subStr)
          Check whether parameter str contains parmater subStr without using the "ugly" call indexOf(subStr) !
static int count(java.lang.String str, java.lang.String subString)
           
static java.lang.String getIntegerSuffix(java.lang.String str)
           
static boolean isAsterisk(java.lang.String str)
           
static boolean isValid(java.lang.String str)
          Check whether a string is valid, e.g. not null and not empty.
static int linesCount(java.lang.String str)
           
static java.lang.String print(java.lang.String str)
          Create a print string (string additionally enclosed with quotes) for parameter str.
static java.lang.String remove(java.lang.String str, java.lang.String subStr)
           
static java.lang.String reverse(java.lang.String str)
          Reverse a string without using StringBuffer everytime a string has to be reversed.
static java.lang.String reversePackageName(java.lang.String name)
          Reverse a fully qualified Java package name, e.g. java.lang.String turns into String.lang.java.
static java.lang.String rightPadded(java.lang.String attribute, int paddingValue)
           
static java.lang.String spaces(int count)
           
static java.lang.String[] toArray(java.util.List list)
           
static java.lang.String[] toArray(java.lang.String stringWithDelimiters, java.lang.String delimiter)
          Return an array with all the substrings of a string.
static java.lang.Integer toInteger(java.lang.String str)
          Convert a String into an Integer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TAB

public static final java.lang.String TAB
See Also:
Constant Field Values
Constructor Detail

StringUtility

public StringUtility()
Creates a new StringUtility object.

Method Detail

reverse

public static java.lang.String reverse(java.lang.String str)
Reverse a string without using StringBuffer everytime a string has to be reversed.

Parameters:
str - the string to be reversed
Returns:

isValid

public static boolean isValid(java.lang.String str)
Check whether a string is valid, e.g. not null and not empty.

Parameters:
str -
Returns:

reversePackageName

public static java.lang.String reversePackageName(java.lang.String name)
Reverse a fully qualified Java package name, e.g. java.lang.String turns into String.lang.java.

Parameters:
name - the package name
Returns:
the reversed package name

print

public static java.lang.String print(java.lang.String str)
Create a print string (string additionally enclosed with quotes) for parameter str. Return ""null"" (with double quotes) in case str is null to make it be displayed in quotes.

Parameters:
str -
Returns:

contains

public static boolean contains(java.lang.String str,
                               java.lang.String subStr)
Check whether parameter str contains parmater subStr without using the "ugly" call indexOf(subStr) != -1 every time.

Parameters:
str -
subStr -
Returns:

toInteger

public static java.lang.Integer toInteger(java.lang.String str)
Convert a String into an Integer. Return null if str contains non-digits.

Parameters:
str - String to be converted into an Integer
Returns:
Integer or null if str contained non-digit chars.

toArray

public static java.lang.String[] toArray(java.lang.String stringWithDelimiters,
                                         java.lang.String delimiter)
Return an array with all the substrings of a string.

Parameters:
stringWithDelimiters - the string to be converted
delimiter - the delimiter that separates substrings
Returns:
an array with every substring as an element

remove

public static java.lang.String remove(java.lang.String str,
                                      java.lang.String subStr)

getIntegerSuffix

public static java.lang.String getIntegerSuffix(java.lang.String str)

rightPadded

public static java.lang.String rightPadded(java.lang.String attribute,
                                           int paddingValue)
Parameters:
attribute -
i -
Returns:

isAsterisk

public static boolean isAsterisk(java.lang.String str)
Parameters:
maxCommandsString -
Returns:

linesCount

public static int linesCount(java.lang.String str)

spaces

public static java.lang.String spaces(int count)

count

public static int count(java.lang.String str,
                        java.lang.String subString)

toArray

public static java.lang.String[] toArray(java.util.List list)