|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.w3c.tidy.TidyUtils
Utility class with handy methods, mainly for String handling or for reproducing c behaviours.
Field Summary | |
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. |
Constructor Summary | |
private |
TidyUtils()
utility class, don't instantiate. |
Method Summary | |
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). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
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
Constructor Detail |
private TidyUtils()
Method Detail |
static boolean toBoolean(int value)
value
- int value
true
if value is != 0static int toUnsigned(int c)
c
- signed int
static boolean wsubstrn(java.lang.String s1, int len1, java.lang.String s2)
s1
- full Stringlen1
- maximum position in Strings2
- String to search for
static boolean wsubstrncase(java.lang.String s1, int len1, java.lang.String s2)
s1
- full Stringlen1
- maximum position in Strings2
- String to search for
static 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 for
static boolean wsubstr(java.lang.String s1, java.lang.String s2)
s1
- full Strings2
- String to search for
true
if s2 is found in s2 (case insensitive search)static boolean isxdigit(char c)
c
- char
true
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 for
true
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 p
static boolean isXMLLetter(char c)
c
- char
true
if the char is a valid xml letterstatic boolean isXMLNamechar(char c)
c
- char
true
if the char is a valid xml name charstatic boolean isQuote(int c)
c
- char
true
if c is " or 'public static byte[] getBytes(java.lang.String str)
str
- String
String.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 offset
new String(bytes, offset, length, "UTF8")
public static int lastChar(java.lang.String str)
str
- String
public static boolean isWhite(char c)
c
- char
true
if char is whitespace.public static boolean isDigit(char c)
c
- char
true
if the given char is a digitpublic static boolean isLetter(char c)
c
- char
true
if the given char is a letterpublic static boolean isNamechar(char c)
c
- char
true
if char is a name char.public static boolean isLower(char c)
c
- char
true
if char is lower case.public static boolean isUpper(char c)
c
- char
true
if char is upper case.public static char toLower(char c)
c
- char
public static char toUpper(char c)
c
- char
public static char foldCase(char c, boolean tocaps, boolean xmlTags)
c
- chartocaps
- convert to capsxmlTags
- use xml tags? If true no change will be performed
private static void mapStr(java.lang.String str, short code)
str
- Stringcode
- code associated to chars in the Stringprivate static short map(char c)
c
- char
public static boolean isCharEncodingSupported(java.lang.String name)
name
- character encoding name
true
if encoding is supported, false otherwhise.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |