public class Utils extends Object
| Modifier and Type | Field and Description |
|---|---|
static Pattern |
REGEX_FIRSTPARAGRAPH
First paragraph pattern.
|
static String |
SUFFIX_DEFAULT
Default suffix.
|
static Pattern |
WORDBOUND_PATTERN
Word bound matchind regexp.
|
| Constructor and Description |
|---|
Utils() |
| Modifier and Type | Method and Description |
|---|---|
static String |
firstParagraph(String text)
Fetches first paragraph of text.
|
static String |
format(String format,
String text)
Formats the text.
|
static void |
setFormatter(Formatter formatter)
Registers new text formatting handler.
|
static String |
truncate(String text,
int length)
Truncates text.
|
static String |
truncate(String text,
int length,
boolean wordBounds)
Truncates text.
|
static String |
truncate(String text,
int length,
String suffix)
Truncates text.
|
static String |
truncate(String text,
int length,
String suffix,
boolean wordBounds)
Truncates text.
|
static String |
urlEncode(String value)
Wrapper function that encodes URLs using UTF-8 encoding.
|
public static final String SUFFIX_DEFAULT
public static final Pattern WORDBOUND_PATTERN
public static final Pattern REGEX_FIRSTPARAGRAPH
public static String firstParagraph(String text)
text - HTML snippet.public static String truncate(String text, int length, String suffix, boolean wordBounds)
text - Text to be truncated.length - Maximum text length.suffix - Suffix to be used at the end of truncated text.wordBounds - Whether to look for word end or not.public static String truncate(String text, int length, String suffix)
text - Text to be truncated.length - Maximum text length.suffix - Suffix to be used at the end of truncated text.public static String truncate(String text, int length, boolean wordBounds)
text - Text to be truncated.length - Maximum text length.wordBounds - Whether to look for word end or not.public static String truncate(String text, int length)
text - Text to be truncated.length - Maximum text length.public static void setFormatter(Formatter formatter)
formatter - Formatter.public static String format(String format, String text) throws TextProcessingException
format - Format name.text - Source text.TextProcessingException - When text processing fails.public static String urlEncode(String value) throws UnsupportedEncodingException
value - URL part.UnsupportedEncodingException - Should never happen.Copyright © 2015–2017 RafaĆ Wrzeszcz - Wrzasq.pl. All rights reserved.