Class Verifier
- Author:
- Brett McLaughlin, Elliotte Rusty Harold, Jason Hunter, Bradley S. Huffman, Rolf Lear, Wilfried Middleton
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
checkAttributeName
(String name) This will check the supplied name to see if it is legal for use as a JDOM
name.Attribute
static String
checkCDATASection
(String data) This will check the supplied data to see if it is legal for use as JDOM
.CDATA
static String
checkCharacterData
(String text) This will check the supplied string to see if it only contains characters allowed by the XML 1.0 specification.static String
checkCommentData
(String data) This will check the supplied data to see if it is legal for use as JDOM
data.Comment
static String
checkElementName
(String name) This will check the supplied name to see if it is legal for use as a JDOM
name.Element
static String
checkNamespaceCollision
(Attribute attribute, Element element) static String
checkNamespaceCollision
(Attribute attribute, Element element, int ignoreatt) static String
checkNamespaceCollision
(Namespace namespace, List<?> list) Check if a
collides with any namespace from a list of objects.Namespace
static String
checkNamespaceCollision
(Namespace namespace, List<?> list, int ignoreatt) Check if a
collides with any namespace from a list of objects.Namespace
static String
checkNamespaceCollision
(Namespace namespace, Attribute attribute) static String
checkNamespaceCollision
(Namespace namespace, Element element) static String
checkNamespaceCollision
(Namespace namespace, Element element, int ignoreatt) static String
checkNamespaceCollision
(Namespace namespace, Namespace other) Check if two namespaces collide.static String
checkNamespacePrefix
(String prefix) This will check the supplied name to see if it is legal for use as a JDOM
prefix.Namespace
static String
checkNamespaceURI
(String uri) This will check the supplied name to see if it is legal for use as a JDOM
URI.Namespace
static String
This will check the supplied data to see if it is legal for use as
data.ProcessingInstruction
static String
This will check the supplied data to see if it is legal for use as a JDOM
target.ProcessingInstruction
static String
checkPublicID
(String publicID) This will ensure that the data for a public identifier is legal.static String
checkSystemLiteral
(String systemLiteral) This will ensure that the data for a system literal is legal.static String
Checks a string to see if it is a legal RFC 2396 URI.static String
checkXMLName
(String name) This is a utility function for sharing the base process of checking any XML name.static int
decodeSurrogatePair
(char high, char low) This is a utility function to decode a non-BMP UTF-16 surrogate pair.static final boolean
isAllXMLWhitespace
(String value) This is a utility function for determining whether a specified String is a whitespace character according to production 3 of the XML 1.0 specification.static boolean
isHexDigit
(char c) This is a utility function for determining whether a specified Unicode character is a hexadecimal digit as defined in RFC 2396; that is, one of the ASCII characters 0-9, a-f, or A-F.static boolean
isHighSurrogate
(char ch) This is a function for determining whether the specified character is the high 16 bits in a UTF-16 surrogate pair.static boolean
isLowSurrogate
(char ch) This is a function for determining whether the specified character is the low 16 bits in a UTF-16 surrogate pair.static boolean
isURICharacter
(char c) This is a utility function for determining whether a specified Unicode character is legal in URI references as determined by RFC 2396.static boolean
isXMLCharacter
(int c) This is a utility function for determining whether a specified character is a character according to production 2 of the XML 1.0 specification.static boolean
isXMLCombiningChar
(char c) This is a utility function for determining whether a specified character is a combining character according to production 87 of the XML 1.0 specification.static boolean
isXMLDigit
(char c) This is a utility function for determining whether a specified Unicode character is a digit according to production 88 of the XML 1.0 specification.static boolean
isXMLExtender
(char c) This is a utility function for determining whether a specified character is an extender according to production 88 of the XML 1.0 specification.static boolean
isXMLLetter
(char c) This is a utility function for determining whether a specified character is a letter according to production 84 of the XML 1.0 specification.static boolean
isXMLLetterOrDigit
(char c) This is a utility function for determining whether a specified character is a letter or digit according to productions 84 and 88 of the XML 1.0 specification.static boolean
isXMLNameCharacter
(char c) This is a utility function for determining whether a specified character is a name character according to production 4 of the XML 1.0 specification.static boolean
isXMLNameStartCharacter
(char c) This is a utility function for determining whether a specified character is a legal name start character according to production 5 of the XML 1.0 specification.static boolean
isXMLPublicIDCharacter
(char c) static boolean
isXMLWhitespace
(char c) This is a utility function for determining whether a specified Unicode character is a whitespace character according to production 3 of the XML 1.0 specification.
-
Method Details
-
checkElementName
This will check the supplied name to see if it is legal for use as a JDOM
name.Element
- Parameters:
name
-String
name to check.- Returns:
String
reason name is illegal, ornull
if name is OK.
-
checkAttributeName
This will check the supplied name to see if it is legal for use as a JDOM
name.Attribute
- Parameters:
name
-String
name to check.- Returns:
String
reason name is illegal, ornull
if name is OK.
-
checkCharacterData
This will check the supplied string to see if it only contains characters allowed by the XML 1.0 specification. The C0 controls (e.g. null, vertical tab, form-feed, etc.) are specifically excluded except for carriage return, line-feed, and the horizontal tab. Surrogates are also excluded.This method is useful for checking element content and attribute values. Note that characters like " and < are allowed in attribute values and element content. They will simply be escaped as " or < when the value is serialized.
- Parameters:
text
-String
value to check.- Returns:
String
reason name is illegal, ornull
if name is OK.
-
checkCDATASection
This will check the supplied data to see if it is legal for use as JDOM
.CDATA
- Parameters:
data
-String
data to check.- Returns:
String
reason data is illegal, ornull
is name is OK.
-
checkNamespacePrefix
This will check the supplied name to see if it is legal for use as a JDOM
prefix.Namespace
- Parameters:
prefix
-String
prefix to check.- Returns:
String
reason name is illegal, ornull
if name is OK.
-
checkNamespaceURI
This will check the supplied name to see if it is legal for use as a JDOM
URI.Namespace
This is a 'light' test of URI's designed to filter out only the worst illegal URIs. It tests only to ensure the first character is valid. A comprehensive URI validation process would be impractical.
- Parameters:
uri
-String
URI to check.- Returns:
String
reason name is illegal, ornull
if name is OK.
-
checkNamespaceCollision
Check if two namespaces collide.- Parameters:
namespace
-Namespace
to check.other
-Namespace
to check against.- Returns:
String
reason for collision, ornull
if no collision.
-
checkNamespaceCollision
- Parameters:
attribute
-Attribute
to check.element
-Element
to check against.- Returns:
String
reason for collision, ornull
if no collision.
-
checkNamespaceCollision
- Parameters:
attribute
-Attribute
to check.element
-Element
to check against.ignoreatt
- Ignore a specific Attribute (if it exists) when calculating any collisions (used when replacing one attribute with another).- Returns:
String
reason for collision, ornull
if no collision.
-
checkNamespaceCollision
- Parameters:
namespace
-Namespace
to check.element
-Element
to check against.- Returns:
String
reason for collision, ornull
if no collision.
-
checkNamespaceCollision
- Parameters:
namespace
-Namespace
to check.element
-Element
to check against.ignoreatt
- Ignore a specific Attribute (if it exists) when calculating any collisions (used when replacing one attribute with another).- Returns:
String
reason for collision, ornull
if no collision.
-
checkNamespaceCollision
- Parameters:
namespace
-Namespace
to check.attribute
-Attribute
to check against.- Returns:
String
reason for collision, ornull
if no collision.
-
checkNamespaceCollision
Check if a
collides with any namespace from a list of objects.Namespace
- Parameters:
namespace
-Namespace
to check.list
-List
to check against.- Returns:
String
reason for collision, ornull
if no collision.
-
checkNamespaceCollision
Check if a
collides with any namespace from a list of objects.Namespace
- Parameters:
namespace
-Namespace
to check.list
-List
to check against.ignoreatt
- Ignore a specific Attribute (if it exists) when calculating any collisions (used when replacing one attribute with another).- Returns:
String
reason for collision, ornull
if no collision.
-
checkProcessingInstructionTarget
This will check the supplied data to see if it is legal for use as a JDOM
target.ProcessingInstruction
- Parameters:
target
-String
target to check.- Returns:
String
reason target is illegal, ornull
if target is OK.
-
checkProcessingInstructionData
This will check the supplied data to see if it is legal for use as
data. Besides checking that all the characters are allowed in XML, this also checks that the data does not contain the PI end-string "?>".ProcessingInstruction
- Parameters:
data
-String
data to check.- Returns:
String
reason data is illegal, ornull
if data is OK.
-
checkCommentData
This will check the supplied data to see if it is legal for use as JDOM
data.Comment
- Parameters:
data
-String
data to check.- Returns:
String
reason data is illegal, ornull
if data is OK.
-
decodeSurrogatePair
public static int decodeSurrogatePair(char high, char low) This is a utility function to decode a non-BMP UTF-16 surrogate pair.- Parameters:
high
- high 16 bitslow
- low 16 bits- Returns:
- decoded character
-
isXMLPublicIDCharacter
public static boolean isXMLPublicIDCharacter(char c) This will check the supplied data to see if it is legal for use as PublicID (in aDocType
orEntityRef
).- Parameters:
c
- the character to validate- Returns:
String
reason c is illegal, ornull
if c is OK.
-
checkPublicID
This will ensure that the data for a public identifier is legal.- Parameters:
publicID
-String
public ID to check.- Returns:
String
reason public ID is illegal, ornull
if public ID is OK.
-
checkSystemLiteral
This will ensure that the data for a system literal is legal.- Parameters:
systemLiteral
-String
system literal to check.- Returns:
String
reason system literal is illegal, ornull
if system literal is OK.
-
checkXMLName
This is a utility function for sharing the base process of checking any XML name.- Parameters:
name
-String
to check for XML name compliance.- Returns:
String
reason the name is illegal, ornull
if OK.
-
checkURI
Checks a string to see if it is a legal RFC 2396 URI. Both absolute and relative URIs are supported.
- Parameters:
uri
-String
to check.- Returns:
String
reason the URI is illegal, ornull
if OK.
-
isHexDigit
public static boolean isHexDigit(char c) This is a utility function for determining whether a specified Unicode character is a hexadecimal digit as defined in RFC 2396; that is, one of the ASCII characters 0-9, a-f, or A-F.
- Parameters:
c
- to check for hex digit.- Returns:
- true if it's allowed, false otherwise.
-
isHighSurrogate
public static boolean isHighSurrogate(char ch) This is a function for determining whether the specified character is the high 16 bits in a UTF-16 surrogate pair.- Parameters:
ch
- character to check- Returns:
- true if the character is a high surrogate, false otherwise
-
isLowSurrogate
public static boolean isLowSurrogate(char ch) This is a function for determining whether the specified character is the low 16 bits in a UTF-16 surrogate pair.- Parameters:
ch
- character to check- Returns:
- true if the character is a low surrogate, false otherwise.
-
isURICharacter
public static boolean isURICharacter(char c) This is a utility function for determining whether a specified Unicode character is legal in URI references as determined by RFC 2396.
- Parameters:
c
-char
to check for URI reference compliance.- Returns:
- true if it's allowed, false otherwise.
-
isXMLCharacter
public static boolean isXMLCharacter(int c) This is a utility function for determining whether a specified character is a character according to production 2 of the XML 1.0 specification.- Parameters:
c
-char
to check for XML compliance- Returns:
boolean
true if it's a character, false otherwise
-
isXMLNameCharacter
public static boolean isXMLNameCharacter(char c) This is a utility function for determining whether a specified character is a name character according to production 4 of the XML 1.0 specification.- Parameters:
c
-char
to check for XML name compliance.- Returns:
boolean
true if it's a name character, false otherwise.
-
isXMLNameStartCharacter
public static boolean isXMLNameStartCharacter(char c) This is a utility function for determining whether a specified character is a legal name start character according to production 5 of the XML 1.0 specification. This production does allow names to begin with colons which the Namespaces in XML Recommendation disallows.- Parameters:
c
-char
to check for XML name start compliance.- Returns:
boolean
true if it's a name start character, false otherwise.
-
isXMLLetterOrDigit
public static boolean isXMLLetterOrDigit(char c) This is a utility function for determining whether a specified character is a letter or digit according to productions 84 and 88 of the XML 1.0 specification.- Parameters:
c
-char
to check.- Returns:
boolean
true if it's letter or digit, false otherwise.
-
isXMLLetter
public static boolean isXMLLetter(char c) This is a utility function for determining whether a specified character is a letter according to production 84 of the XML 1.0 specification.- Parameters:
c
-char
to check for XML name compliance.- Returns:
String
true if it's a letter, false otherwise.
-
isXMLCombiningChar
public static boolean isXMLCombiningChar(char c) This is a utility function for determining whether a specified character is a combining character according to production 87 of the XML 1.0 specification.- Parameters:
c
-char
to check.- Returns:
boolean
true if it's a combining character, false otherwise.
-
isXMLExtender
public static boolean isXMLExtender(char c) This is a utility function for determining whether a specified character is an extender according to production 88 of the XML 1.0 specification.- Parameters:
c
-char
to check.- Returns:
String
true if it's an extender, false otherwise.
-
isXMLDigit
public static boolean isXMLDigit(char c) This is a utility function for determining whether a specified Unicode character is a digit according to production 88 of the XML 1.0 specification.- Parameters:
c
-char
to check for XML digit compliance- Returns:
boolean
true if it's a digit, false otherwise
-
isXMLWhitespace
public static boolean isXMLWhitespace(char c) This is a utility function for determining whether a specified Unicode character is a whitespace character according to production 3 of the XML 1.0 specification.- Parameters:
c
-char
to check for XML whitespace compliance- Returns:
boolean
true if it's a whitespace, false otherwise
-
isAllXMLWhitespace
This is a utility function for determining whether a specified String is a whitespace character according to production 3 of the XML 1.0 specification.This method delegates the individual calls for each character to
isXMLWhitespace(char)
.- Parameters:
value
- The value to inspect- Returns:
- true if all characters in the input value are all whitespace (or the string is the empty-string).
- Since:
- JDOM2
-