Package com.tangosol.config.xml
Class AbstractNamespaceHandler
java.lang.Object
com.tangosol.config.xml.AbstractNamespaceHandler
- All Implemented Interfaces:
NamespaceHandler
- Direct Known Subclasses:
CacheConfigNamespaceHandler
,CdiNamespaceHandler
,JCacheExtendNamespace
,JCacheNamespace
,OperationalConfigNamespaceHandler
An
AbstractNamespaceHandler
provides a base implementation of a NamespaceHandler
with support for implicit and explicit registration of ElementProcessor
s and
AttributeProcessor
s for those xml attributes and elements occurring in the associated xml namespace.- Since:
- Coherence 12.1.2
- Author:
- bo 2011.06.20
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetAttributeProcessor
(XmlAttribute attribute) Obtains theAttributeProcessor
that is suitable for processing the specifiedXmlAttribute
in the xml namespace associated with thisNamespaceHandler
.getAttributeProcessor
(String localName) Obtains theAttributeProcessor
registered with the specified localName (in the namespace).Obtains theDocumentPreprocessor
that must be applied to theXmlElement
(ie: document) in which theNamespaceHandler
is defined, prior toXmlElement
s andXmlAttribute
s being processed defined by thisNamespaceHandler
.getElementProcessor
(XmlElement element) Obtains theElementProcessor
that is suitable for processing the specifiedXmlElement
in the xml namespace associated with thisNamespaceHandler
.getElementProcessor
(String localName) Obtains theElementProcessor
registered with the specified localName (in the namespace).void
onEndNamespace
(ProcessingContext context, XmlElement element, String prefix, URI uri) Called when the xml namespace associated with theNamespaceHandler
is last encountered in an xml document.void
onStartNamespace
(ProcessingContext context, XmlElement element, String prefix, URI uri) Called when the xml namespace associated with theNamespaceHandler
is first encountered in an xml document.protected AttributeProcessor
<?> onUnknownAttribute
(XmlAttribute attribute) A call-back to handle when anXmlAttribute
is unknown to theNamespaceHandler
.protected ElementProcessor
<?> onUnknownElement
(XmlElement element) A call-back to handle when anXmlElement
is unknown to theNamespaceHandler
.<T> void
registerAttributeType
(String sLocalName, Class<T> clzType) Registers (internally creates) an appropriateAttributeProcessor
forXmlAttribute
s with the specified local name so that they produce the specified type of value when processed.<T> void
registerElementType
(String sLocalName, Class<T> clzType) Registers (internally creates) an appropriateElementProcessor
forXmlElement
s with the specified local name so that they produce the specified type of value when processed.void
registerProcessor
(Class<?> clzProcessor) Registers the specified processor as anElementProcessor
orAttributeProcessor
(based on the interfaces it implements) using theXmlSimpleName
annotation to determine the localName of the said processor.void
registerProcessor
(String sLocalName, AttributeProcessor<?> processor) Registers anAttributeProcessor
forXmlAttribute
s with the specified name.void
registerProcessor
(String sLocalName, ElementProcessor<?> processor) Registers anElementProcessor
forXmlElement
s with a name with in the context of theNamespaceHandler
namespace.void
setDocumentPreprocessor
(DocumentPreprocessor preprocessor) Sets theDocumentPreprocessor
for theNamespaceHandler
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.tangosol.config.xml.NamespaceHandler
getOverrideProcessor
-
Constructor Details
-
AbstractNamespaceHandler
public AbstractNamespaceHandler()Construct anAbstractNamespaceHandler
.
-
-
Method Details
-
getDocumentPreprocessor
Obtains theDocumentPreprocessor
that must be applied to theXmlElement
(ie: document) in which theNamespaceHandler
is defined, prior toXmlElement
s andXmlAttribute
s being processed defined by thisNamespaceHandler
.- Specified by:
getDocumentPreprocessor
in interfaceNamespaceHandler
- Returns:
- the
DocumentPreprocessor
ornull
if one is not required or defined for theNamespaceHandler
-
getAttributeProcessor
Obtains theAttributeProcessor
that is suitable for processing the specifiedXmlAttribute
in the xml namespace associated with thisNamespaceHandler
.- Specified by:
getAttributeProcessor
in interfaceNamespaceHandler
- Parameters:
attribute
- theXmlAttribute
- Returns:
- the
AttributeProcessor
ornull
if a suitableAttributeProcessor
could not be found
-
getElementProcessor
Obtains theElementProcessor
that is suitable for processing the specifiedXmlElement
in the xml namespace associated with thisNamespaceHandler
.- Specified by:
getElementProcessor
in interfaceNamespaceHandler
- Parameters:
element
- theXmlElement
- Returns:
- the
ElementProcessor
ornull
if a suitableElementProcessor
could not be found
-
onStartNamespace
Called when the xml namespace associated with theNamespaceHandler
is first encountered in an xml document.- Specified by:
onStartNamespace
in interfaceNamespaceHandler
- Parameters:
context
- the documentProcessingContext
in which the xml namespace was encounteredelement
- theXmlElement
in which the xml namespace was encounteredprefix
- the prefix of the declared xml namespaceuri
- theURI
of the declared xml namespace
-
onEndNamespace
Called when the xml namespace associated with theNamespaceHandler
is last encountered in an xml document.- Specified by:
onEndNamespace
in interfaceNamespaceHandler
- Parameters:
context
- the documentProcessingContext
in which the xml namespace was encounteredelement
- theXmlElement
in which the xml namespace was encounteredprefix
- the prefix of the declared xml namespaceuri
- theURI
of the declared xml namespace
-
setDocumentPreprocessor
Sets theDocumentPreprocessor
for theNamespaceHandler
.- Parameters:
preprocessor
- theDocumentPreprocessor
-
registerProcessor
Registers the specified processor as anElementProcessor
orAttributeProcessor
(based on the interfaces it implements) using theXmlSimpleName
annotation to determine the localName of the said processor.Note: The specified class must have a no-args constructor.
- Parameters:
clzProcessor
- A class that implements either (or both)ElementProcessor
orAttributeProcessor
that is annotated with @XmlSimpleName
to specify it's localName.
-
registerProcessor
Registers anElementProcessor
forXmlElement
s with a name with in the context of theNamespaceHandler
namespace.- Parameters:
sLocalName
- The local name of theXmlElement
to be processed with theElementProcessor
processor
- TheElementProcessor
-
registerProcessor
Registers anAttributeProcessor
forXmlAttribute
s with the specified name.- Parameters:
sLocalName
- The local name of theXmlAttribute
to be processed with theAttributeProcessor
processor
- TheAttributeProcessor
-
registerElementType
Registers (internally creates) an appropriateElementProcessor
forXmlElement
s with the specified local name so that they produce the specified type of value when processed.- Type Parameters:
T
- the type of value the registeredElementProcessor
will produce- Parameters:
sLocalName
- The local name of theXmlElement
s to be associated with the typeclzType
- TheClass
of value that should be produced for theXmlElement
-
registerAttributeType
Registers (internally creates) an appropriateAttributeProcessor
forXmlAttribute
s with the specified local name so that they produce the specified type of value when processed.- Type Parameters:
T
- the type of value the registeredAttributeProcessor
will produce- Parameters:
sLocalName
- The local name of theXmlElement
s to be associated with the typeclzType
- TheClass
of value that should be produced for theXmlAttribute
-
onUnknownAttribute
A call-back to handle when anXmlAttribute
is unknown to theNamespaceHandler
.Override this method to provide specialized foreign
XmlAttribute
processing. By default,null
will be returned for unknownXmlAttribute
s.- Parameters:
attribute
- TheXmlAttribute
that was unknown.- Returns:
- An appropriate
AttributeProcessor
that may be used to process the unknownXmlAttribute
ornull
if no special processing should occur.
-
onUnknownElement
A call-back to handle when anXmlElement
is unknown to theNamespaceHandler
.Override this method to provide specialized foreign
XmlElement
processing. By default, unknownXmlElement
will return anElementProcessor
that when attempting to process the said element, will throw aConfigurationException
.- Parameters:
element
- TheXmlElement
that was unknown.- Returns:
- An appropriate
ElementProcessor
that may be used to process the unknownXmlElement
ornull
if no special processing should occur.
-
getAttributeProcessor
Obtains theAttributeProcessor
registered with the specified localName (in the namespace).- Parameters:
localName
- the name of theAttributeProcessor
to return- Returns:
- the
AttributeProcessor
ornull
if not found
-
getElementProcessor
Obtains theElementProcessor
registered with the specified localName (in the namespace).- Parameters:
localName
- the name of theElementProcessor
to return- Returns:
- the
ElementProcessor
ornull
if not found
-