org.oclc.da.gdfr.registryprototype.utils
Class StringUtils

java.lang.Object
  extended by org.oclc.da.gdfr.registryprototype.utils.StringUtils

public class StringUtils
extends java.lang.Object

StringUtils A class that contains utility methods for string manipulation.

Author:
Jay Goodkin

Constructor Summary
StringUtils(java.lang.String str)
          Construct an instance of StringUtils with an existing string.
 
Method Summary
static java.lang.String addQuotes(java.lang.String str)
          Quote the string specified.
 java.lang.String firstToken()
          Return the first token of the current string.
static boolean isEmpty(java.lang.String str)
          Determine if the string specified is empty (null or blank).
 boolean isValidName()
          This method will check the string and ensure it is a valid name for IFS objects.
 java.lang.String lastToken()
          Return the last token of the current string.
static java.lang.String[] list2Array(java.lang.String list)
          This method will accept a comma delimited list and parse it out to an array of strings.
static java.lang.String[] list2Array(java.lang.String list, java.lang.String separator)
          This method will accept a delimited list and parse it out to an array of strings.
 java.lang.String nthToken(int index)
          Return the Nth token of the current string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringUtils

public StringUtils(java.lang.String str)
Construct an instance of StringUtils with an existing string.

Parameters:
str - The source string to use for subsequent method calls.
Method Detail

isEmpty

public static boolean isEmpty(java.lang.String str)
Determine if the string specified is empty (null or blank).

Parameters:
str - The string to check for being empty.

list2Array

public static java.lang.String[] list2Array(java.lang.String list)
This method will accept a comma delimited list and parse it out to an array of strings. This is intended for use with properties but could be useful elsewhere.

Parameters:
list - This is the delimited list of strings to parse
Returns:
The array of strings parsed from the list.

list2Array

public static java.lang.String[] list2Array(java.lang.String list,
                                            java.lang.String separator)
This method will accept a delimited list and parse it out to an array of strings. This is intended for use with properties but could be useful elsewhere.

Parameters:
list - This is the delimited list of strings to parse
separator - This is the character that will be used to delimit the list
Returns:
The array of strings parsed from the list.

firstToken

public java.lang.String firstToken()
Return the first token of the current string.

Returns:
The first token using the standard whitspace definition as defined in StringTokenizer. Null is returned if there are no tokens.

isValidName

public boolean isValidName()
This method will check the string and ensure it is a valid name for IFS objects. We are only allowing alphanumeric characters, spaces, dashes and underscores in our names.

Returns:
true if the string is a valid name, otherwise false.

lastToken

public java.lang.String lastToken()
Return the last token of the current string.

Returns:
The last token using the standard whitspace definition as defined in StringTokenizer. Null is returned if there are no tokens.

nthToken

public java.lang.String nthToken(int index)
Return the Nth token of the current string.

Parameters:
index - The token (substring) number (1 for sirst token, 2 for second, etc.) to retrieve from the string.
Returns:
The nth token using the standard whitspace definition as defined in StringTokenizer. Null is returned if index is greater than the number of tokens.

addQuotes

public static java.lang.String addQuotes(java.lang.String str)
Quote the string specified.

Parameters:
str - A string to be quoted.
Returns:
The string surrounded by quotes.


Copyright © 2008 OCLC Online Computer Library Center, Inc.. All Rights Reserved.