org.apache.taglibs.string.util
Class StringW
java.lang.Object
|
+--org.apache.taglibs.string.util.StringW
- public final class StringW
- extends java.lang.Object
A set of String library static methods. While extending String or
StringBuffer would have been the nicest solution, that is not
possible, so a simple set of static methods seems the most workable.
Method ideas have so far been taken from the PHP4, Ruby and .NET languages.
- Version:
- 0.4 20010812
- Author:
- bayard@generationjava.com
|
Method Summary |
static java.lang.String |
quoteRegularExpression(java.lang.String str)
Quote a string so that it may be used in a regular expression
without any parts of the string being considered as a
part of the regular expression's control characters. |
static java.lang.String |
truncateNicely(java.lang.String str,
int lower,
int upper,
java.lang.String appendToEnd)
Truncates a string nicely. |
static java.lang.String |
wordWrap(java.lang.String str)
Create a word-wrapped version of a String. |
static java.lang.String |
wordWrap(java.lang.String str,
int width)
Create a word-wrapped version of a String. |
static java.lang.String |
wordWrap(java.lang.String str,
int width,
java.lang.String delim,
java.lang.String split)
Word-wrap a string. |
static java.lang.String |
wordWrap(java.lang.String str,
int width,
java.lang.String delim,
java.lang.String split,
boolean delimInside)
Word-wrap a string. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
StringW
public StringW()
quoteRegularExpression
public static java.lang.String quoteRegularExpression(java.lang.String str)
- Quote a string so that it may be used in a regular expression
without any parts of the string being considered as a
part of the regular expression's control characters.
wordWrap
public static java.lang.String wordWrap(java.lang.String str)
- Create a word-wrapped version of a String. Wrap at 80 characters and
use newlines as the delimiter. If a word is over 80 characters long
use a - sign to split it.
wordWrap
public static java.lang.String wordWrap(java.lang.String str,
int width)
- Create a word-wrapped version of a String. Wrap at a specified width and
use newlines as the delimiter. If a word is over the width in lenght
use a - sign to split it.
wordWrap
public static java.lang.String wordWrap(java.lang.String str,
int width,
java.lang.String delim,
java.lang.String split)
- Word-wrap a string.
- Parameters:
str - String to word-wrapwidth - int to wrap atdelim - String to use to separate linessplit - String to use to split a word greater than width long- Returns:
- String that has been word wrapped (with the delim inside width boundaries)
wordWrap
public static java.lang.String wordWrap(java.lang.String str,
int width,
java.lang.String delim,
java.lang.String split,
boolean delimInside)
- Word-wrap a string.
- Parameters:
str - String to word-wrapwidth - int to wrap atdelim - String to use to separate linessplit - String to use to split a word greater than width longdelimInside - wheter or not delim should be included in chunk before length reaches width.- Returns:
- String that has been word wrapped
truncateNicely
public static java.lang.String truncateNicely(java.lang.String str,
int lower,
int upper,
java.lang.String appendToEnd)
- Truncates a string nicely. It will search for the first space
after the lower limit and truncate the string there. It will
also append any string passed as a parameter to the end of the
string. The hard limit can be specified to forcibily truncate a
string (in the case of an extremely long word or such). All
HTML/XML markup will be stripped from the string prior to
processing for truncation.
- Parameters:
str - String the string to be truncated.lower - int value of the lower limit.upper - int value of the upper limit, -1 if no limit is
desired. If the uppper limit is lower than the
lower limit, it will be adjusted to be same as
the lower limit.appendToEnd - String to be appended to the end of the
truncated string.
This is appended ONLY if the string was indeed
truncated. The append is does not count towards
any lower/upper limits.
Copyright © 2000-2004 The Apache Software Foundation. All Rights Reserved.