|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.enough.polish.util.TextUtil
public final class TextUtil
Provides some useful String methods.
Copyright Enough Software 2004 - 2012
| Field Summary | |
|---|---|
static String |
MAXLINES_APPENDIX
the default appendix to attach to a truncated text |
static int |
MAXLINES_APPENDIX_POSITION_AFTER
Position of the appendix is at the end of the text. |
static int |
MAXLINES_APPENDIX_POSITION_BEFORE
Position of the appendix is at the beginning of the text. |
static int |
MAXLINES_UNLIMITED
standard maximum lines number for text wrapping |
| Constructor Summary | |
|---|---|
TextUtil()
|
|
| Method Summary | |
|---|---|
static String |
encodeAsQuotedPrintable(String clearText,
String enc)
This method encodes a string to a quoted-printable string according to RFC 2045. |
static String |
encodeForXmlParser(String text)
Encodes a string for parsing using an XML parser. |
static String |
encodeUrl(String url)
Encodes a URL string. |
static boolean |
equalsIgnoreCase(String str1,
String str2)
Compares two strings in a case-insensitive way. |
static int |
lastIndexOf(String text,
String match)
Retrieves the last index of the given match in the specified text. |
static String |
replace(String input,
String search,
String replacement)
Replaces the all matches within a String. |
static String |
replaceFirst(String input,
String search,
String replacement)
Replaces the first match in a String. |
static String |
replaceLast(String input,
String search,
String replacement)
Replaces the last match in a String. |
static char |
resolveNamedHtmlEntity(String name)
Resolves the specified HTML entity such as "lt", "quot", "auml" and similar. |
static String |
reverseForRtlLanguage(String input)
Reverses the given text while keeping English texts and numbers in the normal position. |
static String[] |
split(String value,
char delimiter)
Splits the given String around the matches defined by the given delimiter into an array. |
static String[] |
split(String value,
char delimiter,
int numberOfChunks)
Splits the given String around the matches defined by the given delimiter into an array. |
static String[] |
split(String value,
Font font,
int firstLineWidth,
int lineWidth)
Deprecated. please use wrap instead |
static void |
split(String value,
Font font,
int completeWidth,
int firstLineWidth,
int lineWidth,
WrappedText result)
Deprecated. please use wrap instead |
static String[] |
splitAndTrim(String value,
char delimiter)
Splits the given String around the matches defined by the given delimiter into an array. |
static String |
unescapeHtmlEntities(String input)
Decodes text that contains HTML entities such as " or >. |
static String[] |
wrap(String value,
Font font,
int firstLineWidth,
int lineWidth)
Wraps the given string so it fits on the specified lines. |
static String[] |
wrap(String value,
Font font,
int firstLineWidth,
int lineWidth,
int maxLines,
String maxLinesAppendix)
Wraps the given string so it fits on the specified lines. |
static String[] |
wrap(String value,
Font font,
int firstLineWidth,
int lineWidth,
int maxLines,
String maxLinesAppendix,
int maxLinesAppendixPosition)
Wraps the given string so it fits on the specified lines. |
static void |
wrap(String value,
Font font,
int firstLineWidth,
int lineWidth,
int maxLines,
String maxLinesAppendix,
int maxLinesAppendixPosition,
WrappedText result)
Wraps the given string so it fits on the specified lines. |
static void |
wrap(String value,
Font font,
int completeWidth,
int firstLineWidth,
int lineWidth,
WrappedText list,
int maxLines,
int maxLinesAppendixPosition)
Wraps the given string so that the substrings fit into the the given line-widths. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int MAXLINES_UNLIMITED
wrap(String, Font, int, int, int, String),
Constant Field Valuespublic static final int MAXLINES_APPENDIX_POSITION_AFTER
wrap(String, Font, int, int, int, String),
Constant Field Valuespublic static final int MAXLINES_APPENDIX_POSITION_BEFORE
wrap(String, Font, int, int, int, String),
Constant Field Valuespublic static final String MAXLINES_APPENDIX
wrap(String, Font, int, int, int, String),
Constant Field Values| Constructor Detail |
|---|
public TextUtil()
| Method Detail |
|---|
public static String[] split(String value,
char delimiter)
TextUtil.split("one;two;three", ';') results into the array
{"one", "two", "three"}.
value - the String which should be split into an arraydelimiter - the delimiter which marks the boundaries of the array
public static String[] splitAndTrim(String value,
char delimiter)
TextUtil.splitAndTrim(" one; two; three", ';') results into the array
{"one", "two", "three"}.
value - the String which should be split into an arraydelimiter - the delimiter which marks the boundaries of the array
public static String[] split(String value,
char delimiter,
int numberOfChunks)
TextUtil.split("one;two;three", ';', 3) results into the array
{"one", "two", "three"}.TextUtil.split("one;two;three", ';', 4) results into the array
{"one", "two", "three", null}.TextUtil.split("one;two;three", ';', 2) results into the array
{"one", "two"}.
value - the String which should be split into an arraydelimiter - the delimiter which marks the boundaries of the arraynumberOfChunks - the number of expected matches
public static String[] split(String value,
Font font,
int firstLineWidth,
int lineWidth)
value - the string which should be splitfont - the font which is used to display the fontfirstLineWidth - the allowed width for the first linelineWidth - the allowed width for all other lines, lineWidth >= firstLineWidth
wrap(String, Font, int, int)
public static String[] wrap(String value,
Font font,
int firstLineWidth,
int lineWidth)
value - the string which should be splitfont - the font which is used to display the fontfirstLineWidth - the allowed width for the first linelineWidth - the allowed width for all other lines, lineWidth >= firstLineWidth
public static String[] wrap(String value,
Font font,
int firstLineWidth,
int lineWidth,
int maxLines,
String maxLinesAppendix)
value - the string which should be wrappedfont - the font which is used to display the fontfirstLineWidth - the allowed width for the first linelineWidth - the allowed width for all other lines, lineWidth >= firstLineWidthmaxLines - the maximum number of linesmaxLinesAppendix - the appendix that should be added to the last line when the line number is greater than maxLines
public static String[] wrap(String value,
Font font,
int firstLineWidth,
int lineWidth,
int maxLines,
String maxLinesAppendix,
int maxLinesAppendixPosition)
value - the string which should be wrappedfont - the font which is used to display the fontfirstLineWidth - the allowed width for the first linelineWidth - the allowed width for all other lines, lineWidth >= firstLineWidthmaxLines - the maximum number of linesmaxLinesAppendix - the appendix that should be added to the last line when the line number is greater than maxLinesmaxLinesAppendixPosition - either MAXLINES_APPENDIX_POSITION_AFTER or MAXLINES_APPENDIX_POSITION_BEFORE
public static void wrap(String value,
Font font,
int firstLineWidth,
int lineWidth,
int maxLines,
String maxLinesAppendix,
int maxLinesAppendixPosition,
WrappedText result)
value - the string which should be wrappedfont - the font which is used to display the fontfirstLineWidth - the allowed width for the first linelineWidth - the allowed width for all other lines, lineWidth >= firstLineWidthmaxLines - the maximum number of linesmaxLinesAppendix - the appendix that should be added to the last line when the line number is greater than maxLinesmaxLinesAppendixPosition - either MAXLINES_APPENDIX_POSITION_AFTER or MAXLINES_APPENDIX_POSITION_BEFOREresult - the WrappedText that should be reused (should be cleared by caller in most cases)
public static void split(String value,
Font font,
int completeWidth,
int firstLineWidth,
int lineWidth,
WrappedText result)
value - the string which should be wrappedfont - the font which is used to display the fontcompleteWidth - the complete width of the given string for the specified font.firstLineWidth - the allowed width for the first linelineWidth - the allowed width for all other lines, lineWidth >= firstLineWidthresult - the WrappedText to which the substrings will be added.wrap(String, Font, int, int, int, WrappedText, int, int)
public static void wrap(String value,
Font font,
int completeWidth,
int firstLineWidth,
int lineWidth,
WrappedText list,
int maxLines,
int maxLinesAppendixPosition)
value - the string which should be wrappedfont - the font which is used to display the fontcompleteWidth - the complete width of the given string for the specified font.firstLineWidth - the allowed width for the first linelineWidth - the allowed width for all other lines, lineWidth >= firstLineWidthmaxLines - the maximum number of linesmaxLinesAppendixPosition - either MAXLINES_APPENDIX_POSITION_AFTER or MAXLINES_APPENDIX_POSITION_BEFORElist - the list to which the substrings will be added.public static String encodeUrl(String url)
url - URL to encode
public static String encodeForXmlParser(String text)
text - the text
public static String replace(String input,
String search,
String replacement)
input - the input stringsearch - the string that should be replacedreplacement - the replacement
NullPointerException - when one of the specified strings is null
public static String replaceFirst(String input,
String search,
String replacement)
input - the input stringsearch - the string that should be replacedreplacement - the replacement
NullPointerException - when one of the specified strings is null
public static String replaceLast(String input,
String search,
String replacement)
input - the input stringsearch - the string that should be replacedreplacement - the replacement
NullPointerException - when one of the specified strings is null
public static int lastIndexOf(String text,
String match)
text - the text in which the match is givenmatch - the match within the text
NullPointerException - when text or match is null
public static boolean equalsIgnoreCase(String str1,
String str2)
true,
false otherwise.
str1 - the string to comparestr2 - the string to compare to
true if both strings are equals except case,
false
NullPointerException - if str1 is nullString.equals(Object),
String.equalsIgnoreCase(String)public static String reverseForRtlLanguage(String input)
input - the text
public static String encodeAsQuotedPrintable(String clearText,
String enc)
throws UnsupportedEncodingException
clearText - the string to encodeenc - The encoding which should be used to interpret the cleartext.
UnsupportedEncodingException - if the given encoding is not supportedpublic static char resolveNamedHtmlEntity(String name)
name - the name of the entity
public static String unescapeHtmlEntities(String input)
input - the text input that might contain HTML entities
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||