org.apache.velocity.util
Class StringUtils

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

public class StringUtils
extends java.lang.Object

This class provides some methods for dynamically invoking methods in objects, and some string manipulation methods used by torque. The string methods will soon be moved into the turbine string utilities class.

Version:
$Id: StringUtils.java,v 1.9 2001/03/05 11:48:39 jvanzyl Exp $
Author:
Jason van Zyl

Field Summary
private static java.lang.String EOL
           
private static int EOL_LENGTH
           
 
Constructor Summary
StringUtils()
           
 
Method Summary
 boolean allEmpty(java.util.ArrayList list)
          Check to see if all the string objects passed in are empty.
static java.lang.String chop(java.lang.String s, int i)
          Chop i characters off the end of a string.
static java.lang.String collapseNewlines(java.lang.String argStr)
          Remove/collapse multiple newline characters.
static java.lang.String collapseSpaces(java.lang.String argStr)
          Remove/collapse multiple spaces.
 java.lang.String concat(java.util.ArrayList list)
          Concatenates a list of objects as a String.
static java.lang.String fileContentsToString(java.lang.String file)
           
static java.lang.String firstLetterCaps(java.lang.String data)
          Makes the first letter caps and the rest lowercase.
static java.lang.String getPackageAsPath(java.lang.String pckge)
          Return a package name as a relative path name
static java.lang.String normalizePath(java.lang.String path)
          Return a context-relative path, beginning with a "/", that represents the canonical version of the specified path after ".." and "." elements are resolved out.
static java.lang.String removeUnderScores(java.lang.String data)
          Remove Underscores from a string and replaces first Letters with Capitals.
 java.lang.String select(boolean state, java.lang.String trueString, java.lang.String falseString)
           
static java.lang.String[] split(java.lang.String line, java.lang.String delim)
          Create a string array from a string separated by delim
static java.lang.String stackTrace(java.lang.Throwable e)
          Returns the output of printStackTrace as a String.
static java.lang.StringBuffer stringSubstitution(java.lang.String argStr, java.util.Hashtable vars)
           
static java.lang.String sub(java.lang.String line, java.lang.String oldString, java.lang.String newString)
          Replaces all instances of oldString with newString in line.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

EOL

private static final java.lang.String EOL

EOL_LENGTH

private static final int EOL_LENGTH
Constructor Detail

StringUtils

public StringUtils()
Method Detail

concat

public java.lang.String concat(java.util.ArrayList list)
Concatenates a list of objects as a String.
Parameters:
ArrayList - list of object to concatenate.
Returns:
String

getPackageAsPath

public static java.lang.String getPackageAsPath(java.lang.String pckge)
Return a package name as a relative path name
Parameters:
String - package name to convert to a directory.
Returns:
String directory path.

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.
Parameters:
String - string to remove underscores from.
Returns:
String

firstLetterCaps

public static java.lang.String firstLetterCaps(java.lang.String data)
Makes the first letter caps and the rest lowercase.
Parameters:
String -  
Returns:
String

split

public static java.lang.String[] split(java.lang.String line,
                                       java.lang.String delim)
Create a string array from a string separated by delim
Parameters:
line - the line to split
delim - the delimter to split by
Returns:
a string array of the split fields

chop

public static java.lang.String chop(java.lang.String s,
                                    int i)
Chop i characters off the end of a string. This method is sensitive to the EOL for a particular platform. The EOL character will considered a single character.
Parameters:
string - String to chop.
i - Number of characters to chop.
Returns:
String with processed answer.

stringSubstitution

public static java.lang.StringBuffer stringSubstitution(java.lang.String argStr,
                                                        java.util.Hashtable vars)

fileContentsToString

public static java.lang.String fileContentsToString(java.lang.String file)

collapseNewlines

public static java.lang.String collapseNewlines(java.lang.String argStr)
Remove/collapse multiple newline characters.
Parameters:
String - string to collapse newlines in.
Returns:
String

collapseSpaces

public static java.lang.String collapseSpaces(java.lang.String argStr)
Remove/collapse multiple spaces.
Parameters:
String - string to remove multiple spaces from.
Returns:
String

sub

public static final java.lang.String sub(java.lang.String line,
                                         java.lang.String oldString,
                                         java.lang.String newString)
Replaces all instances of oldString with newString in line. Taken from the Jive forum package.
Parameters:
String - original string.
String - string in line to replace.
String - replace oldString with this.
Returns:
String string with replacements.

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.

normalizePath

public static final java.lang.String normalizePath(java.lang.String path)
Return a context-relative path, beginning with a "/", that represents the canonical version of the specified path after ".." and "." elements are resolved out. If the specified path attempts to go outside the boundaries of the current context (i.e. too many ".." path elements are present), return null instead.
Parameters:
path - Path to be normalized
Returns:
String normalized path

select

public java.lang.String select(boolean state,
                               java.lang.String trueString,
                               java.lang.String falseString)

allEmpty

public boolean allEmpty(java.util.ArrayList list)
Check to see if all the string objects passed in are empty.
Parameters:
ArrayList - list of string objects.
Returns:
boolean


Copyright © 2001 Apache Software Foundation. All Rights Reserved.