org.w3c.tidy
Class TidyUtils
public final class TidyUtils
extends java.lang.Object
Utility class with handy methods, mainly for String handling or for reproducing c behaviours.
static boolean | findBadSubString(String s, 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(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 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(String name) - Is the given character encoding supported?
|
static boolean | isDigit(char c) - Is the given char a digit?
|
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 "-", ".", ":", "_")
|
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.
|
static int | lastChar(String str) - Return the last char in string.
|
static char | toLower(char c) - Maps the given character to its lowercase equivalent.
|
static char | toUpper(char c) - Maps the given character to its uppercase equivalent.
|
findBadSubString
public static boolean findBadSubString(String s,
String p,
int len)
Return true if substring s is in p and isn't all in upper case. This is used to check the case of SYSTEM, PUBLIC,
DTD and EN.
s
- substringp
- full stringlen
- how many chars to check in p
- true if substring s is in p and isn't all in upper case
foldCase
public static char foldCase(char c,
boolean tocaps,
boolean xmlTags)
Fold case of a char.
c
- chartocaps
- convert to capsxmlTags
- use xml tags? If true no change will be performed
getBytes
public static byte[] getBytes(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.
getString
public static 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.
bytes
- byte arrayoffset
- starting offset in byte arraylength
- length in byte array starting from offset
- same as
new String(bytes, offset, length, "UTF8")
isCharEncodingSupported
public static boolean isCharEncodingSupported(String name)
Is the given character encoding supported?
name
- character encoding name
true
if encoding is supported, false otherwhise.
isDigit
public static boolean isDigit(char c)
Is the given char a digit?
true
if the given char is a digit
isLetter
public static boolean isLetter(char c)
Is the given char a letter?
true
if the given char is a letter
isLower
public static boolean isLower(char c)
Determines if the specified character is a lowercase character.
true
if char is lower case.
isNamechar
public static boolean isNamechar(char c)
Is the given char valid in name? (letter, digit or "-", ".", ":", "_")
true
if char is a name char.
isUpper
public static boolean isUpper(char c)
Determines if the specified character is a uppercase character.
true
if char is upper case.
isWhite
public static boolean isWhite(char c)
Determines if the specified character is whitespace.
true
if char is whitespace.
lastChar
public static int lastChar(String str)
Return the last char in string. This is useful when trailing quotemark is missing on an attribute
toLower
public static char toLower(char c)
Maps the given character to its lowercase equivalent.
toUpper
public static char toUpper(char c)
Maps the given character to its uppercase equivalent.