org.opensaml.xml
Class AbstractXMLObject

java.lang.Object
  extended by org.opensaml.xml.AbstractXMLObject
All Implemented Interfaces:
XMLObject
Direct Known Subclasses:
AbstractSignableXMLObject, AbstractValidatingXMLObject, SignatureImpl

public abstract class AbstractXMLObject
extends java.lang.Object
implements XMLObject

An abstract implementation of XMLObject.


Constructor Summary
protected AbstractXMLObject(java.lang.String namespaceURI, java.lang.String elementLocalName, java.lang.String namespacePrefix)
          Constructor.
 
Method Summary
 void addNamespace(Namespace namespace)
          Adds a namespace to the ones already scoped to this element.
 void detach()
          Detaches the XMLObject from its parent.
 org.w3c.dom.Element getDOM()
          Gets the DOM representation of this XMLObject, if one exists.
 javax.xml.namespace.QName getElementQName()
          Gets the QName for this element.
 IDIndex getIDIndex()
          Get the IDIndex holding the ID-to-XMLObject index mapping, rooted at this XMLObject's subtree.
 java.util.Set<Namespace> getNamespaces()
          Gets the namespaces that are scoped to this element.
 java.lang.String getNoNamespaceSchemaLocation()
          Gets the value of the XML Schema noNamespaceSchemaLocation attribute for this object.
 XMLObject getParent()
          Gets the parent of this element.
 java.lang.String getSchemaLocation()
          Gets the value of the XML Schema schemaLocation attribute for this object.
 javax.xml.namespace.QName getSchemaType()
          Gets the XML schema type of this element.
 boolean hasChildren()
          Checks if this XMLObject has children.
 boolean hasParent()
          Checks to see if this object has a parent.
protected  javax.xml.namespace.QName prepareForAssignment(javax.xml.namespace.QName oldValue, javax.xml.namespace.QName newValue)
          A helper function for derived classes.
protected  java.lang.String prepareForAssignment(java.lang.String oldValue, java.lang.String newValue)
          A helper function for derived classes.
protected
<T> T
prepareForAssignment(T oldValue, T newValue)
          A helper function for derived classes that checks to see if the old and new value are equal and if so releases the cached dom.
protected
<T extends XMLObject>
T
prepareForAssignment(T oldValue, T newValue)
          A helper function for derived classes, similar to assignString, but for (singleton) SAML objects.
protected  void registerOwnID(java.lang.String oldID, java.lang.String newID)
          A helper function for derived classes.
 void releaseChildrenDOM(boolean propagateRelease)
          Releases the DOM representation of this XMLObject's children.
 void releaseDOM()
          Releases the DOM representation of this XMLObject, if there is one.
 void releaseParentDOM(boolean propagateRelease)
          Releases the DOM representation of this XMLObject's parent.
 void releaseThisAndChildrenDOM()
          A convience method that is equal to calling releaseDOM() then releaseChildrenDOM(boolean) with the release being propogated.
 void releaseThisandParentDOM()
          A convience method that is equal to calling releaseDOM() then releaseParentDOM(boolean) with the release being propogated.
 void removeNamespace(Namespace namespace)
          Removes a namespace from this element.
 XMLObject resolveID(java.lang.String id)
          Find the XMLObject which is identified by the specified ID attribute, within the subtree of XMLObjects which has this XMLObject as its root.
 XMLObject resolveIDFromRoot(java.lang.String id)
          Find the XMLObject which is identified by the specified ID attribute, from the root of the tree of XMLObjects in which this XMLObject is a member.
 void setDOM(org.w3c.dom.Element newDom)
          Sets the DOM representation of this XMLObject.
 void setElementNamespacePrefix(java.lang.String prefix)
          Sets the prefix for this element's namespace.
protected  void setElementQName(javax.xml.namespace.QName elementQName)
          Sets the element QName.
 void setNoNamespaceSchemaLocation(java.lang.String location)
          Sets the value of the XML Schema noNamespaceSchemaLocation attribute for this object.
 void setParent(XMLObject newParent)
          Sets the parent of this element.
 void setSchemaLocation(java.lang.String location)
          Sets the value of the XML Schema schemaLocation attribute for this object.
protected  void setSchemaType(javax.xml.namespace.QName type)
          Sets a given QName as the schema type for the Element represented by this XMLObject.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.opensaml.xml.XMLObject
getOrderedChildren
 

Constructor Detail

AbstractXMLObject

protected AbstractXMLObject(java.lang.String namespaceURI,
                            java.lang.String elementLocalName,
                            java.lang.String namespacePrefix)
Constructor.

Parameters:
namespaceURI - the namespace the element is in
elementLocalName - the local name of the XML element this Object represents
namespacePrefix - the prefix for the given namespace
Method Detail

addNamespace

public void addNamespace(Namespace namespace)
Adds a namespace to the ones already scoped to this element.

Specified by:
addNamespace in interface XMLObject
Parameters:
namespace - the namespace to add

detach

public void detach()
Detaches the XMLObject from its parent. This will release the parent's cached DOM (if it has one) and set this object's parent to null. It does not remove this object from its parent, that's the responsibility of the invoker of this method, nor does it re-root the cached DOM node (if there is one) in a new document. This is handled at marshalling time.

Specified by:
detach in interface XMLObject

getDOM

public org.w3c.dom.Element getDOM()
Gets the DOM representation of this XMLObject, if one exists.

Specified by:
getDOM in interface XMLObject
Returns:
the DOM representation of this XMLObject

getElementQName

public javax.xml.namespace.QName getElementQName()
Gets the QName for this element. This QName MUST contain the namespace URI, namespace prefix, and local element name. Changes made to the returned QName are not reflected by the QName held by this element, that is, the returned QName is a copy of the internal QName member of this class.

Specified by:
getElementQName in interface XMLObject
Returns:
the QName for this attribute

getIDIndex

public IDIndex getIDIndex()
Get the IDIndex holding the ID-to-XMLObject index mapping, rooted at this XMLObject's subtree.

Specified by:
getIDIndex in interface XMLObject
Returns:
the IDIndex owned by this XMLObject

getNamespaces

public java.util.Set<Namespace> getNamespaces()
Gets the namespaces that are scoped to this element.

Specified by:
getNamespaces in interface XMLObject
Returns:
the namespaces that are scoped to this element

getNoNamespaceSchemaLocation

public java.lang.String getNoNamespaceSchemaLocation()
Gets the value of the XML Schema noNamespaceSchemaLocation attribute for this object.

Specified by:
getNoNamespaceSchemaLocation in interface XMLObject
Returns:
value of the XML Schema noNamespaceSchemaLocation attribute for this object

getParent

public XMLObject getParent()
Gets the parent of this element.

Specified by:
getParent in interface XMLObject
Returns:
the parent of this element

getSchemaLocation

public java.lang.String getSchemaLocation()
Gets the value of the XML Schema schemaLocation attribute for this object.

Specified by:
getSchemaLocation in interface XMLObject
Returns:
schema location defined for this object

getSchemaType

public javax.xml.namespace.QName getSchemaType()
Gets the XML schema type of this element. This translates to contents the xsi:type attribute for the element.

Specified by:
getSchemaType in interface XMLObject
Returns:
XML schema type of this element

hasChildren

public boolean hasChildren()
Checks if this XMLObject has children.

Specified by:
hasChildren in interface XMLObject
Returns:
true if this XMLObject has children, false if not

hasParent

public boolean hasParent()
Checks to see if this object has a parent.

Specified by:
hasParent in interface XMLObject
Returns:
true if the object has a parent, false if not

prepareForAssignment

protected javax.xml.namespace.QName prepareForAssignment(javax.xml.namespace.QName oldValue,
                                                         javax.xml.namespace.QName newValue)
A helper function for derived classes. This checks for semantic equality between two QNames if it they are different invalidates the DOM. It returns the normalized value so subclasses just have to go. this.foo = prepareForAssignment(this.foo, foo);

Parameters:
oldValue - - the current value
newValue - - the new value
Returns:
the value that should be assigned

prepareForAssignment

protected java.lang.String prepareForAssignment(java.lang.String oldValue,
                                                java.lang.String newValue)
A helper function for derived classes. This 'nornmalizes' newString and then if it is different from oldString invalidates the DOM. It returns the normalized value so subclasses just have to go. this.foo = prepareForAssignment(this.foo, foo);

Parameters:
oldValue - - the current value
newValue - - the new value
Returns:
the value that should be assigned

prepareForAssignment

protected <T> T prepareForAssignment(T oldValue,
                                     T newValue)
A helper function for derived classes that checks to see if the old and new value are equal and if so releases the cached dom. Derived classes are expected to use this thus: this.foo = prepareForAssignment(this.foo, foo); This method will do a (null) safe compare of the objects and will also invalidate the DOM if appropriate

Type Parameters:
T - - type of object being compared and assigned
Parameters:
oldValue - - current value
newValue - - proposed new value
Returns:
The value to assign to the saved Object.

prepareForAssignment

protected <T extends XMLObject> T prepareForAssignment(T oldValue,
                                                       T newValue)
A helper function for derived classes, similar to assignString, but for (singleton) SAML objects. It is indifferent to whether either the old or the new version of the value is null. Derived classes are expected to use this thus: this.foo = prepareForAssignment(this.foo, foo); This method will do a (null) safe compare of the objects and will also invalidate the DOM if appropriate

Type Parameters:
T - type of object being compared and assigned
Parameters:
oldValue - current value
newValue - proposed new value
Returns:
The value to assign to the saved Object.

registerOwnID

protected void registerOwnID(java.lang.String oldID,
                             java.lang.String newID)
A helper function for derived classes. The mutator/setter method for any ID-typed attributes should call this method in order to handle getting the old value removed from the ID-to-XMLObject mapping, and the new value added to the mapping.

Parameters:
oldID - the old value of the ID-typed attribute
newID - the new value of the ID-typed attribute

releaseChildrenDOM

public void releaseChildrenDOM(boolean propagateRelease)
Releases the DOM representation of this XMLObject's children.

Specified by:
releaseChildrenDOM in interface XMLObject
Parameters:
propagateRelease - true if all descendants of this element should release their DOM

releaseDOM

public void releaseDOM()
Releases the DOM representation of this XMLObject, if there is one.

Specified by:
releaseDOM in interface XMLObject

releaseParentDOM

public void releaseParentDOM(boolean propagateRelease)
Releases the DOM representation of this XMLObject's parent.

Specified by:
releaseParentDOM in interface XMLObject
Parameters:
propagateRelease - true if all ancestors of this element should release their DOM

releaseThisAndChildrenDOM

public void releaseThisAndChildrenDOM()
A convience method that is equal to calling releaseDOM() then releaseChildrenDOM(boolean) with the release being propogated.


releaseThisandParentDOM

public void releaseThisandParentDOM()
A convience method that is equal to calling releaseDOM() then releaseParentDOM(boolean) with the release being propogated.


removeNamespace

public void removeNamespace(Namespace namespace)
Removes a namespace from this element.

Specified by:
removeNamespace in interface XMLObject
Parameters:
namespace - the namespace to remove

resolveID

public XMLObject resolveID(java.lang.String id)
Find the XMLObject which is identified by the specified ID attribute, within the subtree of XMLObjects which has this XMLObject as its root.

Specified by:
resolveID in interface XMLObject
Parameters:
id - the ID attribute to resolve to an XMLObject
Returns:
the XMLObject identified by the specified ID attribute value

resolveIDFromRoot

public XMLObject resolveIDFromRoot(java.lang.String id)
Find the XMLObject which is identified by the specified ID attribute, from the root of the tree of XMLObjects in which this XMLObject is a member.

Specified by:
resolveIDFromRoot in interface XMLObject
Parameters:
id - the ID attribute to resolve to an XMLObject
Returns:
the XMLObject identified by the specified ID attribute value

setDOM

public void setDOM(org.w3c.dom.Element newDom)
Sets the DOM representation of this XMLObject.

Specified by:
setDOM in interface XMLObject
Parameters:
newDom - DOM representation of this XMLObject

setElementNamespacePrefix

public void setElementNamespacePrefix(java.lang.String prefix)
Sets the prefix for this element's namespace.

Parameters:
prefix - the prefix for this element's namespace

setElementQName

protected void setElementQName(javax.xml.namespace.QName elementQName)
Sets the element QName.

Parameters:
elementQName - the element's QName

setNoNamespaceSchemaLocation

public void setNoNamespaceSchemaLocation(java.lang.String location)
Sets the value of the XML Schema noNamespaceSchemaLocation attribute for this object.

Specified by:
setNoNamespaceSchemaLocation in interface XMLObject
Parameters:
location - value of the XML Schema noNamespaceSchemaLocation attribute for this object

setParent

public void setParent(XMLObject newParent)
Sets the parent of this element.

Specified by:
setParent in interface XMLObject
Parameters:
newParent - the parent of this element

setSchemaLocation

public void setSchemaLocation(java.lang.String location)
Sets the value of the XML Schema schemaLocation attribute for this object.

Specified by:
setSchemaLocation in interface XMLObject
Parameters:
location - value of the XML Schema schemaLocation attribute for this object

setSchemaType

protected void setSchemaType(javax.xml.namespace.QName type)
Sets a given QName as the schema type for the Element represented by this XMLObject. This will add the namespace to the list of namespaces scoped for this XMLObject. It will not remove any namespaces, for example, if there is already a schema type set and null is passed in.

Parameters:
type - the schema type


Copyright © 2006-2011 Internet2. All Rights Reserved.