public interface ISafeTextUtils
| Modifier and Type | Method and Description | 
|---|---|
String | 
br(String s)
Convert line breaks to html  
<br> tag. | 
String | 
closeTags(String str)
Search through a String for any tags that have been opened and append closing
 tags for those that have not been closed. 
 | 
String | 
colorToHex(Color c)
Convert Color to html hex string. 
 | 
String | 
extractNumber(String in)
Extract a number from a String. 
 | 
Color | 
hexToColor(String color)
Convert html hex string to Color. 
 | 
String | 
html(String s)
Deprecated. 
 
use htmlEncode(String) or htmlEncode(String, boolean) instead. 
 | 
String | 
htmlEncode(String s)
Escape html entity characters BUT NOT high characters. 
 | 
String | 
htmlEncode(String s,
          boolean encodeSpecialChars)
Escape html entity characters and high characters (eg "curvy" Word quotes). 
 | 
String | 
hyperlink(String text)
Convert all URLs and E-mail addresses in a string into hyperlinks. 
 | 
String | 
hyperlink(String text,
         String target)
Convert all URLs and E-mail addresses in a string into hyperlinks. 
 | 
String | 
indent(String string,
      int indentSize,
      boolean initialLine)
Indent a String with line-breaks. 
 | 
String | 
innerTrim(String s)
Returns a string that has whitespace removed from both ends of the String, as
 well as duplicate whitespace removed from within the String. 
 | 
String | 
join(String glue,
    Collection<String> pieces)
Join a Collection of Strings together. 
 | 
String | 
join(String glue,
    Iterator<String> pieces)
Join an Iteration of Strings together. 
 | 
String | 
join(String glue,
    String[] pieces)
Join an array of Strings together. 
 | 
String | 
leadingSpaces(String s)
Finds all leading spaces on each line and replaces it with an HTML space
 ( ) 
 | 
String | 
left(String s,
    int n)
Returns the leftmost n chars of the string. 
 | 
String | 
linkEmail(String string)
Wrap all email addresses in specified string with href tags. 
 | 
String | 
linkURL(String str)
Wrap all urls ('http://', 'www.', and 'ftp://') in specified string with href
 tags. 
 | 
String | 
linkURL(String str,
       String target)
Wrap all urls ('abc://' and 'www.abc') in specified string with href tags. 
 | 
String | 
list(String str)
Create
 <li> elements in a piece of plain text; Will convert lines starting with - or
 *. 
 | 
String | 
noNull(String string)
Return  
string, or "" if string is
 null. | 
String | 
noNull(String string,
      String defaultString)
Return  
string, or defaultString if
 string is null or "". | 
boolean | 
parseBoolean(String in)
Convert a String to an boolean. 
 | 
Date | 
parseDate(String year,
         String month,
         String day)
Given 3 Strings representing the the year, month and day, return a Date
 object. 
 | 
double | 
parseDouble(String in)
Convert a String to a double. 
 | 
float | 
parseFloat(String in)
Convert a String to a float. 
 | 
int | 
parseInt(String in)
Convert a String to an int. 
 | 
long | 
parseLong(String in)
Convert a String to a long. 
 | 
String | 
plainTextToHtml(String str)
Converts plain text to html code. 
 | 
String | 
plainTextToHtml(String str,
               boolean encodeSpecialChars)  | 
String | 
plainTextToHtml(String str,
               String target)  | 
String | 
plainTextToHtml(String str,
               String target,
               boolean encodeSpecialChars)
Converts plain text to html code. 
 | 
String | 
removeAndInsert(String str,
               int removeAndInsertStart,
               int removeEnd,
               String insertStr)
Removes part of the original string starting at removeAndInsertStart and
 ending at removeEnd. 
 | 
String | 
slashes(String s)
Escape chars that need slashes in front of them. 
 | 
boolean | 
stringSet(String string)
Check whether  
string has been set to something other than
 "" or null. | 
String | 
trimToEndingChar(String str,
                int len)
Trim a String to the specified length. 
 | 
boolean | 
verifyEmail(String email)
Verify that the given string is a valid email address. 
 | 
boolean | 
verifyUrl(String url)
Verify That the given String is in valid URL format. 
 | 
String | 
wrapParagraph(String s)
Wrap paragraphs in html  
<p> tags. | 
String br(String s)
<br> tag.s - the String to convertString closeTags(String str)
str - A string possibly containing unclosed HTML tagsString colorToHex(Color c)
c - the Color to convertString extractNumber(String in)
" 12345" -> "12345" "hello123bye" -> "123" "a2b4c6 8 " -> "2468" " -22" -> "-22" "5.512" -> "5.512" "1.2.3.4" -> "1.234" ".2" -> "0.2" "-555.7" -> "-555.7" "-..6" -> "-0.6" "abc- dx.97 9" -> "-0.979" "�1,000,000.00 per year" -> "1000000.00" "" -> "0" "asdsf" -> "0" "123." -> "123" null -> "0"
in - Original String containing number to be extracted.parseInt(String), 
parseLong(String)Color hexToColor(String color)
Color.black is returned. Only the first six
 hexadecimal characters are considered; any extraneous values are discarded.
 Also, a leading "#", if any, is allowed (and ignored).color - the String (in RGB hexadecimal format) to convertString html(String s)
s - unsafe htmlString htmlEncode(String s)
s - unsafe textString htmlEncode(String s, boolean encodeSpecialChars)
s - the String to escape.encodeSpecialChars - if true high characters will be encode other wise
                           not.String hyperlink(String text)
text - The block of text to hyperlink.hyperlink(String, String)String hyperlink(String text, String target)
text - The block of text to hyperlink.target - The target attribute to use for href (optional).linkEmail(String), 
linkURL(String)String indent(String string, int indentSize, boolean initialLine)
string - String to indent.indentSize - Number of spaces to indent by. 0 will indent using a tab.initialLine - Whether to indent initial line.String innerTrim(String s)
s - string to trimString join(String glue, Iterator<String> pieces)
 // get Iterator of Strings ("abc","def","123");
 Iterator i = getIterator();
 out.print(TextUtils.join(", ", i));
 // prints: "abc, def, 123"
 glue - Token to place between Strings.pieces - Iteration of Strings to join.String join(String glue, String[] pieces)
glue - Token to place between Strings.pieces - Array of Strings to join.join(String, java.util.Iterator)String join(String glue, Collection<String> pieces)
glue - Token to place between Strings.pieces - Collection of Strings to join.join(String, java.util.Iterator)String leadingSpaces(String s)
s - string containing text to replaced with  String left(String s, int n)
s - - the string to operate on.n - - the number of chars to return.String linkEmail(String string)
string - The block of text to check.String linkURL(String str)
str - The block of text to check.String linkURL(String str, String target)
str - The block of text to check.target - The target to use for the href (optional).String list(String str)
str - A string, possibly containing a plaintext "list"String noNull(String string, String defaultString)
string, or defaultString if
 string is null or "". Never returns
 null.
 Examples:
// prints "hello" String s=null; System.out.println(TextUtils.noNull(s,"hello"); // prints "hello" s=""; System.out.println(TextUtils.noNull(s,"hello"); // prints "world" s="world"; System.out.println(TextUtils.noNull(s, "hello");
string - the String to check.defaultString - The default string to return if string is
                      null or ""string if string is non-empty, and
         defaultString otherwisestringSet(java.lang.String)String noNull(String string)
string, or "" if string is
 null. Never returns null.
 Examples:
// prints 0 String s = null; System.out.println(TextUtils.noNull(s).length()); // prints 1 s = "a"; System.out.println(TextUtils.noNull(s).length());
string - the String to checkboolean parseBoolean(String in)
false is
 returned.in - String to be parsed.Date parseDate(String year, String month, String day)
If the day cannot be determined, 1st will be used. If the month cannot be determined, Jan will be used.
year - Year : 4 digitmonth - Month : 1 or 2 digit (1=jan, 2=feb, ...) or name (jan, JAN,
              January, etc). If null, default is Jan.day - Day of month : 1 or 2 digit, prefix will be stripped (1, 30, 05,
              3rd). If null, default is 1st.double parseDouble(String in)
in - String containing number to be parsed.extractNumber(String)float parseFloat(String in)
in - String containing number to be parsed.extractNumber(String)int parseInt(String in)
in - String containing number to be parsed.extractNumber(String)long parseLong(String in)
in - String containing number to be parsed.extractNumber(String)String plainTextToHtml(String str)
str - - String containing the plain text.String plainTextToHtml(String str, String target, boolean encodeSpecialChars)
str - - String containing the plain text.target - - Target for href tags (optional).encodeSpecialChars - - if true high characters will be encode other wise
                           not.String removeAndInsert(String str, int removeAndInsertStart, int removeEnd, String insertStr)
str - - the original string.removeAndInsertStart - - the index within the original string at which
                             removal is to start.removeEnd - - the index within the original string at which
                             removal is to end (exclusive - ie. does not
                             remove the character at that index).insertStr - - the string to be inserted.String slashes(String s)
s - the String to add escape characters toboolean stringSet(String string)
string has been set to something other than
 "" or null.string - the String to checkString trimToEndingChar(String str, int len)
str - - String to trim.len - - length to which string is to be trimmed.boolean verifyEmail(String email)
email - The email address to verify.boolean verifyUrl(String url)
url - The url string to verify.Copyright © 2008–2022 The Plugin People. All rights reserved.