public class XMLUtil
extends java.lang.Object
Constructor and Description |
---|
XMLUtil() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
escapeXML(java.lang.String s,
boolean onlyASCII)
Escapes a string with the appropriated XML codes.
|
static int |
findInArray(char needle,
char[] haystack,
int start)
Looks for a character in a character array, starting from a certain position
|
static java.lang.String |
getEncodingName(byte[] b4)
Returns the IANA encoding name that is auto-detected from
the bytes specified, with the endian-ness of that encoding where appropriate.
|
static boolean |
isValidCharacterValue(int c)
Checks if a character value should be escaped/unescaped.
|
static boolean |
isValidCharacterValue(java.lang.String s)
Checks if a character value should be escaped/unescaped.
|
static int |
unescape(java.lang.String s)
Unescapes 'lt', 'gt', 'apos', 'quote' and 'amp' to the
corresponding character values.
|
static java.lang.String |
unescapeXML(java.lang.String s)
Unescapes a String, replacing nn;, <, >, &, ",
and &apos to the corresponding characters.
|
public static java.lang.String escapeXML(java.lang.String s, boolean onlyASCII)
s
- the string to be escapedonlyASCII
- codes above 127 will always be escaped with &#nn; if true
public static java.lang.String unescapeXML(java.lang.String s)
s
- a String with entitiespublic static int unescape(java.lang.String s)
s
- a string representing a characterpublic static boolean isValidCharacterValue(java.lang.String s)
s
- the String representation of an integerpublic static boolean isValidCharacterValue(int c)
c
- a character valuepublic static int findInArray(char needle, char[] haystack, int start)
needle
- the character you're looking forhaystack
- the character arraystart
- the start positionpublic static java.lang.String getEncodingName(byte[] b4)
b4
- The first four bytes of the input.Copyright © 2013. All Rights Reserved.