public abstract class AbstractXMLObject extends Object implements XMLObject
Modifier and Type | Field and Description |
---|---|
private Element |
dom
DOM Element representation of this object.
|
private 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 String |
noNamespaceSchemaLocation
No-namespace schema locations for this XML object.
|
private NamespaceManager |
nsManager
The namespace manager for this XML object.
|
private LockableClassToInstanceMultiMap<Object> |
objectMetadata
The multimap holding class-indexed instances of additional info associated with this XML object.
|
private XMLObject |
parent
Parent of this element.
|
private String |
schemaLocation
Schema locations for this XML object.
|
private QName |
typeQname
The schema type of this element with namespace and prefix information.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractXMLObject(String namespaceURI,
String elementLocalName,
String namespacePrefix)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
detach()
Detaches the XMLObject from its parent.
|
Element |
getDOM()
Gets the DOM representation of this XMLObject, if one exists.
|
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. |
Set<Namespace> |
getNamespaces()
Gets the namespaces that are scoped to this element.
|
String |
getNoNamespaceSchemaLocation()
Gets the value of the XML Schema noNamespaceSchemaLocation attribute for this object.
|
LockableClassToInstanceMultiMap<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.
|
String |
getSchemaLocation()
Gets the value of the XML Schema schemaLocation attribute for this object.
|
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.
|
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(QName attributeName,
boolean hasValue)
A helper function for derived classes.
|
protected QName |
prepareAttributeValueForAssignment(String attributeID,
QName oldValue,
QName newValue)
A helper function for derived classes.
|
protected QName |
prepareElementContentForAssignment(QName oldValue,
QName newValue)
A helper function for derived classes.
|
protected String |
prepareForAssignment(String oldValue,
String newValue)
A helper function for derived classes.
|
protected String |
prepareForAssignment(String oldValue,
String newValue,
boolean normalize)
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(String oldID,
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(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(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(Element newDom)
Sets the DOM representation of this XMLObject.
|
void |
setElementNamespacePrefix(String prefix)
Sets the prefix for this element's namespace.
|
protected void |
setElementQName(QName name)
Sets the element QName.
|
void |
setNil(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(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(String location)
Sets the value of the XML Schema schemaLocation attribute for this object.
|
protected void |
setSchemaType(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, wait
getOrderedChildren
@Nonnull private final org.slf4j.Logger log
private XMLObject parent
@Nonnull private QName elementQname
private String schemaLocation
private String noNamespaceSchemaLocation
private QName typeQname
private Element dom
private XSBooleanValue nil
xsi:nil
attribute.private NamespaceManager nsManager
@Nonnull private final LockableClassToInstanceMultiMap<Object> objectMetadata
private final IDIndex idIndex
protected AbstractXMLObject(@Nullable String namespaceURI, @Nonnull@NotEmpty String elementLocalName, @Nullable 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 Element getDOM()
@Nonnull public 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 Set<Namespace> getNamespaces()
getNamespaces
in interface XMLObject
@Nullable public String getNoNamespaceSchemaLocation()
getNoNamespaceSchemaLocation
in interface XMLObject
@Nullable public XMLObject getParent()
@Nullable public String getSchemaLocation()
getSchemaLocation
in interface XMLObject
@Nullable public QName getSchemaType()
getSchemaType
in interface XMLObject
public boolean hasChildren()
hasChildren
in interface XMLObject
public boolean hasParent()
protected void manageQualifiedAttributeNamespace(@Nonnull 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 QName prepareElementContentForAssignment(@Nullable QName oldValue, @Nullable QName newValue)
oldValue
- - the current valuenewValue
- - the new value@Nullable protected QName prepareAttributeValueForAssignment(@Nonnull String attributeID, @Nullable QName oldValue, @Nullable 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 String prepareForAssignment(@Nullable String oldValue, @Nullable String newValue)
oldValue
- - the current valuenewValue
- - the new value@Nullable protected String prepareForAssignment(@Nullable String oldValue, @Nullable String newValue, boolean normalize)
normalize=true
,
and then if it is different from oldString invalidates the DOM. It returns the new effective value so
subclasses just have to go. this.foo = prepareForAssignment(this.foo, foo);oldValue
- - the current valuenewValue
- - the new valuenormalize
- - whether the newValue should be normalized@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 String oldID, @Nullable 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 XMLObject
propagateRelease
- true if all descendants of this element should release their DOMpublic void releaseDOM()
releaseDOM
in interface XMLObject
public void releaseParentDOM(boolean propagateRelease)
releaseParentDOM
in interface XMLObject
propagateRelease
- 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 String id)
@Nullable public XMLObject resolveIDFromRoot(@Nonnull@NotEmpty String id)
resolveIDFromRoot
in interface XMLObject
id
- the ID attribute to resolve to an XMLObjectpublic void setElementNamespacePrefix(@Nullable String prefix)
prefix
- the prefix for this element's namespaceprotected void setElementQName(@Nonnull QName name)
name
- the element's QNamepublic void setNoNamespaceSchemaLocation(@Nullable String location)
setNoNamespaceSchemaLocation
in interface XMLObject
location
- value of the XML Schema noNamespaceSchemaLocation attribute for this objectpublic void setSchemaLocation(@Nullable String location)
setSchemaLocation
in interface XMLObject
location
- value of the XML Schema schemaLocation attribute for this objectprotected void setSchemaType(@Nullable QName type)
type
- the schema typepublic 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 XMLObject
public void setNil(@Nullable 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 XMLObject
newNil
- 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 XMLObject
newNil
- whether the object's content model is expressed as null@Nonnull public LockableClassToInstanceMultiMap<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
Copyright © 1999–2019 Shibboleth Consortium. All rights reserved.