|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.velocity.util.StringUtils
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.
Field Summary | |
private static java.lang.String |
EOL
Line separator for the OS we are operating on. |
private static int |
EOL_LENGTH
Length of the line separator. |
Constructor Summary | |
StringUtils()
|
Method Summary | |
boolean |
allEmpty(java.util.List list)
Check to see if all the string objects passed in are empty. |
static java.lang.String |
capitalizeFirstLetter(java.lang.String data)
Capitalize the first letter but leave the rest as they are. |
static java.lang.String |
chop(java.lang.String s,
int i)
Chop i characters off the end of a string. |
static java.lang.String |
chop(java.lang.String s,
int i,
java.lang.String eol)
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.List list)
Concatenates a list of objects as a String. |
static java.lang.String |
fileContentsToString(java.lang.String file)
Read the contents of a file and place them in a string object. |
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 |
removeAndHump(java.lang.String data)
'Camels Hump' replacement of underscores. |
static java.lang.String |
removeAndHump(java.lang.String data,
java.lang.String replaceThis)
'Camels Hump' replacement. |
static java.lang.String |
removeUnderScores(java.lang.String data)
Deprecated. Use the org.apache.commons.util.StringUtils class instead. Using its firstLetterCaps() method in conjunction with a StringTokenizer will achieve the same result. |
java.lang.String |
select(boolean state,
java.lang.String trueString,
java.lang.String falseString)
If state is true then return the trueString, else return the 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.StringBuffer |
stringSubstitution(java.lang.String argStr,
java.util.Map vars)
Perform a series of substitutions. |
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 |
|
Field Detail |
private static final java.lang.String EOL
private static final int EOL_LENGTH
Constructor Detail |
public StringUtils()
Method Detail |
public java.lang.String concat(java.util.List list)
list
- The list of objects to concatenate.public static java.lang.String getPackageAsPath(java.lang.String pckge)
String
- package name to convert to a directory.public static java.lang.String removeUnderScores(java.lang.String data)
Remove underscores from a string and replaces first letters with capitals. Other letters are changed to lower case.
For example foo_bar
becomes FooBar
but foo_barBar
becomes FooBarbar
.
data
- string to remove underscores from.public static java.lang.String removeAndHump(java.lang.String data)
'Camels Hump' replacement of underscores.
Remove underscores from a string but leave the capitalization of the other letters unchanged.
For example foo_barBar
becomes FooBarBar
.
data
- string to humppublic static java.lang.String removeAndHump(java.lang.String data, java.lang.String replaceThis)
'Camels Hump' replacement.
Remove one string from another string but leave the capitalization of the other letters unchanged.
For example, removing "_" from foo_barBar
becomes FooBarBar
.
data
- string to humpreplaceThis
- string to be replacedpublic static java.lang.String firstLetterCaps(java.lang.String data)
Makes the first letter caps and the rest lowercase.
For example fooBar
becomes Foobar
.
data
- capitalize thispublic static java.lang.String capitalizeFirstLetter(java.lang.String data)
Capitalize the first letter but leave the rest as they are.
For example fooBar
becomes FooBar
.
data
- capitalize thispublic static java.lang.String[] split(java.lang.String line, java.lang.String delim)
line
- the line to splitdelim
- the delimter to split bypublic static java.lang.String chop(java.lang.String s, int i)
string
- String to chop.i
- Number of characters to chop.public static java.lang.String chop(java.lang.String s, int i, java.lang.String eol)
string
- String to chop.i
- Number of characters to chop.eol
- A String representing the EOL (end of line).public static java.lang.StringBuffer stringSubstitution(java.lang.String argStr, java.util.Hashtable vars)
public static java.lang.StringBuffer stringSubstitution(java.lang.String argStr, java.util.Map vars)
String
- target stringHashtable
- name/value pairs used for substitutionpublic static java.lang.String fileContentsToString(java.lang.String file)
String
- path to file.public static java.lang.String collapseNewlines(java.lang.String argStr)
String
- string to collapse newlines in.public static java.lang.String collapseSpaces(java.lang.String argStr)
String
- string to remove multiple spaces from.public static final java.lang.String sub(java.lang.String line, java.lang.String oldString, java.lang.String newString)
String
- original string.String
- string in line to replace.String
- replace oldString with this.public static final java.lang.String stackTrace(java.lang.Throwable e)
e
- A Throwable.public static final java.lang.String normalizePath(java.lang.String path)
null
instead.path
- Path to be normalizedpublic java.lang.String select(boolean state, java.lang.String trueString, java.lang.String falseString)
boolean
- String
- trueStringString
- falseStringpublic boolean allEmpty(java.util.List list)
list
- A list of String
objects.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |