Class AbstractXMLObject
- All Implemented Interfaces:
XMLObject
- Direct Known Subclasses:
AbstractElementExtensibleXMLObject,AbstractExtensibleSOAPObject,AbstractSignableXMLObject,AbstractWSAddressingObject,AbstractWSPolicyObject,AbstractWSSecurityObject,AbstractWSTrustObject,AbstractXACMLObject,AddressImpl,AdviceImpl,AdviceImpl,AgreementMethodImpl,AlgorithmIdentifierTypeImpl,AppliesToImpl,AsynchronousImpl,AttributeConsumingServiceImpl,AttributeDesignatorImpl,AttributeImpl,AttributeStatementImpl,AudienceRestrictionConditionImpl,AudienceRestrictionImpl,AuthnContextImpl,AuthnStatementImpl,AuthorityBindingImpl,AuthzDecisionStatementImpl,BaseIDImpl,CipherDataImpl,CipherReferenceImpl,ConcatKDFParamsImpl,ConditionsImpl,ConditionsImpl,ContactPersonImpl,DelegateImpl,DelegationRestrictionTypeImpl,DerivedKeyImpl,DHKeyValueImpl,DigestMethodImpl,DigestMethodImpl,DiscoHintsImpl,DoNotCacheConditionImpl,DSAKeyValueImpl,ECKeyValueImpl,EncryptedElementTypeImpl,EncryptedTypeImpl,EncryptionMethodImpl,EncryptionPropertiesImpl,EncryptionPropertyImpl,EndpointImpl,EndPointReferenceImpl,EntityAttributesImpl,EvidenceImpl,EvidenceImpl,ExtensionsImpl,ExtensionsImpl,FaultImpl,IDPEntryImpl,IDPListImpl,KeyDerivationMethodImpl,KeyDescriptorImpl,KeyInfoImpl,KeyInfoReferenceImpl,KeyValueImpl,KeywordsImpl,NamedCurveImpl,NameIDPolicyImpl,OneTimeUseImpl,OrganizationImpl,PBKDF2ParamsImpl,PGPDataImpl,ProxyRestrictionImpl,PublicationImpl,PublicationInfoImpl,PublicationPathImpl,ReferencedPoliciesTypeImpl,ReferenceListImpl,ReferenceTypeImpl,RegistrationInfoImpl,RequestAuthenticatedImpl,RequestedAttributesImpl,RequestedAuthnContextImpl,RequestedSecurityTokenImpl,RequestImpl,RequestSecurityTokenResponseImpl,RespondWithImpl,ResponseImpl,RetrievalMethodImpl,RSAKeyValueImpl,SaltImpl,ScopingImpl,SessionKeyImpl,SignatureImpl,SigningMethodImpl,SimpleXMLObject,SPKIDataImpl,StatusCodeImpl,StatusCodeImpl,StatusDetailImpl,StatusDetailImpl,StatusImpl,StatusImpl,SubjectConfirmationDataImpl,SubjectConfirmationImpl,SubjectConfirmationImpl,SubjectConfirmationImpl,SubjectImpl,SubjectImpl,SubjectLocalityImpl,SubjectLocalityImpl,SubjectQueryImpl,SubjectStatementImpl,TerminateImpl,TransformImpl,TransformsImpl,TransformsImpl,UIInfoImpl,X509CertificateImpl,X509CRLImpl,X509DataImpl,X509IssuerSerialImpl,X509SerialNumberImpl,XACMLAuthzDecisionStatementTypeImpl,XACMLPolicyStatementTypeImpl,XSAnyImpl,XSBase64BinaryImpl,XSBooleanImpl,XSDateTimeImpl,XSIntegerImpl,XSQNameImpl,XSStringImpl,XSURIImpl
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ElementDOM Element representation of this object.private QNameThe name of this element with namespace and prefix information.private final IDIndexMapping of ID attributes to XMLObjects in the subtree rooted at this object.private final org.slf4j.LoggerClass logger.private XSBooleanValueThe value of thexsi:nilattribute.private StringNo-namespace schema locations for this XML object.private NamespaceManagerThe namespace manager for this XML object.private final LockableClassToInstanceMultiMap<Object>The multimap holding class-indexed instances of additional info associated with this XML object.private XMLObjectParent of this element.private StringSchema locations for this XML object.private QNameThe schema type of this element with namespace and prefix information. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractXMLObject(String namespaceURI, String elementLocalName, String namespacePrefix) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoiddetach()Detaches the XMLObject from its parent.Gets the DOM representation of this XMLObject, if one exists, or raises aConstraintViolationException.getDOM()Gets the DOM representation of this XMLObject, if one exists.Gets the QName for this element.Get the IDIndex holding the ID-to-XMLObject index mapping, rooted at this XMLObject's subtree.Gets theNamespaceManagerinstance for this object.Gets the namespaces that are scoped to this element.Gets the value of the XML Schema noNamespaceSchemaLocation attribute for this object.Get the mutable multimap which holds additional information (represented by plain Java object instances) associated with this XMLObject.Gets the parent of this element or null if there is no parent.Gets the value of the XML Schema schemaLocation attribute for this object.Gets the XML schema type of this element.booleanChecks if this XMLObject has children.booleanChecks to see if this object has a parent.isNil()Gets whether the object declares that its element content is null, which corresponds to anxsi:nilattribute oftrue.Gets whether the object declares that its element content is null, which corresponds to anxsi:nilattribute oftrue.protected voidmanageQualifiedAttributeNamespace(QName attributeName, boolean hasValue) A helper function for derived classes.protected QNameprepareAttributeValueForAssignment(String attributeID, QName oldValue, QName newValue) A helper function for derived classes.protected QNameprepareElementContentForAssignment(QName oldValue, QName newValue) A helper function for derived classes.protected StringprepareForAssignment(String oldValue, String newValue) A helper function for derived classes.protected StringprepareForAssignment(String oldValue, String newValue, boolean normalize) A helper function for derived classes.protected <T> TprepareForAssignment(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 voidregisterOwnID(String oldID, String newID) A helper function for derived classes.voidreleaseChildrenDOM(boolean propagateRelease) Releases the DOM representation of this XMLObject's children.voidReleases the DOM representation of this XMLObject, if there is one.voidreleaseParentDOM(boolean propagateRelease) Releases the DOM representation of this XMLObject's parent.voidA convenience method that is equal to callingreleaseDOM()thenreleaseChildrenDOM(boolean)with the release being propagated.voidA convenience method that is equal to callingreleaseDOM()thenreleaseParentDOM(boolean)with the release being propagated.Find the XMLObject identified by the specified ID attribute, within the subtree of XMLObjects which has this XMLObject as its root.Find the XMLObject identified by the specified ID attribute, from the root of the tree of XMLObjects in which this XMLObject is a member.voidSets the DOM representation of this XMLObject.voidsetElementNamespacePrefix(String prefix) Sets the prefix for this element's namespace.protected voidsetElementQName(QName name) Sets the element QName.voidSets whether the object declares that its element content is null, which corresponds to anxsi:nilattribute oftrue.voidsetNil(XSBooleanValue newNil) Sets whether the object declares that its element content is null, which corresponds to anxsi:nilattribute oftrue.voidsetNoNamespaceSchemaLocation(String location) Sets the value of the XML Schema noNamespaceSchemaLocation attribute for this object.voidSets the parent of this element.voidsetSchemaLocation(String location) Sets the value of the XML Schema schemaLocation attribute for this object.protected voidsetSchemaType(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, waitMethods inherited from interface org.opensaml.core.xml.XMLObject
getOrderedChildren
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
parent
Parent of this element. -
elementQname
The name of this element with namespace and prefix information. -
schemaLocation
Schema locations for this XML object. -
noNamespaceSchemaLocation
No-namespace schema locations for this XML object. -
typeQname
The schema type of this element with namespace and prefix information. -
dom
DOM Element representation of this object. -
nil
The value of thexsi:nilattribute. -
nsManager
The namespace manager for this XML object. -
objectMetadata
The multimap holding class-indexed instances of additional info associated with this XML object. -
idIndex
Mapping of ID attributes to XMLObjects in the subtree rooted at this object. This allows constant-time dereferencing of ID-typed attributes within the subtree.
-
-
Constructor Details
-
AbstractXMLObject
protected AbstractXMLObject(@Nullable String namespaceURI, @Nonnull @NotEmpty String elementLocalName, @Nullable String namespacePrefix) Constructor.- Parameters:
namespaceURI- the namespace the element is inelementLocalName- the local name of the XML element this Object representsnamespacePrefix- the prefix for the given namespace
-
-
Method Details
-
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. -
getDOM
Gets the DOM representation of this XMLObject, if one exists. -
ensureDOM
Gets the DOM representation of this XMLObject, if one exists, or raises aConstraintViolationException. -
getElementQName
Gets the QName for this element. This QName MUST contain the namespace URI, namespace prefix, and local element name.- Specified by:
getElementQNamein interfaceXMLObject- Returns:
- the QName for this attribute
-
getIDIndex
Get the IDIndex holding the ID-to-XMLObject index mapping, rooted at this XMLObject's subtree.- Specified by:
getIDIndexin interfaceXMLObject- Returns:
- the IDIndex owned by this XMLObject
-
getNamespaceManager
Gets theNamespaceManagerinstance for this object.- Specified by:
getNamespaceManagerin interfaceXMLObject- Returns:
- the namespace manager for this object
-
getNamespaces
Gets the namespaces that are scoped to this element.- Specified by:
getNamespacesin interfaceXMLObject- Returns:
- the namespaces that are scoped to this element
-
getNoNamespaceSchemaLocation
Gets the value of the XML Schema noNamespaceSchemaLocation attribute for this object.- Specified by:
getNoNamespaceSchemaLocationin interfaceXMLObject- Returns:
- value of the XML Schema noNamespaceSchemaLocation attribute for this object
-
getParent
Gets the parent of this element or null if there is no parent. -
getSchemaLocation
Gets the value of the XML Schema schemaLocation attribute for this object.- Specified by:
getSchemaLocationin interfaceXMLObject- Returns:
- schema location defined for this object
-
getSchemaType
Gets the XML schema type of this element. This translates to the contents of the xsi:type attribute.- Specified by:
getSchemaTypein interfaceXMLObject- Returns:
- XML schema type of this element, or null
-
hasChildren
public boolean hasChildren()Checks if this XMLObject has children.- Specified by:
hasChildrenin interfaceXMLObject- Returns:
- true if this XMLObject has children, false if not
-
hasParent
public boolean hasParent()Checks to see if this object has a parent. -
manageQualifiedAttributeNamespace
A helper function for derived classes. This method should be called when the value of a namespace-qualified attribute changes.- Parameters:
attributeName- the attribute namehasValue- true to indicate that the attribute has a value, false to indicate it has no value
-
prepareElementContentForAssignment
@Nullable protected QName prepareElementContentForAssignment(@Nullable QName oldValue, @Nullable QName newValue) A helper function for derived classes. This checks for semantic equality between two QNames, and if they are different invalidates the DOM. It returns the normalized value so subclasses just have to use: this.foo = prepareElementContentForAssignment(this.foo, foo);- Parameters:
oldValue- - the current valuenewValue- - the new value- Returns:
- the value that should be assigned
-
prepareAttributeValueForAssignment
@Nullable protected QName prepareAttributeValueForAssignment(@Nonnull String attributeID, @Nullable QName oldValue, @Nullable QName newValue) A helper function for derived classes. This checks for semantic equality between two QNames and if they are different invalidates the DOM. It returns the normalized value so subclasses just have to use: this.foo = prepareAttributeValueForAssignment(this.foo, foo);- Parameters:
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- Returns:
- the value that should be assigned
-
prepareForAssignment
@Nullable protected String prepareForAssignment(@Nullable String oldValue, @Nullable String newValue) A helper function for derived classes. This 'normalizes' newString and then if it is different from oldString invalidates the DOM. It returns the normalized value so subclasses just have to use: this.foo = prepareForAssignment(this.foo, foo);- Parameters:
oldValue- - the current valuenewValue- - the new value- Returns:
- the value that should be assigned
-
prepareForAssignment
@Nullable protected String prepareForAssignment(@Nullable String oldValue, @Nullable String newValue, boolean normalize) A helper function for derived classes. This 'normalizes' newString ifnormalize=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);- Parameters:
oldValue- - the current valuenewValue- - the new valuenormalize- - whether the newValue should be normalized- Returns:
- the value that should be assigned
-
prepareForAssignment
@Nullable protected <T> T prepareForAssignment(@Nullable T oldValue, @Nullable 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 valuenewValue- - proposed new value- Returns:
- The value to assign to the saved Object.
-
prepareForAssignment
@Nullable protected <T extends XMLObject> T prepareForAssignment(@Nullable T oldValue, @Nullable T newValue) A helper function for derived classes, similar to assignString, but for (singleton) XML 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 valuenewValue- proposed new value- Returns:
- The value to assign to the saved Object.
-
registerOwnID
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 attributenewID- 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:
releaseChildrenDOMin interfaceXMLObject- 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:
releaseDOMin interfaceXMLObject
-
releaseParentDOM
public void releaseParentDOM(boolean propagateRelease) Releases the DOM representation of this XMLObject's parent.- Specified by:
releaseParentDOMin interfaceXMLObject- Parameters:
propagateRelease- true if all ancestors of this element should release their DOM
-
releaseThisAndChildrenDOM
public void releaseThisAndChildrenDOM()A convenience method that is equal to callingreleaseDOM()thenreleaseChildrenDOM(boolean)with the release being propagated. -
releaseThisandParentDOM
public void releaseThisandParentDOM()A convenience method that is equal to callingreleaseDOM()thenreleaseParentDOM(boolean)with the release being propagated. -
resolveID
Find the XMLObject identified by the specified ID attribute, within the subtree of XMLObjects which has this XMLObject as its root. -
resolveIDFromRoot
Find the XMLObject identified by the specified ID attribute, from the root of the tree of XMLObjects in which this XMLObject is a member.- Specified by:
resolveIDFromRootin interfaceXMLObject- Parameters:
id- the ID attribute to resolve to an XMLObject- Returns:
- the XMLObject identified by the specified ID attribute value, or null
-
setDOM
Sets the DOM representation of this XMLObject. -
setElementNamespacePrefix
Sets the prefix for this element's namespace.- Parameters:
prefix- the prefix for this element's namespace
-
setElementQName
Sets the element QName.- Parameters:
name- the element's QName
-
setNoNamespaceSchemaLocation
Sets the value of the XML Schema noNamespaceSchemaLocation attribute for this object.- Specified by:
setNoNamespaceSchemaLocationin interfaceXMLObject- Parameters:
location- value of the XML Schema noNamespaceSchemaLocation attribute for this object
-
setParent
Sets the parent of this element. -
setSchemaLocation
Sets the value of the XML Schema schemaLocation attribute for this object.- Specified by:
setSchemaLocationin interfaceXMLObject- Parameters:
location- value of the XML Schema schemaLocation attribute for this object
-
setSchemaType
Sets a given QName as the schema type for the Element represented by this XMLObject. This will register the namespace for the type as well as for the xsi:type qualified attribute name with the namespace manager for this XMLObject. If null is passed, the type name and xsi:type name will be deregistered.- Parameters:
type- the schema type
-
isNil
Gets whether the object declares that its element content is null, which corresponds to anxsi:nilattribute oftrue.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
Gets whether the object declares that its element content is null, which corresponds to anxsi:nilattribute oftrue.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.
- Specified by:
isNilXSBooleanin interfaceXMLObject- Returns:
- whether the object's content model is null
- See Also:
-
setNil
Sets whether the object declares that its element content is null, which corresponds to anxsi:nilattribute oftrue.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
Sets whether the object declares that its element content is null, which corresponds to anxsi:nilattribute oftrue.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.
-
getObjectMetadata
Get the mutable multimap which holds additional information (represented by plain Java object instances) associated with this XMLObject.Objects added to this multimap will be indexed and retrievable by their concrete
Classas well as by theClasstypes representing all superclasses (excludingjava.lang.Object) and all implemented interfaces.- Specified by:
getObjectMetadatain interfaceXMLObject- Returns:
- the class-to-instance multimap
-