public final class TidyUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static short |
DIGIT
char type: digit.
|
private static short |
LETTER
char type: letter.
|
private static short[] |
lexmap
used to classify chars for lexical purposes.
|
private static short |
LOWERCASE
char type: lowercase.
|
private static short |
NAMECHAR
char type: namechar.
|
private static short |
NEWLINE
char type: newline.
|
private static short |
UPPERCASE
char type: uppercase.
|
private static short |
WHITE
char type: whitespace.
|
Modifier | Constructor and Description |
---|---|
private |
TidyUtils()
utility class, don't instantiate.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
findBadSubString(java.lang.String s,
java.lang.String p,
int len)
Return true if substring s is in p and isn't all in upper case.
|
static char |
foldCase(char c,
boolean tocaps,
boolean xmlTags)
Fold case of a char.
|
static byte[] |
getBytes(java.lang.String str)
Should always be able convert to/from UTF-8, so encoding exceptions are converted to an Error to avoid adding
throws declarations in lots of methods.
|
static java.lang.String |
getString(byte[] bytes,
int offset,
int length)
Should always be able convert to/from UTF-8, so encoding exceptions are converted to an Error to avoid adding
throws declarations in lots of methods.
|
static boolean |
isCharEncodingSupported(java.lang.String name)
Is the given character encoding supported?
|
static boolean |
isDigit(char c)
Is the given char a digit?
|
(package private) static boolean |
isInValuesIgnoreCase(java.lang.String[] validValues,
java.lang.String valueToCheck)
Check if the string valueToCheck is contained in validValues array (case insesitie comparison).
|
static boolean |
isLetter(char c)
Is the given char a letter?
|
static boolean |
isLower(char c)
Determines if the specified character is a lowercase character.
|
static boolean |
isNamechar(char c)
Is the given char valid in name? (letter, digit or "-", ".", ":", "_")
|
(package private) static boolean |
isQuote(int c)
Is the given character a single or double quote?
|
static boolean |
isUpper(char c)
Determines if the specified character is a uppercase character.
|
static boolean |
isWhite(char c)
Determines if the specified character is whitespace.
|
(package private) static boolean |
isxdigit(char c)
Is the character a hex digit?
|
(package private) static boolean |
isXMLLetter(char c)
Is the given char a valid xml letter?
|
(package private) static boolean |
isXMLNamechar(char c)
Is the given char valid in xml name?
|
static int |
lastChar(java.lang.String str)
Return the last char in string.
|
private static short |
map(char c)
Returns the constant which defines the classification of char in lexmap.
|
private static void |
mapStr(java.lang.String str,
short code)
Classify chars in String and put them in lexmap.
|
(package private) static boolean |
toBoolean(int value)
Converts a int to a boolean.
|
static char |
toLower(char c)
Maps the given character to its lowercase equivalent.
|
(package private) static int |
toUnsigned(int c)
convert an int to unsigned (& 0xFF).
|
static char |
toUpper(char c)
Maps the given character to its uppercase equivalent.
|
(package private) static int |
wstrnchr(java.lang.String s1,
int len1,
char cc)
return offset of cc from beginning of s1, -1 if not found.
|
(package private) static boolean |
wsubstr(java.lang.String s1,
java.lang.String s2)
Same as wsubstrn, but without a specified length.
|
(package private) static boolean |
wsubstrn(java.lang.String s1,
int len1,
java.lang.String s2)
check if the first String contains the second one.
|
(package private) static boolean |
wsubstrncase(java.lang.String s1,
int len1,
java.lang.String s2)
check if the first String contains the second one (ignore case).
|
private static final short DIGIT
private static final short LETTER
private static final short NAMECHAR
private static final short WHITE
private static final short NEWLINE
private static final short LOWERCASE
private static final short UPPERCASE
private static short[] lexmap
static boolean toBoolean(int value)
value
- int valuetrue
if value is != 0static int toUnsigned(int c)
c
- signed intstatic boolean wsubstrn(java.lang.String s1, int len1, java.lang.String s2)
s1
- full Stringlen1
- maximum position in Strings2
- String to search forstatic boolean wsubstrncase(java.lang.String s1, int len1, java.lang.String s2)
s1
- full Stringlen1
- maximum position in Strings2
- String to search forstatic int wstrnchr(java.lang.String s1, int len1, char cc)
s1
- Stringlen1
- maximum offset (values > than lenl are ignored and returned as -1)cc
- character to search forstatic boolean wsubstr(java.lang.String s1, java.lang.String s2)
s1
- full Strings2
- String to search fortrue
if s2 is found in s2 (case insensitive search)static boolean isxdigit(char c)
c
- chartrue
if he given character is a hex digitstatic boolean isInValuesIgnoreCase(java.lang.String[] validValues, java.lang.String valueToCheck)
validValues
- array of valid valuesvalueToCheck
- value to search fortrue
if valueToCheck is found in validValuespublic static boolean findBadSubString(java.lang.String s, java.lang.String p, int len)
s
- substringp
- full stringlen
- how many chars to check in pstatic boolean isXMLLetter(char c)
c
- chartrue
if the char is a valid xml letterstatic boolean isXMLNamechar(char c)
c
- chartrue
if the char is a valid xml name charstatic boolean isQuote(int c)
c
- chartrue
if c is " or 'public static byte[] getBytes(java.lang.String str)
str
- StringString.getBytes()
public static java.lang.String getString(byte[] bytes, int offset, int length)
bytes
- byte arrayoffset
- starting offset in byte arraylength
- length in byte array starting from offsetnew String(bytes, offset, length, "UTF8")
public static int lastChar(java.lang.String str)
str
- Stringpublic static boolean isWhite(char c)
c
- chartrue
if char is whitespace.public static boolean isDigit(char c)
c
- chartrue
if the given char is a digitpublic static boolean isLetter(char c)
c
- chartrue
if the given char is a letterpublic static boolean isNamechar(char c)
c
- chartrue
if char is a name char.public static boolean isLower(char c)
c
- chartrue
if char is lower case.public static boolean isUpper(char c)
c
- chartrue
if char is upper case.public static char toLower(char c)
c
- charpublic static char toUpper(char c)
c
- charpublic static char foldCase(char c, boolean tocaps, boolean xmlTags)
c
- chartocaps
- convert to capsxmlTags
- use xml tags? If true no change will be performedprivate static void mapStr(java.lang.String str, short code)
str
- Stringcode
- code associated to chars in the Stringprivate static short map(char c)
c
- charpublic static boolean isCharEncodingSupported(java.lang.String name)
name
- character encoding nametrue
if encoding is supported, false otherwhise.