com.sun.enterprise.util
Class StringUtils

java.lang.Object
  extended by com.sun.enterprise.util.StringUtils

public class StringUtils
extends java.lang.Object


Field Summary
static java.lang.String EOL
           
static java.lang.String NEWLINE
           
 
Method Summary
static java.lang.String cat(java.lang.String separator, java.lang.String... list)
          Concatenate a list of strings, putting a separator in between each one.
static java.lang.String formatSQLException(java.sql.SQLException ex)
           
static java.lang.String getPenultimateDirName(java.lang.String s)
           
static java.lang.String getProperty(java.lang.String propName)
          Get a system propety given a property name, possibly trying all combination of upercase, name mangling to get a value.
static java.lang.String getStackTrace(java.lang.Throwable t)
           
static boolean isHex(char c)
           
static boolean isHex(java.lang.String s)
           
static boolean isToken(java.lang.String s)
           
static void main(java.lang.String[] args)
           
static java.lang.String makeFilePath(java.lang.String[] strings, boolean addTrailing)
          A utility to get the Operating System specific path from given array of Strings.
static int maxWidth(java.util.Vector v)
           
static boolean ok(java.lang.String s)
           
static java.lang.String padLeft(java.lang.String s, int len)
           
static java.lang.String padRight(java.lang.String s, int len)
           
static java.util.List<java.lang.String> parseStringList(java.lang.String line)
          Parses a string containing substrings separated from each other by the standard separator characters and returns a list of strings.
static java.util.List<java.lang.String> parseStringList(java.lang.String line, java.lang.String sep)
          Parses a string containing substrings separated from each other by the specified set of separator characters and returns a list of strings.
static void prepend(java.lang.String[] ss, java.lang.String what)
           
static java.lang.String quotePathIfNecessary(java.lang.String path)
          Nightmares can result from using a path with a space in it! This method will enclose in quotes if needed.
static java.lang.String removeChar(java.lang.String strOrig, char c)
          Remove a character from a String
static java.lang.String removeEnclosingQuotes(java.lang.String s)
          Removes the quoting around a String.
static java.lang.String replace(java.lang.String s, java.lang.String token, java.lang.String replace)
           
static int safeLength(java.lang.String s)
          return the length of the String - or 0 if it's null
static java.lang.String stripToken(java.lang.String s)
           
static void testUpperCase()
           
static java.lang.String[] toLines(java.lang.String s)
           
static java.lang.String toShortClassName(java.lang.String className)
           
static java.lang.String toString(java.util.Properties props)
           
static java.lang.String UpperCaseFirstLetter(java.lang.String s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NEWLINE

public static final java.lang.String NEWLINE

EOL

public static final java.lang.String EOL
Method Detail

safeLength

public static int safeLength(java.lang.String s)
return the length of the String - or 0 if it's null


ok

public static boolean ok(java.lang.String s)

formatSQLException

public static java.lang.String formatSQLException(java.sql.SQLException ex)

maxWidth

public static int maxWidth(java.util.Vector v)

isHex

public static boolean isHex(java.lang.String s)

isHex

public static boolean isHex(char c)

getPenultimateDirName

public static java.lang.String getPenultimateDirName(java.lang.String s)

toShortClassName

public static java.lang.String toShortClassName(java.lang.String className)

padRight

public static java.lang.String padRight(java.lang.String s,
                                        int len)

padLeft

public static java.lang.String padLeft(java.lang.String s,
                                       int len)

toLines

public static java.lang.String[] toLines(java.lang.String s)

prepend

public static void prepend(java.lang.String[] ss,
                           java.lang.String what)

UpperCaseFirstLetter

public static java.lang.String UpperCaseFirstLetter(java.lang.String s)

replace

public static java.lang.String replace(java.lang.String s,
                                       java.lang.String token,
                                       java.lang.String replace)

toString

public static java.lang.String toString(java.util.Properties props)

main

public static void main(java.lang.String[] args)

testUpperCase

public static void testUpperCase()

makeFilePath

public static java.lang.String makeFilePath(java.lang.String[] strings,
                                            boolean addTrailing)
A utility to get the Operating System specific path from given array of Strings.

Parameters:
strings - an array of Strings participating in the path.
addTrailing - a boolean that determines whether the returned String should have a trailing File Separator character. None of the strings may be null or empty String. An exception is thrown.
Returns:
a String that concatenates these Strings and gets a path. Returns a null if the array is null or contains no elements.
Throws:
java.lang.IllegalArgumentException - if any of the arguments is null or is an empty string.

parseStringList

public static java.util.List<java.lang.String> parseStringList(java.lang.String line)
Parses a string containing substrings separated from each other by the standard separator characters and returns a list of strings. Splits the string line into individual string elements separated by the field separators, and returns these individual strings as a list of strings. The individual string elements are trimmed of leading and trailing whitespace. Only non-empty strings are returned in the list.

Parameters:
line - The string to split
Returns:
Returns the list containing the individual strings that the input string was split into.

parseStringList

public static java.util.List<java.lang.String> parseStringList(java.lang.String line,
                                                               java.lang.String sep)
Parses a string containing substrings separated from each other by the specified set of separator characters and returns a list of strings. Splits the string line into individual string elements separated by the field separators specified in sep, and returns these individual strings as a list of strings. The individual string elements are trimmed of leading and trailing whitespace. Only non-empty strings are returned in the list.

Parameters:
line - The string to split
sep - The list of separators to use for determining where the string should be split. If null, then the standard separators (see StringTokenizer javadocs) are used.
Returns:
Returns the list containing the individual strings that the input string was split into.

getProperty

public static java.lang.String getProperty(java.lang.String propName)
Get a system propety given a property name, possibly trying all combination of upercase, name mangling to get a value.

Parameters:
propName - the approximate system property name
Returns:
the property value if found, null otherwise

removeChar

public static java.lang.String removeChar(java.lang.String strOrig,
                                          char c)
Remove a character from a String

Parameters:
strOrig - original string
c - character to remove from the string
Returns:
String with specified characters removed

getStackTrace

public static java.lang.String getStackTrace(java.lang.Throwable t)

isToken

public static final boolean isToken(java.lang.String s)

stripToken

public static final java.lang.String stripToken(java.lang.String s)

cat

public static java.lang.String cat(java.lang.String separator,
                                   java.lang.String... list)
Concatenate a list of strings, putting a separator in between each one. If the list is one string, then the separator is not used. The separator will never be added to the start or end of the returned string. When empty or null strings are encountered in the list of strings they are ignore.

Parameters:
separator - Separator to use between concatenated strings
list - List of strings to concatenate together
Returns:
String created by concatenating provided strings

removeEnclosingQuotes

public static java.lang.String removeEnclosingQuotes(java.lang.String s)
Removes the quoting around a String.

Parameters:
s - The String that may have enclosing quotes
Returns:
The String resulting from removing the enclosing quotes

quotePathIfNecessary

public static java.lang.String quotePathIfNecessary(java.lang.String path)
Nightmares can result from using a path with a space in it! This method will enclose in quotes if needed.

Parameters:
path -
Returns:


Copyright © 2012 GlassFish Community. All Rights Reserved.