Package org.semanticweb.owlapi.io
Class XMLUtils
java.lang.Object
org.semanticweb.owlapi.io.XMLUtils
This class contains various methods for checking QNames, NCNames etc. The implementation is based
on the W3C namespaces in XML specification.
- Since:
- 3.3.0
- Author:
- Matthew Horridge, The University of Manchester, Bio-Health Informatics Group
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic 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
Escapes a character sequence so that it is valid XML.static void
Escapes a string builder so that it is valid XML.static String
utility to get the part of a char sequence that is not the NCName fragment.static String
Get the longest NCName that is a suffix of a character sequence.static int
Gets the index of the longest NCName that is the suffix of a character sequence.static boolean
Determines if a character sequence has a suffix that is an NCName.static String
static boolean
static boolean
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
Determines if a character sequence isnull
or empty.static boolean
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.
-
Field Details
-
LT
< shortcut.- See Also:
-
GT
> shortcut.- See Also:
-
QUOT
" shortcut.- See Also:
-
AMP
& shortcut.- See Also:
-
APOS
' shortcut.- See Also:
-
OWL_PROCESSING_INSTRUCTION_NAME
OWL processing instruction.- See Also:
-
-
Method Details
-
isXMLNameStartCharacter
public static boolean isXMLNameStartCharacter(int codePoint) Determines if a character is an XML name start character.- Parameters:
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.- Returns:
true
ifcodePoint
is an XML name start character, otherwisefalse
-
isXMLNameChar
public static boolean isXMLNameChar(int codePoint) Determines if a character is an XML name character.- Parameters:
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.- Returns:
true
ifcodePoint
is an XML name start character, otherwisefalse
-
isNCNameStartChar
public static boolean isNCNameStartChar(int codePoint) Determines if a character is an NCName (Non-Colonised Name) start character.- Parameters:
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.- Returns:
true
ifcodePoint
is a NCName start character, otherwisefalse
.
-
isNCNameChar
public static boolean isNCNameChar(int codePoint) Determines if a character is an NCName (Non-Colonised Name) character.- Parameters:
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.- Returns:
true
ifcodePoint
is a NCName character, otherwisefalse
.
-
isNCName
Determines if a character sequence is an NCName (Non-Colonised Name). An NCName is a string which starts with an NCName start character and is followed by zero or more NCName characters.- Parameters:
s
- The character sequence to be tested.- Returns:
true
ifs
is an NCName, otherwisefalse
.
-
isQName
Determines if a character sequence is a QName. A QName is either an NCName (LocalName), or an NCName followed by a colon followed by another NCName (where the first NCName is referred to as the 'Prefix Name' and the second NCName is referred to as the 'Local Name' - i.e. PrefixName:LocalName).- Parameters:
s
- The character sequence to be tested.- Returns:
true
ifs
is a QName, otherwisefalse
.
-
isQName
Determines if a character sequence is a QName. A QName is either an NCName (LocalName), or an NCName followed by a colon followed by another NCName (where the first NCName is referred to as the 'Prefix Name' and the second NCName is referred to as the 'Local Name' - i.e. PrefixName:LocalName).- Parameters:
s
- The character sequence to be tested.start
- start index to check- Returns:
true
ifs
is a QName, otherwisefalse
.
-
hasNCNameSuffix
Determines if a character sequence has a suffix that is an NCName.- Parameters:
s
- The character sequence.- Returns:
true
if the character sequences
has a suffix that is an NCName.
-
getNCNameSuffixIndex
Gets the index of the longest NCName that is the suffix of a character sequence.- Parameters:
s
- The character sequence.- Returns:
- The index of the longest suffix of the specified character sequence
s
that is an NCName, or -1 if the character sequences
does not have a suffix that is an NCName.
-
getNCNameSuffix
Get the longest NCName that is a suffix of a character sequence.- Parameters:
s
- The character sequence.- Returns:
- The String which is the longest suffix of the character sequence
s
that is an NCName, ornull
if the character sequences
does not have a suffix that is an NCName.
-
isEmpty
- Parameters:
s
- string- Returns:
- true if the input is null, empty or blank, i.e., only containing whitespace characters
-
getNCNamePrefix
utility to get the part of a char sequence that is not the NCName fragment.- Parameters:
s
- the char sequence to split- Returns:
- the prefix split at the last non-ncname character, or the whole input if no ncname is found
-
escapeXML
Escapes a character sequence so that it is valid XML.- Parameters:
s
- The character sequence.- Returns:
- The escaped version of the character sequence.
-
escapeXML
public static StringBuilder escapeXML(char[] chars, int start, int count, StringBuilder destination) Escapes a subset of a char sequence so that it is valid XML. Escaped or unchanged characters are added to destination.- Parameters:
chars
- chars to checkstart
- start index (inclusive)count
- number of charactersdestination
- destination for escaped chars- Returns:
- The modified destination.
-
escapeXML
Escapes a string builder so that it is valid XML.- Parameters:
sb
- The string builder to escape.
-
isNullOrEmpty
Determines if a character sequence isnull
or empty.- Parameters:
s
- The character sequence.- Returns:
true
if the character sequence isnull
,true
if the character sequence is empty, otherwisefalse
.
-
iriWithTerminatingHash
- Parameters:
iri
- input to check and terminate with a hash- Returns:
- input plus a hash if the input does not terminate with hash or slash; if the input
contains a hash in a position aside from the last character, it is returned
unchanged. If null is received, return
"#"
.
-