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 ElementProcessors and
AttributeProcessors for those xml attributes and elements occurring in the associated xml namespace.- Since:
- Coherence 12.1.2
- Author:
- bo 2011.06.20
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetAttributeProcessor(XmlAttribute attribute) Obtains theAttributeProcessorthat is suitable for processing the specifiedXmlAttributein the xml namespace associated with thisNamespaceHandler.getAttributeProcessor(String localName) Obtains theAttributeProcessorregistered with the specified localName (in the namespace).Obtains theDocumentPreprocessorthat must be applied to theXmlElement(ie: document) in which theNamespaceHandleris defined, prior toXmlElements andXmlAttributes being processed defined by thisNamespaceHandler.getElementProcessor(XmlElement element) Obtains theElementProcessorthat is suitable for processing the specifiedXmlElementin the xml namespace associated with thisNamespaceHandler.getElementProcessor(String localName) Obtains theElementProcessorregistered with the specified localName (in the namespace).voidonEndNamespace(ProcessingContext context, XmlElement element, String prefix, URI uri) Called when the xml namespace associated with theNamespaceHandleris last encountered in an xml document.voidonStartNamespace(ProcessingContext context, XmlElement element, String prefix, URI uri) Called when the xml namespace associated with theNamespaceHandleris first encountered in an xml document.protected AttributeProcessor<?> onUnknownAttribute(XmlAttribute attribute) A call-back to handle when anXmlAttributeis unknown to theNamespaceHandler.protected ElementProcessor<?> onUnknownElement(XmlElement element) A call-back to handle when anXmlElementis unknown to theNamespaceHandler.<T> voidregisterAttributeType(String sLocalName, Class<T> clzType) Registers (internally creates) an appropriateAttributeProcessorforXmlAttributes with the specified local name so that they produce the specified type of value when processed.<T> voidregisterElementType(String sLocalName, Class<T> clzType) Registers (internally creates) an appropriateElementProcessorforXmlElements with the specified local name so that they produce the specified type of value when processed.voidregisterProcessor(Class<?> clzProcessor) Registers the specified processor as anElementProcessororAttributeProcessor(based on the interfaces it implements) using theXmlSimpleNameannotation to determine the localName of the said processor.voidregisterProcessor(String sLocalName, AttributeProcessor<?> processor) Registers anAttributeProcessorforXmlAttributes with the specified name.voidregisterProcessor(String sLocalName, ElementProcessor<?> processor) Registers anElementProcessorforXmlElements with a name with in the context of theNamespaceHandlernamespace.voidsetDocumentPreprocessor(DocumentPreprocessor preprocessor) Sets theDocumentPreprocessorfor theNamespaceHandler.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.tangosol.config.xml.NamespaceHandler
getOverrideProcessor
-
Constructor Details
-
AbstractNamespaceHandler
public AbstractNamespaceHandler()Construct anAbstractNamespaceHandler.
-
-
Method Details
-
getDocumentPreprocessor
Obtains theDocumentPreprocessorthat must be applied to theXmlElement(ie: document) in which theNamespaceHandleris defined, prior toXmlElements andXmlAttributes being processed defined by thisNamespaceHandler.- Specified by:
getDocumentPreprocessorin interfaceNamespaceHandler- Returns:
- the
DocumentPreprocessorornullif one is not required or defined for theNamespaceHandler
-
getAttributeProcessor
Obtains theAttributeProcessorthat is suitable for processing the specifiedXmlAttributein the xml namespace associated with thisNamespaceHandler.- Specified by:
getAttributeProcessorin interfaceNamespaceHandler- Parameters:
attribute- theXmlAttribute- Returns:
- the
AttributeProcessorornullif a suitableAttributeProcessorcould not be found
-
getElementProcessor
Obtains theElementProcessorthat is suitable for processing the specifiedXmlElementin the xml namespace associated with thisNamespaceHandler.- Specified by:
getElementProcessorin interfaceNamespaceHandler- Parameters:
element- theXmlElement- Returns:
- the
ElementProcessorornullif a suitableElementProcessorcould not be found
-
onStartNamespace
Called when the xml namespace associated with theNamespaceHandleris first encountered in an xml document.- Specified by:
onStartNamespacein interfaceNamespaceHandler- Parameters:
context- the documentProcessingContextin which the xml namespace was encounteredelement- theXmlElementin which the xml namespace was encounteredprefix- the prefix of the declared xml namespaceuri- theURIof the declared xml namespace
-
onEndNamespace
Called when the xml namespace associated with theNamespaceHandleris last encountered in an xml document.- Specified by:
onEndNamespacein interfaceNamespaceHandler- Parameters:
context- the documentProcessingContextin which the xml namespace was encounteredelement- theXmlElementin which the xml namespace was encounteredprefix- the prefix of the declared xml namespaceuri- theURIof the declared xml namespace
-
setDocumentPreprocessor
Sets theDocumentPreprocessorfor theNamespaceHandler.- Parameters:
preprocessor- theDocumentPreprocessor
-
registerProcessor
Registers the specified processor as anElementProcessororAttributeProcessor(based on the interfaces it implements) using theXmlSimpleNameannotation 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)ElementProcessororAttributeProcessorthat is annotated with @XmlSimpleNameto specify it's localName.
-
registerProcessor
Registers anElementProcessorforXmlElements with a name with in the context of theNamespaceHandlernamespace.- Parameters:
sLocalName- The local name of theXmlElementto be processed with theElementProcessorprocessor- TheElementProcessor
-
registerProcessor
Registers anAttributeProcessorforXmlAttributes with the specified name.- Parameters:
sLocalName- The local name of theXmlAttributeto be processed with theAttributeProcessorprocessor- TheAttributeProcessor
-
registerElementType
Registers (internally creates) an appropriateElementProcessorforXmlElements with the specified local name so that they produce the specified type of value when processed.- Type Parameters:
T- the type of value the registeredElementProcessorwill produce- Parameters:
sLocalName- The local name of theXmlElements to be associated with the typeclzType- TheClassof value that should be produced for theXmlElement
-
registerAttributeType
Registers (internally creates) an appropriateAttributeProcessorforXmlAttributes with the specified local name so that they produce the specified type of value when processed.- Type Parameters:
T- the type of value the registeredAttributeProcessorwill produce- Parameters:
sLocalName- The local name of theXmlElements to be associated with the typeclzType- TheClassof value that should be produced for theXmlAttribute
-
onUnknownAttribute
A call-back to handle when anXmlAttributeis unknown to theNamespaceHandler.Override this method to provide specialized foreign
XmlAttributeprocessing. By default,nullwill be returned for unknownXmlAttributes.- Parameters:
attribute- TheXmlAttributethat was unknown.- Returns:
- An appropriate
AttributeProcessorthat may be used to process the unknownXmlAttributeornullif no special processing should occur.
-
onUnknownElement
A call-back to handle when anXmlElementis unknown to theNamespaceHandler.Override this method to provide specialized foreign
XmlElementprocessing. By default, unknownXmlElementwill return anElementProcessorthat when attempting to process the said element, will throw aConfigurationException.- Parameters:
element- TheXmlElementthat was unknown.- Returns:
- An appropriate
ElementProcessorthat may be used to process the unknownXmlElementornullif no special processing should occur.
-
getAttributeProcessor
Obtains theAttributeProcessorregistered with the specified localName (in the namespace).- Parameters:
localName- the name of theAttributeProcessorto return- Returns:
- the
AttributeProcessorornullif not found
-
getElementProcessor
Obtains theElementProcessorregistered with the specified localName (in the namespace).- Parameters:
localName- the name of theElementProcessorto return- Returns:
- the
ElementProcessorornullif not found
-