public final class XMLUtils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
AMP
& shortcut.
|
static String |
APOS
' shortcut.
|
static String |
GT
> shortcut.
|
static String |
LT
< shortcut.
|
static String |
OWL_PROCESSING_INSTRUCTION_NAME
OWL processing instruction.
|
static String |
QUOT
" shortcut.
|
Modifier and Type | Method and Description |
---|---|
static StringBuilder |
escapeXML(char[] chars,
int start,
int count,
StringBuilder destination)
Escapes a subset of a char sequence so that it is valid XML.
|
static String |
escapeXML(CharSequence s)
Escapes a character sequence so that it is valid XML.
|
static void |
escapeXML(StringBuilder sb)
Escapes a string builder so that it is valid XML.
|
static String |
getNCNamePrefix(CharSequence s)
utility to get the part of a char sequence that is not the NCName fragment.
|
static String |
getNCNameSuffix(CharSequence s)
Get the longest NCName that is a suffix of a character sequence.
|
static int |
getNCNameSuffixIndex(CharSequence s)
Gets the index of the longest NCName that is the suffix of a character sequence.
|
static boolean |
hasNCNameSuffix(CharSequence s)
Determines if a character sequence has a suffix that is an NCName.
|
static String |
iriWithTerminatingHash(String iri) |
static boolean |
isEmpty(CharSequence s) |
static boolean |
isNCName(CharSequence s)
Determines if a character sequence is an NCName (Non-Colonised Name).
|
static boolean |
isNCNameChar(int codePoint)
Determines if a character is an NCName (Non-Colonised Name) character.
|
static boolean |
isNCNameStartChar(int codePoint)
Determines if a character is an NCName (Non-Colonised Name) start character.
|
static boolean |
isNullOrEmpty(CharSequence s)
Determines if a character sequence is
null or empty. |
static boolean |
isQName(CharSequence s)
Determines if a character sequence is a QName.
|
static boolean |
isQName(CharSequence s,
int start)
Determines if a character sequence is a QName.
|
static boolean |
isXMLNameChar(int codePoint)
Determines if a character is an XML name character.
|
static boolean |
isXMLNameStartCharacter(int codePoint)
Determines if a character is an XML name start character.
|
public static final String LT
public static final String GT
public static final String QUOT
public static final String AMP
public static final String APOS
public static final String OWL_PROCESSING_INSTRUCTION_NAME
public static boolean isXMLNameStartCharacter(int codePoint)
codePoint
- The code point of the character to be tested. For UTF-16 characters the code
point corresponds to the value of the char that represents the character.true
if codePoint
is an XML name start character, otherwise
false
public static boolean isXMLNameChar(int codePoint)
codePoint
- The code point of the character to be tested. For UTF-8 and UTF-16
characters the code point corresponds to the value of the char that represents the
character.true
if codePoint
is an XML name start character, otherwise
false
public static boolean isNCNameStartChar(int codePoint)
codePoint
- The code point of the character to be tested. For UTF-8 and UTF-16
characters the code point corresponds to the value of the char that represents the
character.true
if codePoint
is a NCName start character, otherwise
false
.public static boolean isNCNameChar(int codePoint)
codePoint
- The code point of the character to be tested. For UTF-8 and UTF-16
characters the code point corresponds to the value of the char that represents the
character.true
if codePoint
is a NCName character, otherwise false
.public static boolean isNCName(@Nullable CharSequence s)
s
- The character sequence to be tested.true
if s
is an NCName, otherwise false
.public static boolean isQName(CharSequence s)
s
- The character sequence to be tested.true
if s
is a QName, otherwise false
.public static boolean isQName(CharSequence s, int start)
s
- The character sequence to be tested.start
- start index to checktrue
if s
is a QName, otherwise false
.public static boolean hasNCNameSuffix(CharSequence s)
s
- The character sequence.true
if the character sequence s
has a suffix that is an NCName.public static int getNCNameSuffixIndex(CharSequence s)
s
- The character sequence.s
that is
an NCName, or -1 if the character sequence s
does not have a suffix that is
an NCName.@Nullable public static String getNCNameSuffix(CharSequence s)
s
- The character sequence.s
that is an
NCName, or null
if the character sequence s
does not have a suffix
that is an NCName.public static boolean isEmpty(@Nullable CharSequence s)
s
- stringpublic static String getNCNamePrefix(CharSequence s)
s
- the char sequence to splitpublic static String escapeXML(CharSequence s)
s
- The character sequence.public static StringBuilder escapeXML(char[] chars, int start, int count, StringBuilder destination)
chars
- chars to checkstart
- start index (inclusive)count
- number of charactersdestination
- destination for escaped charspublic static void escapeXML(StringBuilder sb)
sb
- The string builder to escape.public static boolean isNullOrEmpty(@Nullable CharSequence s)
null
or empty.s
- The character sequence.true
if the character sequence is null
, true
if the character
sequence is empty, otherwise false
.public static String iriWithTerminatingHash(@Nullable String iri)
iri
- input to check and terminate with a hash"#"
.Copyright © 2020 The University of Manchester. All rights reserved.