public abstract class AbstractXMLObject extends java.lang.Object implements XMLObject
| Modifier and Type | Field and Description |
|---|---|
private org.w3c.dom.Element |
dom
DOM Element representation of this object.
|
private javax.xml.namespace.QName |
elementQname
The name of this element with namespace and prefix information.
|
private IDIndex |
idIndex
Mapping of ID attributes to XMLObjects in the subtree rooted at this object.
|
private org.slf4j.Logger |
log
Class logger.
|
private XSBooleanValue |
nil
The value of the
xsi:nil attribute. |
private java.lang.String |
noNamespaceSchemaLocation
No-namespace schema locations for this XML object.
|
private NamespaceManager |
nsManager
The namespace manager for this XML object.
|
private net.shibboleth.utilities.java.support.collection.LockableClassToInstanceMultiMap<java.lang.Object> |
objectMetadata
The multimap holding class-indexed instances of additional info associated with this XML object.
|
private XMLObject |
parent
Parent of this element.
|
private java.lang.String |
schemaLocation
Schema locations for this XML object.
|
private javax.xml.namespace.QName |
typeQname
The schema type of this element with namespace and prefix information.
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractXMLObject(java.lang.String namespaceURI,
java.lang.String elementLocalName,
java.lang.String namespacePrefix)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
NamespaceManager |
getNamespaceManager()
Gets the
NamespaceManager instance for this object. |
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.
|
net.shibboleth.utilities.java.support.collection.LockableClassToInstanceMultiMap<java.lang.Object> |
getObjectMetadata()
Get the mutable multimap which holds additional information (represented by plain Java object instances)
associated with this XMLObject.
|
XMLObject |
getParent()
Gets the parent of this element or null if there is no parent.
|
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.
|
java.lang.Boolean |
isNil()
Gets whether the object declares that its element content
is null, which corresponds to an
xsi:nil
attribute of true. |
XSBooleanValue |
isNilXSBoolean()
Gets whether the object declares that its element content
is null, which corresponds to an
xsi:nil
attribute of true. |
protected void |
manageQualifiedAttributeNamespace(javax.xml.namespace.QName attributeName,
boolean hasValue)
A helper function for derived classes.
|
protected javax.xml.namespace.QName |
prepareAttributeValueForAssignment(java.lang.String attributeID,
javax.xml.namespace.QName oldValue,
javax.xml.namespace.QName newValue)
A helper function for derived classes.
|
protected javax.xml.namespace.QName |
prepareElementContentForAssignment(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> |
prepareForAssignment(T oldValue,
T newValue)
A helper function for derived classes, similar to assignString, but for (singleton) XML 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 convenience method that is equal to calling
releaseDOM() then releaseChildrenDOM(boolean)
with the release being propagated. |
void |
releaseThisandParentDOM()
A convenience method that is equal to calling
releaseDOM() then releaseParentDOM(boolean) with
the release being propagated. |
XMLObject |
resolveID(java.lang.String id)
Find the XMLObject 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 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 name)
Sets the element QName.
|
void |
setNil(java.lang.Boolean newNil)
Sets whether the object declares that its element content
is null, which corresponds to an
xsi:nil
attribute of true. |
void |
setNil(XSBooleanValue newNil)
Sets whether the object declares that its element content
is null, which corresponds to an
xsi:nil
attribute of true. |
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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetOrderedChildren@Nonnull private final org.slf4j.Logger log
private XMLObject parent
@Nonnull private javax.xml.namespace.QName elementQname
private java.lang.String schemaLocation
private java.lang.String noNamespaceSchemaLocation
private javax.xml.namespace.QName typeQname
private org.w3c.dom.Element dom
private XSBooleanValue nil
xsi:nil attribute.private NamespaceManager nsManager
@Nonnull private final net.shibboleth.utilities.java.support.collection.LockableClassToInstanceMultiMap<java.lang.Object> objectMetadata
private final IDIndex idIndex
protected AbstractXMLObject(@Nullable
java.lang.String namespaceURI,
@Nonnull @NotEmpty
java.lang.String elementLocalName,
@Nullable
java.lang.String namespacePrefix)
namespaceURI - the namespace the element is inelementLocalName - the local name of the XML element this Object representsnamespacePrefix - the prefix for the given namespacepublic void detach()
@Nullable public org.w3c.dom.Element getDOM()
@Nonnull public javax.xml.namespace.QName getElementQName()
getElementQName in interface XMLObject@Nonnull public IDIndex getIDIndex()
getIDIndex in interface XMLObject@Nonnull public NamespaceManager getNamespaceManager()
NamespaceManager instance for this object.getNamespaceManager in interface XMLObject@Nonnull public java.util.Set<Namespace> getNamespaces()
getNamespaces in interface XMLObject@Nullable public java.lang.String getNoNamespaceSchemaLocation()
getNoNamespaceSchemaLocation in interface XMLObject@Nullable public XMLObject getParent()
@Nullable public java.lang.String getSchemaLocation()
getSchemaLocation in interface XMLObject@Nullable public javax.xml.namespace.QName getSchemaType()
getSchemaType in interface XMLObjectpublic boolean hasChildren()
hasChildren in interface XMLObjectpublic boolean hasParent()
protected void manageQualifiedAttributeNamespace(@Nonnull
javax.xml.namespace.QName attributeName,
boolean hasValue)
attributeName - the attribute namehasValue - true to indicate that the attribute has a value, false to indicate it has no value@Nullable
protected javax.xml.namespace.QName prepareElementContentForAssignment(@Nullable
javax.xml.namespace.QName oldValue,
@Nullable
javax.xml.namespace.QName newValue)
oldValue - - the current valuenewValue - - the new value@Nullable
protected javax.xml.namespace.QName prepareAttributeValueForAssignment(@Nonnull
java.lang.String attributeID,
@Nullable
javax.xml.namespace.QName oldValue,
@Nullable
javax.xml.namespace.QName newValue)
attributeID - - unique identifier of the attribute in the content model within this XMLObject, used to
identify the attribute within the XMLObject's NamespaceManageroldValue - - the current valuenewValue - - the new value@Nullable
protected java.lang.String prepareForAssignment(@Nullable
java.lang.String oldValue,
@Nullable
java.lang.String newValue)
oldValue - - the current valuenewValue - - the new value@Nullable
protected <T> T prepareForAssignment(@Nullable
T oldValue,
@Nullable
T newValue)
this.foo = prepareForAssignment(this.foo, foo);
This method will do a (null) safe compare of the objects and will also invalidate the DOM if appropriateT - - type of object being compared and assignedoldValue - - current valuenewValue - - proposed new value@Nullable protected <T extends XMLObject> T prepareForAssignment(@Nullable T oldValue, @Nullable T newValue)
this.foo = prepareForAssignment(this.foo, foo);
This method will do a (null) safe compare of the objects and will also invalidate the DOM if appropriateT - type of object being compared and assignedoldValue - current valuenewValue - proposed new valueprotected void registerOwnID(@Nullable
java.lang.String oldID,
@Nullable
java.lang.String newID)
oldID - the old value of the ID-typed attributenewID - the new value of the ID-typed attributepublic void releaseChildrenDOM(boolean propagateRelease)
releaseChildrenDOM in interface XMLObjectpropagateRelease - true if all descendants of this element should release their DOMpublic void releaseDOM()
releaseDOM in interface XMLObjectpublic void releaseParentDOM(boolean propagateRelease)
releaseParentDOM in interface XMLObjectpropagateRelease - true if all ancestors of this element should release their DOMpublic void releaseThisAndChildrenDOM()
releaseDOM() then releaseChildrenDOM(boolean)
with the release being propagated.public void releaseThisandParentDOM()
releaseDOM() then releaseParentDOM(boolean) with
the release being propagated.@Nullable public XMLObject resolveID(@Nonnull @NotEmpty java.lang.String id)
@Nullable public XMLObject resolveIDFromRoot(@Nonnull @NotEmpty java.lang.String id)
resolveIDFromRoot in interface XMLObjectid - the ID attribute to resolve to an XMLObjectpublic void setDOM(@Nullable
org.w3c.dom.Element newDom)
public void setElementNamespacePrefix(@Nullable
java.lang.String prefix)
prefix - the prefix for this element's namespaceprotected void setElementQName(@Nonnull
javax.xml.namespace.QName name)
name - the element's QNamepublic void setNoNamespaceSchemaLocation(@Nullable
java.lang.String location)
setNoNamespaceSchemaLocation in interface XMLObjectlocation - value of the XML Schema noNamespaceSchemaLocation attribute for this objectpublic void setParent(@Nullable
XMLObject newParent)
public void setSchemaLocation(@Nullable
java.lang.String location)
setSchemaLocation in interface XMLObjectlocation - value of the XML Schema schemaLocation attribute for this objectprotected void setSchemaType(@Nullable
javax.xml.namespace.QName type)
type - the schema typepublic java.lang.Boolean isNil()
xsi:nil
attribute of true.
Note that it is up to the developer to ensure that the value of this attribute is consistent with the actual element content on the object instance.
Per the XML Schema specification, a value of true disallows element content, but not element attributes.
public XSBooleanValue isNilXSBoolean()
xsi:nil
attribute of true.
Note that it is up to the developer to ensure that the value of this attribute is consistent with the actual element content on the object instance.
Per the XML Schema specification, a value of true disallows element content, but not element attributes.
isNilXSBoolean in interface XMLObjectpublic void setNil(@Nullable
java.lang.Boolean newNil)
xsi:nil
attribute of true.
Note that it is up to the developer to ensure that the value of this attribute is consistent with the actual element content on the object instance.
Per the XML Schema specification, a value of true disallows element content, but not element attributes.
setNil in interface XMLObjectnewNil - whether the object's content model is expressed as nullpublic void setNil(@Nullable
XSBooleanValue newNil)
xsi:nil
attribute of true.
Note that it is up to the developer to ensure that the value of this attribute is consistent with the actual element content on the object instance.
Per the XML Schema specification, a value of true disallows element content, but not element attributes.
setNil in interface XMLObjectnewNil - whether the object's content model is expressed as null@Nonnull public net.shibboleth.utilities.java.support.collection.LockableClassToInstanceMultiMap<java.lang.Object> getObjectMetadata()
Objects added to this multimap will be indexed and retrievable by their concrete Class
as well as by the Class types representing all superclasses (excluding java.lang.Object)
and all implemented interfaces.
getObjectMetadata in interface XMLObject