Package net.shibboleth.metadata.dom
Class AbstractDOMTraversalStage<C extends DOMTraversalContext>
java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent
net.shibboleth.metadata.pipeline.AbstractStage<T>
net.shibboleth.metadata.pipeline.AbstractIteratingStage<Element>
net.shibboleth.metadata.dom.AbstractDOMTraversalStage<C>
- Type Parameters:
C- the context to carry through the traversal
- All Implemented Interfaces:
Stage<Element>,net.shibboleth.shared.component.Component,net.shibboleth.shared.component.DestructableComponent,net.shibboleth.shared.component.IdentifiableComponent,net.shibboleth.shared.component.IdentifiedComponent,net.shibboleth.shared.component.InitializableComponent
- Direct Known Subclasses:
AbstractDOMValidationStage,AbstractElementVisitingStage,AbstractSAMLTraversalStage,ElementsStrippingStage,IPHintValidationStage
@ThreadSafe
public abstract class AbstractDOMTraversalStage<C extends DOMTraversalContext>
extends AbstractIteratingStage<Element>
An abstract DOM traversal class using the template method pattern.
A context object, extending DOMTraversalContext, is created by the
implementing subclass and passed to the visit(org.w3c.dom.Element, C) method when
each applicable Element is visited. In very simple cases, the
SimpleDOMTraversalContext may suffice, but more complicated
behaviour can be built up by extending or re-implementing that class.
Which Element nodes are visited during the traversal is controlled
by n applicable(org.w3c.dom.Element, C) method implemented by subclasses. Traversal within
elements to DOM attributes is not supported directly.
At the end of the traversal, the context's DOMTraversalContext.end()
method is called to perform any post-processing required.
- Since:
- 0.9.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAdd anErrorStatusto the given item, in respect of the givenElement.protected abstract booleanapplicable(Element element, C context) Indicates whether the visitor should be applied to a particularElement.protected abstract CbuildContext(Item<Element> item) Build the context for a particular traversal.protected voidProcesses a givenItem.protected StringerrorPrefix(Element element) Computes a prefix to be put in front of the message inaddError(net.shibboleth.metadata.Item<org.w3c.dom.Element>, org.w3c.dom.Element, java.lang.String).private voidDepth-first traversal of the DOM tree rooted in an element, applying the visitor when appropriate.protected abstract voidVisit a particularElement.Methods inherited from class net.shibboleth.metadata.pipeline.AbstractIteratingStage
doExecuteMethods inherited from class net.shibboleth.metadata.pipeline.AbstractStage
execute, getCollectionPredicate, setCollectionPredicateMethods inherited from class net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent
setIdMethods inherited from class net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
doInitialize, ensureId, getId, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentExceptionMethods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent
checkComponentActive, checkSetterPreconditions, destroy, doDestroy, initialize, isDestroyed, isInitializedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.shibboleth.shared.component.DestructableComponent
destroy, isDestroyedMethods inherited from interface net.shibboleth.shared.component.IdentifiedComponent
getIdMethods inherited from interface net.shibboleth.shared.component.InitializableComponent
initialize, isInitialized
-
Constructor Details
-
AbstractDOMTraversalStage
public AbstractDOMTraversalStage()
-
-
Method Details
-
buildContext
Build the context for a particular traversal.- Parameters:
item- theItemwe are traversing- Returns:
- an appropriate context
-
applicable
Indicates whether the visitor should be applied to a particularElement.- Parameters:
element-Elementto which we may wish to apply the visitorcontext-DOMTraversalContextimplementation being used to manage the traversal- Returns:
trueif the visitor should be applied to thisElement.
-
visit
protected abstract void visit(@Nonnull Element element, @Nonnull C context) throws StageProcessingException Visit a particularElement.- Parameters:
element- theElementto visitcontext- the traversal context- Throws:
StageProcessingException- if errors occur during processing
-
traverse
Depth-first traversal of the DOM tree rooted in an element, applying the visitor when appropriate. The traversal snapshots the child elements at each level, so that the visitor could in principle reorder or delete them during processing.- Parameters:
element-Elementto start fromcontext- context for the traversal- Throws:
StageProcessingException- if errors occur during processing
-
doExecute
Description copied from class:AbstractIteratingStageProcesses a givenItem.- Specified by:
doExecutein classAbstractIteratingStage<Element>- Parameters:
item-Itemon which to operate- Throws:
StageProcessingException- thrown if there is a problem with the stage processing
-
errorPrefix
Computes a prefix to be put in front of the message inaddError(net.shibboleth.metadata.Item<org.w3c.dom.Element>, org.w3c.dom.Element, java.lang.String).- Parameters:
element-Elementforming the context for the prefix- Returns:
- a prefix for the error message
-
addError
protected void addError(@Nonnull Item<Element> item, @Nonnull Element element, @Nonnull String error) Add anErrorStatusto the given item, in respect of the givenElement. If the item is an EntitiesDescriptor, interpose an identifier for the individual EntityDescriptor.
-