com.metamatrix.core.util
Class StringUtilities

java.lang.Object
  extended by com.metamatrix.core.util.StringUtilities

public class StringUtilities
extends java.lang.Object

This class contains static utilities that return strings that are the result of manipulating other strings or objects.

Since:
3.1
Version:
3.1
Author:
John P. A. Verhaeg

Field Summary
static java.lang.String LINE_SEPARATOR
          The String that should be used to separate lines; defaults to NEW_LINE
static java.lang.String LINE_SEPARATOR_PROPERTY_NAME
          The name of the System property that specifies the string that should be used to separate lines.
static java.lang.String NEW_LINE
          The String "\n"
 
Constructor Summary
StringUtilities()
           
 
Method Summary
static java.lang.String buildPath(java.lang.String prefix, java.lang.String suffix)
          Returns the path representing the concatenation of the specified path prefix and suffix.
static java.lang.String condenseToLength(java.lang.String originalString, int maxLength, int endLength, java.lang.String middleString)
           
static java.lang.String getLastUpperCharToken(java.lang.String value)
          Returns a new string that represents the last fragment of the original string that begins with an uppercase char.
static java.lang.String getLastUpperCharToken(java.lang.String value, java.lang.String lastToken)
          Returns a new string that represents the last fragment of the original string that begins with an uppercase char.
static java.lang.String[] getLines(java.lang.String value)
           
static java.lang.String getLineSeparator()
           
static java.lang.String lowerCaseFirstChar(java.lang.String value)
          Returns a new string that lowercases the first character in the passed in value String
static java.lang.String removeChars(java.lang.String value, char[] chars)
           
static java.lang.String removeExtraWhitespace(java.lang.String value)
          Replaces multiple sequential "whitespace" characters from the specified string with a single space character, where whitespace includes \r\t\n and other characters
static java.lang.String replaceWhitespace(java.lang.String value, boolean stripExtras)
          Replaces all "whitespace" characters from the specified string with space characters, where whitespace includes \r\t\n and other characters
static java.lang.String replaceWhitespace(java.lang.String value, java.lang.String replaceWith, boolean stripExtras)
          Replaces all "whitespace" characters from the specified string with space characters, where whitespace includes \r\t\n and other characters
static java.lang.String upperCaseFirstChar(java.lang.String value)
          Returns a new string that uppercases the first character in the passed in value String
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NEW_LINE

public static final java.lang.String NEW_LINE
The String "\n"

See Also:
Constant Field Values

LINE_SEPARATOR_PROPERTY_NAME

public static final java.lang.String LINE_SEPARATOR_PROPERTY_NAME
The name of the System property that specifies the string that should be used to separate lines. This property is a standard environment property that is usually set automatically.

See Also:
Constant Field Values

LINE_SEPARATOR

public static final java.lang.String LINE_SEPARATOR
The String that should be used to separate lines; defaults to NEW_LINE

Constructor Detail

StringUtilities

public StringUtilities()
Method Detail

getLineSeparator

public static java.lang.String getLineSeparator()

buildPath

public static java.lang.String buildPath(java.lang.String prefix,
                                         java.lang.String suffix)
Returns the path representing the concatenation of the specified path prefix and suffix. The resulting path is guaranteed to have exactly one file separator between the prefix and suffix.

Parameters:
prefix - The path prefix
suffix - The path suffix
Returns:
The concatenated path prefix and suffix
Since:
3.1

lowerCaseFirstChar

public static java.lang.String lowerCaseFirstChar(java.lang.String value)
Returns a new string that lowercases the first character in the passed in value String

Parameters:
value -
Returns:
String

upperCaseFirstChar

public static java.lang.String upperCaseFirstChar(java.lang.String value)
Returns a new string that uppercases the first character in the passed in value String

Parameters:
value -
Returns:
String

getLastUpperCharToken

public static java.lang.String getLastUpperCharToken(java.lang.String value,
                                                     java.lang.String lastToken)
Returns a new string that represents the last fragment of the original string that begins with an uppercase char. Ex: "getSuperTypes" would return "Types".

Parameters:
value -
lastToken - - the last token tried... if not null will look backwards from the last token instead of the end of the value param
Returns:
String

getLastUpperCharToken

public static java.lang.String getLastUpperCharToken(java.lang.String value)
Returns a new string that represents the last fragment of the original string that begins with an uppercase char. Ex: "getSuperTypes" would return "Types".

Parameters:
value -
Returns:
String

getLines

public static java.lang.String[] getLines(java.lang.String value)

removeChars

public static java.lang.String removeChars(java.lang.String value,
                                           char[] chars)

replaceWhitespace

public static java.lang.String replaceWhitespace(java.lang.String value,
                                                 boolean stripExtras)
Replaces all "whitespace" characters from the specified string with space characters, where whitespace includes \r\t\n and other characters

Parameters:
value - the string to work with
stripExtras - if true, replace multiple whitespace characters with a single character.
See Also:
Pattern

replaceWhitespace

public static java.lang.String replaceWhitespace(java.lang.String value,
                                                 java.lang.String replaceWith,
                                                 boolean stripExtras)
Replaces all "whitespace" characters from the specified string with space characters, where whitespace includes \r\t\n and other characters

Parameters:
value - the string to work with
replaceWith - the character to replace with
stripExtras - if true, replace multiple whitespace characters with a single character.
See Also:
Pattern

removeExtraWhitespace

public static java.lang.String removeExtraWhitespace(java.lang.String value)
Replaces multiple sequential "whitespace" characters from the specified string with a single space character, where whitespace includes \r\t\n and other characters

Parameters:
value - the string to work with
See Also:
Pattern

condenseToLength

public static java.lang.String condenseToLength(java.lang.String originalString,
                                                int maxLength,
                                                int endLength,
                                                java.lang.String middleString)
Parameters:
originalString -
maxLength -
endLength -
middleString -
Returns:
Since:
5.0


Copyright © 2009. All Rights Reserved.