org.apache.xml.security.utils
Class ElementProxy

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

public abstract class ElementProxy
extends Object

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


Field Summary
protected  String baseURI
          Field baseURI
protected static org.slf4j.Logger log
           
 
Constructor Summary
ElementProxy()
          Constructor ElementProxy
ElementProxy(Document doc)
          Constructor ElementProxy
ElementProxy(Element element, String BaseURI)
          Constructor ElementProxy
 
Method Summary
 void addBase64Element(byte[] bytes, String localname)
          Method addBase64Element
 void addBase64Text(byte[] bytes)
          Method addBase64Text
 void addBigIntegerElement(BigInteger bi, String localname)
          Method addBigIntegerElement
protected  void addReturnToSelf()
           
 void addText(String text)
          Method addText
 void addTextElement(String text, String localname)
          Method addTextElement
protected  void appendOther(Element parent, Node toAppend)
           
protected  void appendSelf(ElementProxy toAppend)
           
protected  void appendSelf(Node toAppend)
           
static Element createElementForFamily(Document doc, String namespace, String localName)
          This method creates an Element in a given namespace with a given localname.
protected  Element createElementForFamilyLocal(String namespace, String localName)
           
protected  Text createText(String text)
           
abstract  String getBaseLocalName()
          Returns the localname of the Elements of the sub-class.
abstract  String getBaseNamespace()
          Returns the namespace of the Elements of the sub-class.
 String getBaseURI()
          Method getBaseURI
 BigInteger getBigIntegerFromChildElement(String localname, String namespace)
          Method getVal
 byte[] getBytesFromTextChild()
          Method getBytesFromTextChild
static String getDefaultPrefix(String namespace)
          Method getDefaultPrefix
 Document getDocument()
          Method getDocument
 Element getElement()
          Returns the Element which was constructed by the Object.
 NodeList getElementPlusReturns()
          Returns the Element plus a leading and a trailing CarriageReturn Text node.
protected  Node getFirstChild()
           
protected  String getLocalAttribute(String attrName)
           
 String getTextFromChildElement(String localname, String namespace)
          Method getTextFromChildElement
 String getTextFromTextChild()
          Method getTextFromTextChild
 int length(String namespace, String localname)
          Method length
static void registerDefaultPrefixes()
          This method registers the default prefixes.
static void setDefaultPrefix(String namespace, String prefix)
          Method setDefaultPrefix
protected  void setDocument(Document doc)
          Set a new value for the wrapped document that this object is a proxy for.
protected  void setElement(Element elem)
          New value for the wrapped XML element that this object is a proxy for.
 void setElement(Element element, String BaseURI)
          Method setElement
protected  void setLocalAttribute(String attrName, String value)
           
protected  void setLocalIdAttribute(String attrName, String value)
           
 void setXPathNamespaceContext(String prefix, 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

log

protected static final org.slf4j.Logger log

baseURI

protected String baseURI
Field baseURI

Constructor Detail

ElementProxy

public ElementProxy()
Constructor ElementProxy


ElementProxy

public ElementProxy(Document doc)
Constructor ElementProxy

Parameters:
doc -

ElementProxy

public ElementProxy(Element element,
                    String BaseURI)
             throws XMLSecurityException
Constructor ElementProxy

Parameters:
element -
BaseURI -
Throws:
XMLSecurityException
Method Detail

getBaseNamespace

public abstract 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 String getBaseLocalName()
Returns the localname of the Elements of the sub-class.

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

createElementForFamilyLocal

protected Element createElementForFamilyLocal(String namespace,
                                              String localName)

createElementForFamily

public static Element createElementForFamily(Document doc,
                                             String namespace,
                                             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(Element element,
                       String BaseURI)
                throws XMLSecurityException
Method setElement

Parameters:
element -
BaseURI -
Throws:
XMLSecurityException

getElement

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

Returns:
the Element which was constructed by the Object.

getElementPlusReturns

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

Returns:
the Element which was constructed by the Object.

createText

protected Text createText(String text)

getDocument

public Document getDocument()
Method getDocument

Returns:
the Document where this element is contained.

getBaseURI

public String getBaseURI()
Method getBaseURI

Returns:
the base uri of the namespace of this element

addBigIntegerElement

public void addBigIntegerElement(BigInteger bi,
                                 String localname)
Method addBigIntegerElement

Parameters:
bi -
localname -

addReturnToSelf

protected void addReturnToSelf()

addBase64Element

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

Parameters:
bytes -
localname -

addTextElement

public void addTextElement(String text,
                           String localname)
Method addTextElement

Parameters:
text -
localname -

addBase64Text

public void addBase64Text(byte[] bytes)
Method addBase64Text

Parameters:
bytes -

appendSelf

protected void appendSelf(ElementProxy toAppend)

appendSelf

protected void appendSelf(Node toAppend)

appendOther

protected void appendOther(Element parent,
                           Node toAppend)

addText

public void addText(String text)
Method addText

Parameters:
text -

getBigIntegerFromChildElement

public BigInteger getBigIntegerFromChildElement(String localname,
                                                String namespace)
                                         throws Base64DecodingException
Method getVal

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

getTextFromChildElement

public String getTextFromChildElement(String localname,
                                      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 String getTextFromTextChild()
Method getTextFromTextChild

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

length

public int length(String namespace,
                  String localname)
Method length

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

setXPathNamespaceContext

public void setXPathNamespaceContext(String prefix,
                                     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(String namespace,
                                    String prefix)
                             throws XMLSecurityException
Method setDefaultPrefix

Parameters:
namespace -
prefix -
Throws:
XMLSecurityException

registerDefaultPrefixes

public static void registerDefaultPrefixes()
                                    throws XMLSecurityException
This method registers the default prefixes.

Throws:
XMLSecurityException

getDefaultPrefix

public static String getDefaultPrefix(String namespace)
Method getDefaultPrefix

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

setElement

protected void setElement(Element elem)
New value for the wrapped XML element that this object is a proxy for.

Parameters:
elem - New element
See Also:
getElement()

setDocument

protected void setDocument(Document doc)
Set a new value for the wrapped document that this object is a proxy for.

Parameters:
doc - New document object being wrapped.
See Also:
getDocument()

getLocalAttribute

protected String getLocalAttribute(String attrName)

setLocalAttribute

protected void setLocalAttribute(String attrName,
                                 String value)

setLocalIdAttribute

protected void setLocalIdAttribute(String attrName,
                                   String value)

getFirstChild

protected Node getFirstChild()


Copyright © 2000–2014 The Apache Software Foundation. All rights reserved.