de.mguennewig.pobjects
Class PObjUtils

java.lang.Object
  extended by de.mguennewig.pobjects.PObjUtils

public final class PObjUtils
extends java.lang.Object

Static class with multiple utility methods.

Author:
Michael Günnewig

Method Summary
static
<T extends java.lang.Appendable & java.lang.CharSequence>
void
appendList(T sb, java.util.Collection<?> list, java.lang.String sep)
          Appends the text representations of the values in the list to the buffer and inserts the given separator between each.
static boolean endsWithIgnoreCase(java.lang.String s, java.lang.String suffix)
          Tests if this string ends with the specified suffix, but ignores case.
static java.lang.String join(java.lang.String sep, java.lang.Object[] list)
          Joins the separate elements of list into a single with fields separated by sep and returns that new string.
static java.lang.String lcfirst(java.lang.String str)
          Analog to ucfirst(String) but with lower case letter.
static java.lang.String quotedString(java.lang.String s)
          Returns the string as quoted JAVA string for class generation.
static java.lang.String squeeze(java.lang.String s)
          Returns the string with multiple whitespace replaced by one.
static boolean startsWithIgnoreCase(java.lang.String s, java.lang.String prefix)
          Tests if this string starts with the specified prefix, but ignores case.
static java.lang.String toAllCapsCase(java.lang.String str)
          Returns a upper case string of the given one, but adds underscores between each change of lower case to upper case, also known as All Caps Case.
static java.lang.Class<?> tryToLoadClass(java.lang.String className)
          Tries to load the class identified by className.
static java.lang.String ucfirst(java.lang.String str)
          Like String.toUpperCase() but only affects the first character of the string.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

join

public static java.lang.String join(java.lang.String sep,
                                    java.lang.Object[] list)
Joins the separate elements of list into a single with fields separated by sep and returns that new string.

See Also:
String.split(String)

appendList

public static <T extends java.lang.Appendable & java.lang.CharSequence> void appendList(T sb,
                                                                                       java.util.Collection<?> list,
                                                                                       java.lang.String sep)
Appends the text representations of the values in the list to the buffer and inserts the given separator between each.

Parameters:
sb - The appendable character sequence to which the generated string should be appended.
list - A list of values whose text representations will be added to the buffer.
sep - The separator which will be inserted between each two text representations of the values from the list.

lcfirst

public static java.lang.String lcfirst(java.lang.String str)
Analog to ucfirst(String) but with lower case letter.


ucfirst

public static java.lang.String ucfirst(java.lang.String str)
Like String.toUpperCase() but only affects the first character of the string.

See Also:
"Perl's ucfirst function"

startsWithIgnoreCase

public static boolean startsWithIgnoreCase(java.lang.String s,
                                           java.lang.String prefix)
Tests if this string starts with the specified prefix, but ignores case.

This is equivalent to s.regionMatches(true, 0, prefix, 0, prefix.length()).

Throws:
java.lang.NullPointerException - if any parameter is null.
See Also:
String.startsWith(String), String.regionMatches(boolean,int,String,int,int)

endsWithIgnoreCase

public static boolean endsWithIgnoreCase(java.lang.String s,
                                         java.lang.String suffix)
Tests if this string ends with the specified suffix, but ignores case.

This is equivalent to s.regionMatches(true, s.length()-prefix.length(), prefix, 0, prefix.length()).

See Also:
String.endsWith(String), String.regionMatches(boolean,int,String,int,int)

squeeze

public static java.lang.String squeeze(java.lang.String s)
Returns the string with multiple whitespace replaced by one.


quotedString

public static java.lang.String quotedString(java.lang.String s)
Returns the string as quoted JAVA string for class generation.


toAllCapsCase

public static java.lang.String toAllCapsCase(java.lang.String str)
Returns a upper case string of the given one, but adds underscores between each change of lower case to upper case, also known as All Caps Case.

ex.: Foobar results in FOOBAR, but FooBar results in FOO_BAR.


tryToLoadClass

public static java.lang.Class<?> tryToLoadClass(java.lang.String className)
Tries to load the class identified by className.

Parameters:
className - A full qualified class name.
See Also:
Class.forName(String)