public class XMLUtil extends Object
Constructor | Description |
---|---|
XMLUtil() |
Modifier and Type | Method | Description |
---|---|---|
static String |
escapeXML(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 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(String s) |
Checks if a character value should be escaped/unescaped.
|
static int |
unescape(String s) |
Unescapes 'lt', 'gt', 'apos', 'quote' and 'amp' to the
corresponding character values.
|
static String |
unescapeXML(String s) |
Unescapes a String, replacing nn;, <, >, &, ",
and &apos to the corresponding characters.
|
public static String escapeXML(String s, boolean onlyASCII)
s
- the string to be escapedonlyASCII
- codes above 127 will always be escaped with &#nn; if true
public static String unescapeXML(String s)
s
- a String with entitiespublic static int unescape(String s)
s
- a string representing a characterpublic static boolean isValidCharacterValue(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 String getEncodingName(byte[] b4)
b4
- The first four bytes of the input.Copyright © 2018. All rights reserved.