|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.jzeno.util.StringUtils
public class StringUtils
Utility methods for manipulating strings.
Constructor Summary | |
---|---|
StringUtils()
|
Method Summary | |
---|---|
static java.lang.String |
addLeadingChar(long number,
int length,
char character)
Method addLeadingChar. |
static java.lang.String |
addLeadingZero(float number,
int lengthInt,
int nrDec)
Method addLeadingZero. returns a String representation of the number. if nrDec > 0, the number will have exactly nrDec positions otherwice it will have no decimal positions at all. |
static java.lang.String |
addLeadingZero(long number,
int length)
Method addLeadingZero. |
static boolean |
beginsWith(java.lang.String s,
java.lang.String sub)
This method checks if a given string begins with another string The search is case sensitive !! |
static java.lang.String[] |
breakIntoTokens(java.lang.String string,
java.lang.String token)
Breaks a string into tokens and gives back an array |
static java.lang.String |
Capital(java.lang.String s)
|
static java.lang.String |
composeAction(java.lang.String action,
java.util.Map parameters)
This method composes an action based on the original action and a number of extra parameters. |
static boolean |
contains(java.lang.String s,
char c)
This method checks if a given string contains a certain char |
static boolean |
contains(java.lang.String s,
java.lang.String sub)
This method checks if a given string contains another string The search is case sensitive !! |
static boolean |
containsIgnoreCase(java.lang.String s,
java.lang.String sub)
This method checks if a given string contains another string The search is case insensitive !! |
static java.lang.String |
convertByteArrayToString(byte[] ba)
|
static java.lang.String |
convertLF2CRLF(java.lang.String s)
|
static byte[] |
convertToBytesUSASCII(java.lang.String s)
|
static java.lang.String |
escapeAllHTML(java.lang.String s)
Replaces characters that may be confused by a HTML parser with their equivalent character entity references. |
static java.lang.String |
escapeConstructionHint(java.lang.String value)
|
static java.lang.String |
escapeHTML(java.lang.String s)
Replaces characters that may be confused by a HTML parser with their equivalent character entity references. |
static java.lang.String |
filterCharNum(java.lang.String str)
|
static java.lang.String |
format(java.util.Date date)
Deprecated. |
static java.lang.String |
format(java.util.Date date,
java.lang.String format)
Deprecated. |
static java.lang.String |
getAttributeValue(java.lang.String attribute,
java.lang.String in)
Checks the given string for an occurrence of an attribute and returns its value. |
static java.lang.String |
getStackTrace(java.lang.Throwable throwable)
Returns a string representation of the stack trace of the given Throwable. |
static boolean |
isNumeric(java.lang.String s)
Checks that the supplied string is only composed of digits. |
static java.lang.String |
prepad(java.lang.String originalString,
char prepadChar,
int targetLength)
|
static java.lang.String |
removeLineBreaks(java.lang.String txt)
Replace Line separators with a space. |
static java.lang.String |
removeNonAlphaNumericSpace(java.lang.String input)
Removes everything that is not an alphabetic, numeric or space character from the input string. |
static java.lang.String |
replace(java.lang.String what,
java.lang.String with,
java.lang.String in)
Substring replacer. |
static java.lang.String |
replace(java.lang.String in,
java.lang.String what,
java.lang.String[] with)
Method replace. |
static java.util.Collection |
split(java.lang.String string,
java.lang.String separator)
|
static java.lang.String |
trunc(java.lang.String aString,
int numberOfChars)
Method trunc. returns the substring starting at the beginning of the string. at most numberOfChars are returned. |
static java.lang.String |
wrap(java.lang.String txt,
int size)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StringUtils()
Method Detail |
---|
public static boolean isNumeric(java.lang.String s)
Checks that the supplied string is only composed of digits.
public static java.lang.String trunc(java.lang.String aString, int numberOfChars)
Method trunc. returns the substring starting at the beginning of the string. at most numberOfChars are returned.
public static boolean contains(java.lang.String s, char c)
This method checks if a given string contains a certain char
s
- the string to be checkedc
- the character that needs to be searched in the given string
public static boolean contains(java.lang.String s, java.lang.String sub)
This method checks if a given string contains another string The search is case sensitive !!
s
- the string to be checkedsub
- the substring that needs to be searched in the given string
public static boolean containsIgnoreCase(java.lang.String s, java.lang.String sub)
This method checks if a given string contains another string The search is case insensitive !!
s
- the string to be checkedsub
- the substring that needs to be searched in the given string
public static boolean beginsWith(java.lang.String s, java.lang.String sub)
This method checks if a given string begins with another string The search is case sensitive !!
s
- the string to be checkedsub
- the substring that needs to be searched in the given string
public static java.lang.String replace(java.lang.String in, java.lang.String what, java.lang.String[] with)
Method replace. This method replaces all occurences of a certain substring "what" into another substring. The first occurance is replaced with with[0]. The second with with[1],... . If there are not enough "with" strings, the rest of the occurance of what stay unchanged.
public static java.lang.String replace(java.lang.String what, java.lang.String with, java.lang.String in)
what
- substring to be replacedwith
- substring to include in the resultin
- string in which the substrings need to be replaced
public static java.lang.String[] breakIntoTokens(java.lang.String string, java.lang.String token)
string
- The string that needs to be formattedtoken
- Delimiter
public static java.lang.String getStackTrace(java.lang.Throwable throwable)
throwable
- The Throwable for which the stack trace is returned.
public static java.lang.String getAttributeValue(java.lang.String attribute, java.lang.String in)
attribute
- attribute namein
- the string to be searched
public static java.lang.String composeAction(java.lang.String action, java.util.Map parameters)
action
- the original actionparameters
- the extra parameters to be added to the action url a parameter
is included if both the key and the value are set
public static java.lang.String Capital(java.lang.String s)
public static java.lang.String addLeadingChar(long number, int length, char character)
number
- int to be converted to a string.length
- Minimum length of the String.character
- Character that will be uszed as leading character
public static java.lang.String addLeadingZero(long number, int length)
public static java.lang.String addLeadingZero(float number, int lengthInt, int nrDec)
public static java.lang.String format(java.util.Date date, java.lang.String format)
public static java.lang.String format(java.util.Date date)
public static byte[] convertToBytesUSASCII(java.lang.String s)
public static java.lang.String convertLF2CRLF(java.lang.String s)
public static java.lang.String convertByteArrayToString(byte[] ba)
public static java.lang.String removeLineBreaks(java.lang.String txt)
Replace Line separators with a space.
A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a linefeed.
public static java.lang.String removeNonAlphaNumericSpace(java.lang.String input)
Removes everything that is not an alphabetic, numeric or space character from the input string.
public static java.lang.String wrap(java.lang.String txt, int size)
public static java.lang.String escapeHTML(java.lang.String s)
Replaces characters that may be confused by a HTML parser with their equivalent character entity references.
Any data that will appear as text on a web page should be be escaped. This is especially important for data that comes from untrusted sources such as Internet users. A common mistake in CGI programming is to ask a user for data and then put that data on a web page. For example:
Server: What is your name? User: <b>Joe<b> Server: Hello <b>Joe</b>, Welcome
If the name is put on the page without checking that it doesn't contain HTML code or without sanitizing that HTML code, the user could reformat the page, insert scripts, and control the the content on your web server.
This method will replace HTML characters such as > with their HTML entity reference (>) so that the html parser will be sure to interpret them as plain text rather than HTML or script.
This method should be used for both data to be displayed in text in the
html document, and data put in form elements. For example:
<html><body>This in not a <tag>
in HTML</body></html>
and
<form><input type="hidden" name="date" value="This data could
be "malicious""></form>
In the second example, the form data would be properly be resubmitted to
your cgi script in the URLEncoded format:
This data could be %22malicious%22
s
- String to be escaped
java.lang.NullPointerException
- if s is null.public static java.lang.String escapeAllHTML(java.lang.String s)
Any data that will appear as text on a web page should be be escaped. This is especially important for data that comes from untrusted sources such as Internet users. A common mistake in CGI programming is to ask a user for data and then put that data on a web page. For example:
Server: What is your name? User: <b>Joe<b> Server: Hello <b>Joe</b>, WelcomeIf the name is put on the page without checking that it doesn't contain HTML code or without sanitizing that HTML code, the user could reformat the page, insert scripts, and control the the content on your web server.
This method will replace HTML characters such as > with their HTML entity reference (>) so that the html parser will be sure to interpret them as plain text rather than HTML or script.
This method should be used for both data to be displayed in text in the
html document, and data put in form elements. For example:
<html><body>This in not a <tag>
in HTML</body></html>
and
<form><input type="hidden" name="date" value="This data could
be "malicious""></form>
In the second example, the form data would be properly be resubmitted to
your cgi script in the URLEncoded format:
This data could be %22malicious%22
s
- String to be escaped
java.lang.NullPointerException
- if s is null.public static java.lang.String filterCharNum(java.lang.String str)
public static java.lang.String prepad(java.lang.String originalString, char prepadChar, int targetLength)
public static java.util.Collection split(java.lang.String string, java.lang.String separator)
public static java.lang.String escapeConstructionHint(java.lang.String value)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |