org.jurvis.lang
Class JvStringUtilities

java.lang.Object
  extended by org.jurvis.lang.JvStringUtilities

public final class JvStringUtilities
extends Object

Various utility methods useful in manipulating Strings.

Author:
Neil W. Weber

Constructor Summary
JvStringUtilities()
           
 
Method Summary
static String baseName(String name)
          Return the base name of the specified name.
static String capitalize(String s)
          Utility method to take a string and capitalize it.
static int countOf(String str, int ch)
          Return the number of times the specified character is found within the string.
static String decapitalize(String name)
          Utility method to take a string and convert it to normal Java variable name capitalization.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JvStringUtilities

public JvStringUtilities()
Method Detail

capitalize

public static String capitalize(String s)
Utility method to take a string and capitalize it. The first character of each word is capitalized and all the remaining characters in the word are made lower case. For example, "foo BAR" becomes "Foo Bar."

Parameters:
s - the string to be capitalized
Returns:
the capitalized version of the string

decapitalize

public static String decapitalize(String name)
Utility method to take a string and convert it to normal Java variable name capitalization. This normally means converting the first character from upper case to lower case, but in the (unusual) special case when there is more than one character and both the first and second characters are upper case, we leave it alone.

Thus "FooBah" becomes "fooBah" and "X" becomes "x", but "URL" stays as "URL".

Parameters:
name - The string to be decapitalized.
Returns:
The decapitalized version of the string.

baseName

public static String baseName(String name)
Return the base name of the specified name. The base name is the portion of the name on the right of the last '.'.

Parameters:
name - the name to compute the basename of
Returns:
the base name

countOf

public static int countOf(String str,
                          int ch)
Return the number of times the specified character is found within the string.

Parameters:
str - the string to search within
ch - the character to search for
Returns:
the number of times the character is found


Copyright © 1999-2004 Neil W. Weber. All Rights Reserved.