|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectnet.sourceforge.java.util.text.StringUtils
Contains String related utility methods.
| Field Summary | |
static char |
DEFAULT_DELIMITER
The default delimiter char to use |
static String |
EMPTY_STRING
Constant for the empty String |
private static Map |
ENTITY_MAPPING
Maps entity names to their corresponding unicode Characters.
|
private static String |
HTML_PATTERN
Regular expression pattern to match any HTML tags. |
static String |
LINE_SEPARATOR
Constant for the line separator |
private static int |
LONGEST_ENTITY
The longest an entity can be 10, including the lead & and trail ; |
private static int |
SHORTEST_ENTITY
The shortest an entity can be 4, including the lead & and trailing ; |
| Constructor Summary | |
StringUtils()
|
|
| Method Summary | |
static String |
abbreviate(String str,
int maximumChars)
Abbreviates the specified String if its length exceeds the
value specified by maximumChars. |
static String |
arrayToCSV(int[] input,
char delimiter)
Converts the specified input to a single
String in which the input elements
are separated by the given delimiter
|
static String |
arrayToCSV(Point[] input,
char delimiter)
Converts the specified input to a single
String in which the input elements
are separated by the given delimiter
|
static String |
arrayToCSV(String[] input,
char delimiter)
Converts the specified input to a single
String in which the input elements
are separated by the given delimiter
|
static String |
convertEntities(String text)
Converts HTML to text converting entities such as " back to " and < back to < Ordinary text passes unchanged. |
static String |
convertHTML(String text)
Converts the specified HTML input String to pure raw text.
|
static String[] |
csvToArray(String input,
char delimiter)
Uses the specified delimiter to convert the
input to an array of single String
elements.
|
static int[] |
csvToIntArray(String input,
char delimiter)
Uses the specified delimiter to convert the
input to an array of single int/code>
values.
|
static Point[] |
csvToPointArray(String input,
char delimiter)
Uses the specified delimiter to convert the
input to an array of single Point elements.
|
static char |
entityToChar(String entity)
Converts the specified entity to a single
char.
|
static boolean |
isEmpty(String str)
Tests if the given String is empty. |
static String |
nullValueToEmptyString(String str)
Converts a possible null String object to an empty
String object. |
private static char |
potentialEntityToChar(String entity)
Checks a number of gauntlet conditions to ensure this is a valid entity. |
static String |
stripHTML(String text)
Strips off all HTML tags from the specified text.
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private static final int LONGEST_ENTITY
The longest an entity can be 10, including the lead & and trail ;
SHORTEST_ENTITY,
Constant Field Valuesprivate static final int SHORTEST_ENTITY
The shortest an entity can be 4, including the lead & and trailing ;
LONGEST_ENTITY,
Constant Field Valuesprivate static Map ENTITY_MAPPING
Maps entity names to their corresponding unicode Characters.
private static final String HTML_PATTERN
Regular expression pattern to match any HTML tags.
stripHTML(String),
convertHTML(String),
Constant Field Valuespublic static final String EMPTY_STRING
Constant for the empty String
public static final String LINE_SEPARATOR
Constant for the line separator
public static final char DEFAULT_DELIMITER
The default delimiter char to use
| Constructor Detail |
public StringUtils()
| Method Detail |
public static char entityToChar(String entity)
Converts the specified entity to a single
char.
entity - the entity to convert; it must have lead & and trail ;
stripped; may be a x#123 or #123 style entity; works faster if the entity
is specified in lower case
public static String convertEntities(String text)
Converts HTML to text converting entities such as " back to " and < back to < Ordinary text passes unchanged.
text - raw text to be processed; must not be null
null input also
returns nullpublic static String stripHTML(String text)
Strips off all HTML tags from the specified text.
text - the raw text to strip HTML tags from
null
is specified null is also returnedpublic static String convertHTML(String text)
Converts the specified HTML input String to pure raw text.
All HTML entities are converted and all HTML tags stripped off.
text - the HTML input String to convert; a
null value is converted to an empty String
convertEntities(String),
stripHTML(String)public static String nullValueToEmptyString(String str)
Converts a possible null String object to an empty
String object. If the specified value is non null the
value is just being trimmed using String.trim()
str - the String object to convert
String if the specified value is set to
null; otherwise the specified value is being trimmed
using String.trim()public static boolean isEmpty(String str)
Tests if the given String is empty. A String
object is considered empty if it is either null or its
trimmed length is zero.
str - the String to test
true if the given String is empty;
false otherwise
public static String abbreviate(String str,
int maximumChars)
Abbreviates the specified String if its length exceeds the
value specified by maximumChars. The resulting
String will then be a substring of str
beginning at index 0 and ending at index maximumChars-1
plus a concatenated "..." to show that an abbreviation has been done. If
the length of str is below the value specified by
maximumChars the input String remains
untouched.
str - the String to abbreviatemaximumChars - the maximum characters to allow in the specified
input String
String
public static String arrayToCSV(String[] input,
char delimiter)
Converts the specified input to a single
String in which the input elements
are separated by the given delimiter
input - a String array holding the elementsdelimiter - the delimiter char to use
String that separates the
input elements by the given delimiterarrayToCSV(int[], char),
arrayToCSV(Point[], char)
public static String arrayToCSV(int[] input,
char delimiter)
Converts the specified input to a single
String in which the input elements
are separated by the given delimiter
input - an int array holding the elementsdelimiter - the delimiter char to use
String that separates the
input elements by the given delimiterarrayToCSV(String[], char),
arrayToCSV(Point[], char)
public static String arrayToCSV(Point[] input,
char delimiter)
Converts the specified input to a single
String in which the input elements
are separated by the given delimiter
input - a Point array holding the elementsdelimiter - the delimiter char to use
String that separates the
input elements by the given delimiterarrayToCSV(String[], char),
arrayToCSV(int[], char)
public static String[] csvToArray(String input,
char delimiter)
Uses the specified delimiter to convert the
input to an array of single String
elements.
input - a String in which the elements are
separated by the given delimiterdelimiter - the delimiter char to use
String holding all elements from
the given inputcsvToIntArray(String, char),
csvToPointArray(String, char)
public static int[] csvToIntArray(String input,
char delimiter)
Uses the specified delimiter to convert the
input to an array of single int/code>
values.
input - a String in which the elements are separated
by the given delimiterdelimiter - the delimiter char to use
int values from the given
inputcsvToArray(String, char),
csvToPointArray(String, char)
public static Point[] csvToPointArray(String input,
char delimiter)
Uses the specified delimiter to convert the
input to an array of single Point elements.
input - a String in which the elements are separated
by the given delimiterdelimiter - the delimiter char to use
Point objects holding all elements
from the given inputcsvToArray(String, char),
csvToIntArray(String, char)private static char potentialEntityToChar(String entity)
Checks a number of gauntlet conditions to ensure this is a valid entity. Converts the entity to the corresponding char.
entity - String that may hold an entity; lead & must
be stripped, but may contain text past the ;
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||