Package org.jdom
Class Verifier
- java.lang.Object
-
- org.jdom.Verifier
-
public final class Verifier extends java.lang.ObjectA utility class to handle well-formedness checks on names, data, and other verification tasks for JDOM. The class is final and may not be subclassed.- Version:
- $Revision: 1.57 $, $Date: 2009/07/23 05:54:23 $
- Author:
- Brett McLaughlin, Elliotte Rusty Harold, Jason Hunter, Bradley S. Huffman
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringcheckAttributeName(java.lang.String name)This will check the supplied name to see if it is legal for use as a JDOMname.Attributestatic java.lang.StringcheckCDATASection(java.lang.String data)This will check the supplied data to see if it is legal for use as JDOM.CDATAstatic java.lang.StringcheckCharacterData(java.lang.String text)This will check the supplied string to see if it only contains characters allowed by the XML 1.0 specification.static java.lang.StringcheckCommentData(java.lang.String data)This will check the supplied data to see if it is legal for use as JDOMdata.Commentstatic java.lang.StringcheckElementName(java.lang.String name)This will check the supplied name to see if it is legal for use as a JDOMname.Elementstatic java.lang.StringcheckNamespaceCollision(Attribute attribute, Element element)static java.lang.StringcheckNamespaceCollision(Namespace namespace, java.util.List list)Check if acollides with any namespace from a list of objects.Namespacestatic java.lang.StringcheckNamespaceCollision(Namespace namespace, Attribute attribute)static java.lang.StringcheckNamespaceCollision(Namespace namespace, Element element)static java.lang.StringcheckNamespaceCollision(Namespace namespace, Namespace other)Check if two namespaces collide.static java.lang.StringcheckNamespacePrefix(java.lang.String prefix)This will check the supplied name to see if it is legal for use as a JDOMprefix.Namespacestatic java.lang.StringcheckNamespaceURI(java.lang.String uri)This will check the supplied name to see if it is legal for use as a JDOMURI.Namespacestatic java.lang.StringcheckProcessingInstructionData(java.lang.String data)This will check the supplied data to see if it is legal for use asdata.ProcessingInstructionstatic java.lang.StringcheckProcessingInstructionTarget(java.lang.String target)This will check the supplied data to see if it is legal for use as a JDOMtarget.ProcessingInstructionstatic java.lang.StringcheckPublicID(java.lang.String publicID)This will ensure that the data for a public identifier is legal.static java.lang.StringcheckSystemLiteral(java.lang.String systemLiteral)This will ensure that the data for a system literal is legal.static java.lang.StringcheckURI(java.lang.String uri)Checks a string to see if it is a legal RFC 2396 URI.static java.lang.StringcheckXMLName(java.lang.String name)This is a utility function for sharing the base process of checking any XML name.static intdecodeSurrogatePair(char high, char low)This is a utility function to decode a non-BMP UTF-16 surrogate pair.static booleanisHexDigit(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 booleanisHighSurrogate(char ch)This is a function for determining whether the specified character is the high 16 bits in a UTF-16 surrogate pair.static booleanisLowSurrogate(char ch)This is a function for determining whether the specified character is the low 16 bits in a UTF-16 surrogate pair.static booleanisURICharacter(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 booleanisXMLCharacter(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 booleanisXMLCombiningChar(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 booleanisXMLDigit(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 booleanisXMLExtender(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 booleanisXMLLetter(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 booleanisXMLLetterOrDigit(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 booleanisXMLNameCharacter(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 booleanisXMLNameStartCharacter(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 booleanisXMLPublicIDCharacter(char c)static booleanisXMLWhitespace(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 Detail
-
checkElementName
public static java.lang.String checkElementName(java.lang.String name)
This will check the supplied name to see if it is legal for use as a JDOMname.Element- Parameters:
name-Stringname to check.- Returns:
Stringreason name is illegal, ornullif name is OK.
-
checkAttributeName
public static java.lang.String checkAttributeName(java.lang.String name)
This will check the supplied name to see if it is legal for use as a JDOMname.Attribute- Parameters:
name-Stringname to check.- Returns:
Stringreason name is illegal, ornullif name is OK.
-
checkCharacterData
public static java.lang.String checkCharacterData(java.lang.String text)
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, formfeed, etc.) are specifically excluded except for carriage return, linefeed, 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-Stringvalue to check.- Returns:
Stringreason name is illegal, ornullif name is OK.
-
checkCDATASection
public static java.lang.String checkCDATASection(java.lang.String data)
This will check the supplied data to see if it is legal for use as JDOM.CDATA- Parameters:
data-Stringdata to check.- Returns:
Stringreason data is illegal, ornullis name is OK.
-
checkNamespacePrefix
public static java.lang.String checkNamespacePrefix(java.lang.String prefix)
This will check the supplied name to see if it is legal for use as a JDOMprefix.Namespace- Parameters:
prefix-Stringprefix to check.- Returns:
Stringreason name is illegal, ornullif name is OK.
-
checkNamespaceURI
public static java.lang.String checkNamespaceURI(java.lang.String uri)
This will check the supplied name to see if it is legal for use as a JDOMURI.Namespace- Parameters:
uri-StringURI to check.- Returns:
Stringreason name is illegal, ornullif name is OK.
-
checkNamespaceCollision
public static java.lang.String checkNamespaceCollision(Namespace namespace, Namespace other)
Check if two namespaces collide.- Parameters:
namespace-Namespaceto check.other-Namespaceto check against.- Returns:
Stringreason for collision, ornullif no collision.
-
checkNamespaceCollision
public static java.lang.String checkNamespaceCollision(Attribute attribute, Element element)
- Parameters:
attribute-Attributeto check.element-Elementto check against.- Returns:
Stringreason for collision, ornullif no collision.
-
checkNamespaceCollision
public static java.lang.String checkNamespaceCollision(Namespace namespace, Element element)
- Parameters:
namespace-Namespaceto check.element-Elementto check against.- Returns:
Stringreason for collision, ornullif no collision.
-
checkNamespaceCollision
public static java.lang.String checkNamespaceCollision(Namespace namespace, Attribute attribute)
- Parameters:
namespace-Namespaceto check.attribute-Attributeto check against.- Returns:
Stringreason for collision, ornullif no collision.
-
checkNamespaceCollision
public static java.lang.String checkNamespaceCollision(Namespace namespace, java.util.List list)
Check if acollides with any namespace from a list of objects.Namespace- Parameters:
namespace-Namespaceto check.list-Listto check against.- Returns:
Stringreason for collision, ornullif no collision.
-
checkProcessingInstructionTarget
public static java.lang.String checkProcessingInstructionTarget(java.lang.String target)
This will check the supplied data to see if it is legal for use as a JDOMtarget.ProcessingInstruction- Parameters:
target-Stringtarget to check.- Returns:
Stringreason target is illegal, ornullif target is OK.
-
checkProcessingInstructionData
public static java.lang.String checkProcessingInstructionData(java.lang.String data)
This will check the supplied data to see if it is legal for use asdata. 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-Stringdata to check.- Returns:
Stringreason data is illegal, ornullif data is OK.
-
checkCommentData
public static java.lang.String checkCommentData(java.lang.String data)
This will check the supplied data to see if it is legal for use as JDOMdata.Comment- Parameters:
data-Stringdata to check.- Returns:
Stringreason data is illegal, ornullif 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)
-
checkPublicID
public static java.lang.String checkPublicID(java.lang.String publicID)
This will ensure that the data for a public identifier is legal.- Parameters:
publicID-Stringpublic ID to check.- Returns:
Stringreason public ID is illegal, ornullif public ID is OK.
-
checkSystemLiteral
public static java.lang.String checkSystemLiteral(java.lang.String systemLiteral)
This will ensure that the data for a system literal is legal.- Parameters:
systemLiteral-Stringsystem literal to check.- Returns:
Stringreason system literal is illegal, ornullif system literal is OK.
-
checkXMLName
public static java.lang.String checkXMLName(java.lang.String name)
This is a utility function for sharing the base process of checking any XML name.- Parameters:
name-Stringto check for XML name compliance.- Returns:
Stringreason the name is illegal, ornullif OK.
-
checkURI
public static java.lang.String checkURI(java.lang.String uri)
Checks a string to see if it is a legal RFC 2396 URI. Both absolute and relative URIs are supported.
- Parameters:
uri-Stringto check.- Returns:
Stringreason the URI is illegal, ornullif 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-charto 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-charto check for XML compliance- Returns:
booleantrue 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-charto check for XML name compliance.- Returns:
booleantrue 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-charto check for XML name start compliance.- Returns:
booleantrue 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-charto check.- Returns:
booleantrue 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-charto check for XML name compliance.- Returns:
Stringtrue 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-charto check.- Returns:
booleantrue 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-charto check.- Returns:
Stringtrue 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-charto check for XML digit compliance- Returns:
booleantrue 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-charto check for XML whitespace compliance- Returns:
booleantrue if it's a whitespace, false otherwise
-
-