public final class Utilities
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static int |
C_ESCAPES
The escape flags for standard C escapes.
|
static java.util.regex.Pattern |
COMMENT_NEWLINE
The regular expression pattern for newlines surrounded by spaces
and optionally followed by stars '
*'. |
static int |
ESCAPE_BELL_VT
Flag for escaping the bell '
\a' and vertical tab
'\v' characters, which may be escaped in standard C
but not in Java. |
static int |
ESCAPE_DOUBLE
Flag for using doubled escape sequences.
|
static int |
ESCAPE_HTML
Flag for escaping less-than '
<' and greater-than
'>' signs as HTML entities. |
static int |
ESCAPE_REGEX
Flag for escaping the '
[', '-', and
']' characters used in regular expressions. |
static int |
ESCAPE_UNICODE
Flag for escaping all characters that neither are printable ASCII
characters nor have named escapes using Unicode escapes.
|
static int |
FULL_ESCAPES
The escape flags for Java and regex escapes.
|
static int |
FULL_HTML_ESCAPES
The escape flags for Java, regex, and HTML escapes.
|
static int |
JAVA_ESCAPES
The escape flags for Java escapes.
|
static int |
JAVA_HTML_ESCAPES
The escape flags for Java and HTML escapes.
|
static java.util.regex.Pattern |
SPACE_NEWLINE_SPACE
The regular expression pattern for newlines surrounded by spaces.
|
static java.util.regex.Pattern |
WHITE_SPACE
The regular expression pattern for white space.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
escape(char c,
java.lang.Appendable out,
int flags)
Escape the specified character into the specified appendable.
|
static java.lang.String |
escape(char c,
int flags)
Escape the specified character.
|
static void |
escape(java.lang.String s,
java.lang.Appendable out,
int flags)
Escape the specified string into the specified appendable.
|
static java.lang.String |
escape(java.lang.String s,
int flags)
Escape the specified string.
|
static java.lang.String |
format(java.util.List<?> l)
Convert the specified list to a human-readable representation.
|
static java.io.File |
locate(java.util.List<java.io.File> roots,
java.lang.String path)
Locate the specified file.
|
static void |
pump(java.io.Reader in,
java.io.Writer out)
Pump all data from the specified reader to the specified writer.
|
static java.lang.String |
split(java.lang.String id,
char separator)
Split the specified identifier.
|
static java.lang.String |
toArticle(java.lang.String noun)
Get the appropriate indefinite article for the specified noun.
|
static java.lang.String |
unescape(java.lang.String s)
Unescape the specified string.
|
static boolean |
useBellVTEscapes(int flags)
Determine whether the escape bell and vertical tabs flag is set.
|
static boolean |
useDoubleEscapes(int flags)
Determine whether the escape double flag is set.
|
static boolean |
useHTMLEscapes(int flags)
Determine whether the escape HTML flag is set.
|
static boolean |
useRegexEscapes(int flags)
Determine whether the escape regex flag is set.
|
static boolean |
useUnicodeEscapes(int flags)
Determine whether the escape Unicode flag is set.
|
static java.lang.String |
withoutSpace(java.lang.String s)
Remove all whitespace from the specified string.
|
public static final java.util.regex.Pattern WHITE_SPACE
public static final java.util.regex.Pattern SPACE_NEWLINE_SPACE
public static final java.util.regex.Pattern COMMENT_NEWLINE
*'.public static final int ESCAPE_BELL_VT
\a' and vertical tab
'\v' characters, which may be escaped in standard C
but not in Java.public static final int ESCAPE_DOUBLE
public static final int ESCAPE_REGEX
[', '-', and
']' characters used in regular expressions.public static final int ESCAPE_UNICODE
public static final int ESCAPE_HTML
<' and greater-than
'>' signs as HTML entities.public static final int C_ESCAPES
public static final int JAVA_ESCAPES
public static final int JAVA_HTML_ESCAPES
public static final int FULL_ESCAPES
public static final int FULL_HTML_ESCAPES
public static java.io.File locate(java.util.List<java.io.File> roots,
java.lang.String path)
throws java.io.FileNotFoundException
java.io.File objects.roots - The list of file system roots to search.path - The (relative) file path.java.io.FileNotFoundException - Signals that the specified file could not be found.public static void pump(java.io.Reader in,
java.io.Writer out)
throws java.io.IOException
in - The reader.out - The writer.java.io.IOException - Signals an exceptinal condition during I/O.public static java.lang.String withoutSpace(java.lang.String s)
s - The string.public static boolean useBellVTEscapes(int flags)
flags - The escape flags.true if the escape bell and vertical tabs
flag is set.ESCAPE_BELL_VTpublic static boolean useDoubleEscapes(int flags)
flags - The escape flags.true if the escape double flag is set.ESCAPE_DOUBLEpublic static boolean useRegexEscapes(int flags)
flags - The escape flags.true if the escape regex flag is set.ESCAPE_REGEXpublic static boolean useUnicodeEscapes(int flags)
flags - The escape flags.true if the escape Unicode flag is set.ESCAPE_UNICODEpublic static boolean useHTMLEscapes(int flags)
flags - The escape flags.true if the escape HTML flag is set.ESCAPE_HTMLpublic static void escape(char c,
java.lang.Appendable out,
int flags)
throws java.io.IOException
c - The character.out - The appendable.flags - The escape flags.java.io.IOException - Signals an I/O error.public static void escape(java.lang.String s,
java.lang.Appendable out,
int flags)
throws java.io.IOException
s - The string.out - The appendable.flags - The escape flags.java.io.IOException - Signals an I/O error.public static java.lang.String escape(char c,
int flags)
c - The character.flags - The escape flags.public static java.lang.String escape(java.lang.String s,
int flags)
s - The string.flags - The escape flags.public static java.lang.String unescape(java.lang.String s)
\b', '\f', '\n',
'\r', '\t', '\"',
'\'', and '\\'), the additional
standard C escapes ('\a', '\v', and
'\?'), standard C's octal escapes, and standard C's
and Java's Unicode escapes. To support regex-like character
classes, it also unescapes '\-', '\[',
and '\]'.s - The string to unescape.java.lang.IllegalArgumentException - Signals a malformed string.public static java.lang.String format(java.util.List<?> l)
toString() for each element in the
specified list to generate a human-readable representation.l - The list.public static java.lang.String split(java.lang.String id,
char separator)
id - The identifier.separator - The separator.public static java.lang.String toArticle(java.lang.String noun)
noun - The noun.Copyright © 2012. All Rights Reserved.