org.apache.turbine.util
Class StringUtils

java.lang.Object
  |
  +--org.apache.turbine.util.StringUtils

public class StringUtils
extends java.lang.Object

This is where common String manipulation routines should go.

Version:
$Id: StringUtils.java,v 1.2 2001/09/09 01:31:29 fedor Exp $
Author:
Jon S. Stevens, Daniel Rall, Greg Coladonato

Field Summary
static int PPKEY_CLASSNAME
           
static int PPKEY_ID
           
static int PPKEY_PROPERTY
           
 
Constructor Summary
StringUtils()
           
 
Method Summary
static boolean equals(java.lang.String s1, java.lang.String s2)
          Compares two Strings, returns true if their values are the same.
static java.lang.String firstLetterCaps(java.lang.String data)
          Makes the first letter caps and leaves the rest as is.
static boolean isEmpty(java.lang.String foo)
          Determine whether a (trimmed) string is empty
static boolean isValid(java.lang.String foo)
          Validates that the supplied string is neither null nor the empty string.
static java.lang.String join(java.lang.String[] list, java.lang.String separator)
          Joins the elements of the provided array into a single string containing a list of CSV elements.
static java.lang.String makeString(java.lang.String foo)
          Deal with null strings converting them to "" instead.
static java.lang.String[] parseObjectKey(java.lang.String s)
          Takes a String of the form substring[substring]subtring and returns the 3 substrings
static java.lang.String removeUnderScores(java.lang.String data)
          Remove Underscores from a string and replaces first Letters with Capitals.
static java.lang.String[] split(java.lang.String text, java.lang.String separator)
          Splits the provided CSV text into a list.
static java.lang.String stackTrace(java.lang.Throwable e)
          Returns the output of printStackTrace as a String.
static java.lang.String stackTrace(java.lang.Throwable e, boolean addPre)
          Returns the output of printStackTrace as a String.
protected static java.lang.String wrapLine(java.lang.String line, java.lang.String newline, int wrapColumn)
          Wraps a single line of text.
static java.lang.String wrapText(java.lang.String inString, java.lang.String newline, int wrapColumn)
          Takes a block of text which might have long lines in it and wraps the long lines based on the supplied wrapColumn parameter.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

PPKEY_CLASSNAME

public static final int PPKEY_CLASSNAME

PPKEY_ID

public static final int PPKEY_ID

PPKEY_PROPERTY

public static final int PPKEY_PROPERTY
Constructor Detail

StringUtils

public StringUtils()
Method Detail

makeString

public static final java.lang.String makeString(java.lang.String foo)
Deal with null strings converting them to "" instead. It also invokes String.trim() on the output.
Parameters:
foo - A String.
Returns:
A String.

isValid

public static final boolean isValid(java.lang.String foo)
Validates that the supplied string is neither null nor the empty string.
Parameters:
foo - The text to check.
Returns:
Whether valid.

isEmpty

public static final boolean isEmpty(java.lang.String foo)
Determine whether a (trimmed) string is empty
Parameters:
foo - The text to check.
Returns:
Whether empty.

stackTrace

public static final java.lang.String stackTrace(java.lang.Throwable e)
Returns the output of printStackTrace as a String.
Parameters:
e - A Throwable.
Returns:
A String.

stackTrace

public static final java.lang.String stackTrace(java.lang.Throwable e,
                                                boolean addPre)
Returns the output of printStackTrace as a String.
Parameters:
e - A Throwable.
addPre - a boolean to add HTML
 tags around the stacktrace
Returns:
A String.

equals

public static boolean equals(java.lang.String s1,
                             java.lang.String s2)
Compares two Strings, returns true if their values are the same.
Parameters:
s1 - The first string.
s2 - The second string.
Returns:
True if the values of both strings are the same.

parseObjectKey

public static java.lang.String[] parseObjectKey(java.lang.String s)
Takes a String of the form substring[substring]subtring and returns the 3 substrings
Returns:
a three element String array

removeUnderScores

public static java.lang.String removeUnderScores(java.lang.String data)
Remove Underscores from a string and replaces first Letters with Capitals. foo_bar becomes FooBar

firstLetterCaps

public static java.lang.String firstLetterCaps(java.lang.String data)
Makes the first letter caps and leaves the rest as is.

split

public static java.lang.String[] split(java.lang.String text,
                                       java.lang.String separator)
Splits the provided CSV text into a list.
Parameters:
text - The CSV list of values to split apart.
separator - The separator character.
Returns:
The list of values.

join

public static java.lang.String join(java.lang.String[] list,
                                    java.lang.String separator)
Joins the elements of the provided array into a single string containing a list of CSV elements.
Parameters:
list - The list of values to join together.
separator - The separator character.
Returns:
The CSV text.

wrapText

public static java.lang.String wrapText(java.lang.String inString,
                                        java.lang.String newline,
                                        int wrapColumn)
Takes a block of text which might have long lines in it and wraps the long lines based on the supplied wrapColumn parameter. It was initially implemented for use by VelocityEmail. If there are tabs in inString, you are going to get results that are a bit strange, since tabs are a single character but are displayed as 4 or 8 spaces. Remove the tabs.
Parameters:
inString - Text which is in need of word-wrapping.
newline - The characters that define a newline.
wrapColumn - The column to wrap the words at.
Returns:
The text with all the long lines word-wrapped.

wrapLine

protected static java.lang.String wrapLine(java.lang.String line,
                                           java.lang.String newline,
                                           int wrapColumn)
Wraps a single line of text. Called by wrapText(). I can't think of any good reason for exposing this to the public, since wrapText should always be used AFAIK.
Parameters:
line - A line which is in need of word-wrapping.
newline - The characters that define a newline.
wrapColumn - The column to wrap the words at.
Returns:
A line with newlines inserted.


Copyright © 2000-2002 Apache Software Foundation. All Rights Reserved.