public class XMLUtil extends Object
Constructor and Description |
---|
XMLUtil() |
Modifier and Type | Method and 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 escaped
onlyASCII
- codes above 127 will always be escaped with nn; if true
public static String unescapeXML(String s)
s
- a String with entities
public static int unescape(String s)
s
- a string representing a character
public static boolean isValidCharacterValue(String s)
s
- the String representation of an integer
public static boolean isValidCharacterValue(int c)
c
- a character value
public static int findInArray(char needle, char[] haystack, int start)
needle
- the character you're looking for
haystack
- the character array
start
- the start position
public static String getEncodingName(byte[] b4)
b4
- The first four bytes of the input.
Copyright © 1998–2016. All rights reserved.