org.opensaml
Class XML

java.lang.Object
  extended byorg.opensaml.XML

public class XML
extends Object

Utility classes for XML constants and optimizations

Author:
Scott Cantor, Howard Gilbert

Nested Class Summary
static class XML.ParserPool
          Nested class that provides XML parsers as a pooled resource
 
Field Summary
protected  SAMLConfig config
          OpenSAML configuration
static String OPENSAML_NS
          OpenSAML XML namespace
static XML.ParserPool parserPool
          A global object to manage a pool of custom DOM parsers
static String SAML_ARTIFACT_SOURCEID
           
static String SAML_NS
          SAML XML namespace
static String SAML_SCHEMA_ID
          SAML XML Schema Identifier
static String SAML10_PROTOCOL_ENUM
          SAML 1.x Metadata Profile protocol indicators and namespace
static String SAML11_PROTOCOL_ENUM
           
static String SAML11_SCHEMA_ID
          SAML 1.1 XML Schema Identifier
static String SAMLP_NS
          SAML protocol XML namespace
static String SAMLP_SCHEMA_ID
          SAML protocol XML Schema Identifier
static String SAMLP11_SCHEMA_ID
          SAML 1.1 protocol XML Schema Identifier
static String SOAP11ENV_NS
          SOAP 1.1 Envelope XML namespace
static String SOAP11ENV_SCHEMA_ID
          SOAP 1.1 Envelope Schema Identifier
static String XML_NS
          XML core namespace
static String XML_SCHEMA_ID
          XML core schema identifier
static String XMLNS_NS
          XML namespace for xmlns attributes
static String XMLSIG_NS
          XML Signature namespace
static String XMLSIG_SCHEMA_ID
          XML Signature Schema Identifier
static String XSD_NS
          XML Schema Instance namespace
static String XSI_NS
          XML Schema Instance namespace
 
Constructor Summary
XML()
           
 
Method Summary
static String assign(String s)
          A "safe" assignment function for strings that blocks the empty string
static Element getFirstChildElement(Node n)
          Gets the first child Element of the node, skipping any Text nodes such as whitespace.
static Element getFirstChildElement(Node n, String ns, String localName)
          Gets the first child Element of the node of the given name, skipping any Text nodes such as whitespace.
static Element getLastChildElement(Node n)
          Gets the last child Element of the node, skipping any Text nodes such as whitespace.
static Element getLastChildElement(Node n, String ns, String localName)
          Gets the last child Element of the node of the given name, skipping any Text nodes such as whitespace.
static String getNamespaceForPrefix(String prefix, Element e)
          Gets the XML namespace URI that is mapped to the specified prefix, in the context of the DOM element e
static String getNamespaceForQName(String qname, Element e)
          Gets the XML namespace URI that is mapped to the prefix of a QName, in the context of the DOM element e
static Element getNextSiblingElement(Node n)
          Gets the next sibling Element of the node, skipping any Text nodes such as whitespace.
static Element getNextSiblingElement(Node n, String ns, String localName)
          Gets the next sibling Element of the node of the given name, skipping any Text nodes such as whitespace.
static Element getPreviousSiblingElement(Node n)
          Gets the previous sibling Element of the node, skipping any Text nodes such as whitespace.
static Element getPreviousSiblingElement(Node n, String ns, String localName)
          Gets the previous sibling Element of the node of the given name, skipping any Text nodes such as whitespace.
static QName getQNameAttribute(Element e, String namespace, String name)
          Builds a QName from a QName-valued attribute by evaluating it
static QName getQNameTextNode(Text t)
          Builds a QName from a QName-valued text node by evaluating it
static boolean isElementNamed(Element e, String ns, String localName)
          Shortcut for checking a DOM element node's namespace and local name
static boolean isEmpty(String s)
          A "safe" null/empty check for strings.
static boolean safeCompare(String s1, String s2)
          Compares two strings for equality, allowing for nulls
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

config

protected SAMLConfig config
OpenSAML configuration


XML_NS

public static final String XML_NS
XML core namespace

See Also:
Constant Field Values

XMLNS_NS

public static final String XMLNS_NS
XML namespace for xmlns attributes

See Also:
Constant Field Values

XSI_NS

public static final String XSI_NS
XML Schema Instance namespace

See Also:
Constant Field Values

XSD_NS

public static final String XSD_NS
XML Schema Instance namespace

See Also:
Constant Field Values

OPENSAML_NS

public static final String OPENSAML_NS
OpenSAML XML namespace

See Also:
Constant Field Values

SAML_NS

public static final String SAML_NS
SAML XML namespace

See Also:
Constant Field Values

SAMLP_NS

public static final String SAMLP_NS
SAML protocol XML namespace

See Also:
Constant Field Values

SAML10_PROTOCOL_ENUM

public static final String SAML10_PROTOCOL_ENUM
SAML 1.x Metadata Profile protocol indicators and namespace

See Also:
Constant Field Values

SAML11_PROTOCOL_ENUM

public static final String SAML11_PROTOCOL_ENUM
See Also:
Constant Field Values

SAML_ARTIFACT_SOURCEID

public static final String SAML_ARTIFACT_SOURCEID
See Also:
Constant Field Values

XMLSIG_NS

public static final String XMLSIG_NS
XML Signature namespace

See Also:
Constant Field Values

SOAP11ENV_NS

public static final String SOAP11ENV_NS
SOAP 1.1 Envelope XML namespace

See Also:
Constant Field Values

XML_SCHEMA_ID

public static final String XML_SCHEMA_ID
XML core schema identifier

See Also:
Constant Field Values

SAML_SCHEMA_ID

public static final String SAML_SCHEMA_ID
SAML XML Schema Identifier

See Also:
Constant Field Values

SAMLP_SCHEMA_ID

public static final String SAMLP_SCHEMA_ID
SAML protocol XML Schema Identifier

See Also:
Constant Field Values

SAML11_SCHEMA_ID

public static final String SAML11_SCHEMA_ID
SAML 1.1 XML Schema Identifier

See Also:
Constant Field Values

SAMLP11_SCHEMA_ID

public static final String SAMLP11_SCHEMA_ID
SAML 1.1 protocol XML Schema Identifier

See Also:
Constant Field Values

XMLSIG_SCHEMA_ID

public static final String XMLSIG_SCHEMA_ID
XML Signature Schema Identifier

See Also:
Constant Field Values

SOAP11ENV_SCHEMA_ID

public static final String SOAP11ENV_SCHEMA_ID
SOAP 1.1 Envelope Schema Identifier

See Also:
Constant Field Values

parserPool

public static XML.ParserPool parserPool
A global object to manage a pool of custom DOM parsers

Constructor Detail

XML

public XML()
Method Detail

isEmpty

public static boolean isEmpty(String s)
A "safe" null/empty check for strings.

Parameters:
s - The string to check
Returns:
true iff the string is null or length zero

assign

public static String assign(String s)
A "safe" assignment function for strings that blocks the empty string

Parameters:
s - The string to check
Returns:
s iff the string is non-empty or else null

safeCompare

public static boolean safeCompare(String s1,
                                  String s2)
Compares two strings for equality, allowing for nulls

Parameters:
s1 - The first operand
s2 - The second operand
Returns:
true iff both are null or both are non-null and the same strng value

isElementNamed

public static boolean isElementNamed(Element e,
                                     String ns,
                                     String localName)
Shortcut for checking a DOM element node's namespace and local name

Parameters:
e - An element to compare against
ns - An XML namespace to compare
localName - A local name to compare
Returns:
true iff the element's local name and namespace match the parameters

getFirstChildElement

public static Element getFirstChildElement(Node n)
Gets the first child Element of the node, skipping any Text nodes such as whitespace.

Parameters:
n - The parent in which to search for children
Returns:
The first child Element of n, or null if none

getLastChildElement

public static Element getLastChildElement(Node n)
Gets the last child Element of the node, skipping any Text nodes such as whitespace.

Parameters:
n - The parent in which to search for children
Returns:
The last child Element of n, or null if none

getFirstChildElement

public static Element getFirstChildElement(Node n,
                                           String ns,
                                           String localName)
Gets the first child Element of the node of the given name, skipping any Text nodes such as whitespace.

Parameters:
n - The parent in which to search for children
ns - The namespace URI of the element to locate
localName - The local name of the element to locate
Returns:
The first child Element of n with the specified name, or null if none

getLastChildElement

public static Element getLastChildElement(Node n,
                                          String ns,
                                          String localName)
Gets the last child Element of the node of the given name, skipping any Text nodes such as whitespace.

Parameters:
n - The parent in which to search for children
ns - The namespace URI of the element to locate
localName - The local name of the element to locate
Returns:
The last child Element of n with the specified name, or null if none

getNextSiblingElement

public static Element getNextSiblingElement(Node n)
Gets the next sibling Element of the node, skipping any Text nodes such as whitespace.

Parameters:
n - The sibling to start with
Returns:
The next sibling Element of n, or null if none

getPreviousSiblingElement

public static Element getPreviousSiblingElement(Node n)
Gets the previous sibling Element of the node, skipping any Text nodes such as whitespace.

Parameters:
n - The sibling to start with
Returns:
The previous sibling Element of n, or null if none

getNextSiblingElement

public static Element getNextSiblingElement(Node n,
                                            String ns,
                                            String localName)
Gets the next sibling Element of the node of the given name, skipping any Text nodes such as whitespace.

Parameters:
n - The sibling to start with
ns - The namespace URI of the element to locate
localName - The local name of the element to locate
Returns:
The next sibling Element of n with the specified name, or null if none

getPreviousSiblingElement

public static Element getPreviousSiblingElement(Node n,
                                                String ns,
                                                String localName)
Gets the previous sibling Element of the node of the given name, skipping any Text nodes such as whitespace.

Parameters:
n - The sibling to start with
ns - The namespace URI of the element to locate
localName - The local name of the element to locate
Returns:
The previous sibling Element of n with the specified name, or null if none

getQNameAttribute

public static QName getQNameAttribute(Element e,
                                      String namespace,
                                      String name)
Builds a QName from a QName-valued attribute by evaluating it

Parameters:
e - The element containing the attribute
namespace - The namespace of the attribute
name - The local name of the attribute
Returns:
A QName containing the attribute value as a namespace/local name pair.

getQNameTextNode

public static QName getQNameTextNode(Text t)
Builds a QName from a QName-valued text node by evaluating it

Parameters:
t - The text node containing the QName value
Returns:
A QName containing the text node value as a namespace/local name pair.

getNamespaceForQName

public static String getNamespaceForQName(String qname,
                                          Element e)
Gets the XML namespace URI that is mapped to the prefix of a QName, in the context of the DOM element e

Parameters:
qname - The QName value to map a prefix from
e - The DOM element in which to calculate the prefix binding
Returns:
The XML namespace URI mapped to qname's prefix in the context of e

getNamespaceForPrefix

public static String getNamespaceForPrefix(String prefix,
                                           Element e)
Gets the XML namespace URI that is mapped to the specified prefix, in the context of the DOM element e

Parameters:
prefix - The namespace prefix to map
e - The DOM element in which to calculate the prefix binding
Returns:
The XML namespace URI mapped to prefix in the context of e


Copyright ? 2005 UCAID. All Rights Reserved.