org.apache.xml.security.utils
Class ElementProxy

java.lang.Object
  extended byorg.apache.xml.security.utils.ElementProxy
Direct Known Subclasses:
EncryptionElementProxy, InclusiveNamespaces, SignatureElementProxy, XPath2FilterContainer, XPath2FilterContainer04, XPathFilterCHGPContainer

public abstract class ElementProxy
extends java.lang.Object

This is the base class to all Objects which have a direct 1:1 mapping to an Element in a particular namespace.

Author:
$Author: lajoie $

Field Summary
protected  java.lang.String _baseURI
          Field _baseURI
protected  org.w3c.dom.Element _constructionElement
          Field _constructionElement
protected  org.w3c.dom.Document _doc
          Field _doc
 
Constructor Summary
ElementProxy()
          Constructor ElementProxy
ElementProxy(org.w3c.dom.Document doc)
          Constructor ElementProxy
ElementProxy(org.w3c.dom.Element element, java.lang.String BaseURI)
          Constructor ElementProxy
 
Method Summary
 void addBase64Element(byte[] bytes, java.lang.String localname)
          Method addBase64Element
 void addBase64Text(byte[] bytes)
          Method addBase64Text
 void addBigIntegerElement(java.math.BigInteger bi, java.lang.String localname)
          Method setVal
 void addText(java.lang.String text)
          Method addText
 void addTextElement(java.lang.String text, java.lang.String localname)
          Method addTextElement
static org.w3c.dom.Element createElementForFamily(org.w3c.dom.Document doc, java.lang.String namespace, java.lang.String localName)
          This method creates an Element in a given namespace with a given localname.
protected  org.w3c.dom.Element createElementForFamilyLocal(org.w3c.dom.Document doc, java.lang.String namespace, java.lang.String localName)
           
abstract  java.lang.String getBaseLocalName()
          Returns the localname of the Elements of the sub-class.
abstract  java.lang.String getBaseNamespace()
          Returns the namespace of the Elements of the sub-class.
 java.lang.String getBaseURI()
          Method getBaseURI
 java.math.BigInteger getBigIntegerFromChildElement(java.lang.String localname, java.lang.String namespace)
          Method getVal
 byte[] getBytesFromChildElement(java.lang.String localname, java.lang.String namespace)
          Deprecated.  
 byte[] getBytesFromTextChild()
          Method getBytesFromTextChild
static java.lang.String getDefaultPrefix(java.lang.String namespace)
          Method getDefaultPrefix
static java.lang.String getDefaultPrefixBindings(java.lang.String namespace)
           
 org.w3c.dom.Document getDocument()
          Method getDocument
 org.w3c.dom.Element getElement()
          Returns the Element which was constructed by the Object.
 org.w3c.dom.NodeList getElementPlusReturns()
          Returns the Element plus a leading and a trailing CarriageReturn Text node.
 java.lang.String getTextFromChildElement(java.lang.String localname, java.lang.String namespace)
          Method getTextFromChildElement
 java.lang.String getTextFromTextChild()
          Method getTextFromTextChild
 int length(java.lang.String namespace, java.lang.String localname)
          Method length
static void setDefaultPrefix(java.lang.String namespace, java.lang.String prefix)
          Method setDefaultPrefix
 void setElement(org.w3c.dom.Element element, java.lang.String BaseURI)
          Method setElement
 void setXPathNamespaceContext(java.lang.String prefix, java.lang.String uri)
          Adds an xmlns: definition to the Element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_constructionElement

protected org.w3c.dom.Element _constructionElement
Field _constructionElement


_baseURI

protected java.lang.String _baseURI
Field _baseURI


_doc

protected org.w3c.dom.Document _doc
Field _doc

Constructor Detail

ElementProxy

public ElementProxy()
Constructor ElementProxy


ElementProxy

public ElementProxy(org.w3c.dom.Document doc)
Constructor ElementProxy

Parameters:
doc -

ElementProxy

public ElementProxy(org.w3c.dom.Element element,
                    java.lang.String BaseURI)
             throws XMLSecurityException
Constructor ElementProxy

Parameters:
element -
BaseURI -
Throws:
XMLSecurityException
Method Detail

getBaseNamespace

public abstract java.lang.String getBaseNamespace()
Returns the namespace of the Elements of the sub-class.

Returns:
the namespace of the Elements of the sub-class.

getBaseLocalName

public abstract java.lang.String getBaseLocalName()
Returns the localname of the Elements of the sub-class.

Returns:
the localname of the Elements of the sub-class.

createElementForFamilyLocal

protected org.w3c.dom.Element createElementForFamilyLocal(org.w3c.dom.Document doc,
                                                          java.lang.String namespace,
                                                          java.lang.String localName)

createElementForFamily

public static org.w3c.dom.Element createElementForFamily(org.w3c.dom.Document doc,
                                                         java.lang.String namespace,
                                                         java.lang.String localName)
This method creates an Element in a given namespace with a given localname. It uses the getDefaultPrefix(java.lang.String) method to decide whether a particular prefix is bound to that namespace.
This method was refactored out of the constructor.

Parameters:
doc -
namespace -
localName -
Returns:
The element created.

setElement

public void setElement(org.w3c.dom.Element element,
                       java.lang.String BaseURI)
                throws XMLSecurityException
Method setElement

Parameters:
element -
BaseURI -
Throws:
XMLSecurityException

getElement

public final org.w3c.dom.Element getElement()
Returns the Element which was constructed by the Object.

Returns:
the Element which was constructed by the Object.

getElementPlusReturns

public final org.w3c.dom.NodeList getElementPlusReturns()
Returns the Element plus a leading and a trailing CarriageReturn Text node.

Returns:
the Element which was constructed by the Object.

getDocument

public org.w3c.dom.Document getDocument()
Method getDocument

Returns:
the Document where this element is contained.

getBaseURI

public java.lang.String getBaseURI()
Method getBaseURI

Returns:
the base uri of the namespace of this element

addBigIntegerElement

public void addBigIntegerElement(java.math.BigInteger bi,
                                 java.lang.String localname)
Method setVal

Parameters:
bi -
localname -

addBase64Element

public void addBase64Element(byte[] bytes,
                             java.lang.String localname)
Method addBase64Element

Parameters:
bytes -
localname -

addTextElement

public void addTextElement(java.lang.String text,
                           java.lang.String localname)
Method addTextElement

Parameters:
text -
localname -

addBase64Text

public void addBase64Text(byte[] bytes)
Method addBase64Text

Parameters:
bytes -

addText

public void addText(java.lang.String text)
Method addText

Parameters:
text -

getBigIntegerFromChildElement

public java.math.BigInteger getBigIntegerFromChildElement(java.lang.String localname,
                                                          java.lang.String namespace)
                                                   throws Base64DecodingException
Method getVal

Parameters:
localname -
namespace -
Returns:
The biginter contained in the given element
Throws:
Base64DecodingException

getBytesFromChildElement

public byte[] getBytesFromChildElement(java.lang.String localname,
                                       java.lang.String namespace)
                                throws XMLSecurityException
Deprecated.  

Method getBytesFromChildElement

Parameters:
localname -
namespace -
Returns:
the bytes
Throws:
XMLSecurityException

getTextFromChildElement

public java.lang.String getTextFromChildElement(java.lang.String localname,
                                                java.lang.String namespace)
Method getTextFromChildElement

Parameters:
localname -
namespace -
Returns:
the Text of the textNode

getBytesFromTextChild

public byte[] getBytesFromTextChild()
                             throws XMLSecurityException
Method getBytesFromTextChild

Returns:
The base64 bytes from the text children of this element
Throws:
XMLSecurityException

getTextFromTextChild

public java.lang.String getTextFromTextChild()
Method getTextFromTextChild

Returns:
the Text obtained by concatenating all the text nodes of this element

length

public int length(java.lang.String namespace,
                  java.lang.String localname)
Method length

Parameters:
namespace -
localname -
Returns:
the number of elements {namespace}:localname under this element

setXPathNamespaceContext

public void setXPathNamespaceContext(java.lang.String prefix,
                                     java.lang.String uri)
                              throws XMLSecurityException
Adds an xmlns: definition to the Element. This can be called as follows:
 // set namespace with ds prefix
 xpathContainer.setXPathNamespaceContext("ds", "http://www.w3.org/2000/09/xmldsig#");
 xpathContainer.setXPathNamespaceContext("xmlns:ds", "http://www.w3.org/2000/09/xmldsig#");
 

Parameters:
prefix -
uri -
Throws:
XMLSecurityException

setDefaultPrefix

public static void setDefaultPrefix(java.lang.String namespace,
                                    java.lang.String prefix)
                             throws XMLSecurityException
Method setDefaultPrefix

Parameters:
namespace -
prefix -
Throws:
XMLSecurityException

getDefaultPrefix

public static java.lang.String getDefaultPrefix(java.lang.String namespace)
Method getDefaultPrefix

Parameters:
namespace -
Returns:
the default prefix bind to this element.

getDefaultPrefixBindings

public static java.lang.String getDefaultPrefixBindings(java.lang.String namespace)