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
public abstract class AbstractNamespaceHandler extends Object implements NamespaceHandler
AnAbstractNamespaceHandlerprovides a base implementation of aNamespaceHandlerwith support for implicit and explicit registration ofElementProcessors andAttributeProcessors 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 Constructor Description AbstractNamespaceHandler()Construct anAbstractNamespaceHandler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AttributeProcessor<?>getAttributeProcessor(XmlAttribute attribute)Obtains theAttributeProcessorthat is suitable for processing the specifiedXmlAttributein the xml namespace associated with thisNamespaceHandler.AttributeProcessor<?>getAttributeProcessor(String localName)Obtains theAttributeProcessorregistered with the specified localName (in the namespace).DocumentPreprocessorgetDocumentPreprocessor()Obtains theDocumentPreprocessorthat must be applied to theXmlElement(ie: document) in which theNamespaceHandleris defined, prior toXmlElements andXmlAttributes being processed defined by thisNamespaceHandler.ElementProcessor<?>getElementProcessor(XmlElement element)Obtains theElementProcessorthat is suitable for processing the specifiedXmlElementin the xml namespace associated with thisNamespaceHandler.ElementProcessor<?>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, wait
-
Methods inherited from interface com.tangosol.config.xml.NamespaceHandler
getOverrideProcessor
-
-
-
-
Constructor Detail
-
AbstractNamespaceHandler
public AbstractNamespaceHandler()
Construct anAbstractNamespaceHandler.
-
-
Method Detail
-
getDocumentPreprocessor
public DocumentPreprocessor 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
public AttributeProcessor<?> getAttributeProcessor(XmlAttribute attribute)
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
public ElementProcessor<?> getElementProcessor(XmlElement element)
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
public void onStartNamespace(ProcessingContext context, XmlElement element, String prefix, URI uri)
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
public void onEndNamespace(ProcessingContext context, XmlElement element, String prefix, URI uri)
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
public void setDocumentPreprocessor(DocumentPreprocessor preprocessor)
Sets theDocumentPreprocessorfor theNamespaceHandler.- Parameters:
preprocessor- theDocumentPreprocessor
-
registerProcessor
public void registerProcessor(Class<?> clzProcessor)
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
public void registerProcessor(String sLocalName, ElementProcessor<?> processor)
Registers anElementProcessorforXmlElements with a name with in the context of theNamespaceHandlernamespace.- Parameters:
sLocalName- The local name of theXmlElementto be processed with theElementProcessorprocessor- TheElementProcessor
-
registerProcessor
public void registerProcessor(String sLocalName, AttributeProcessor<?> processor)
Registers anAttributeProcessorforXmlAttributes with the specified name.- Parameters:
sLocalName- The local name of theXmlAttributeto be processed with theAttributeProcessorprocessor- TheAttributeProcessor
-
registerElementType
public <T> void registerElementType(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.- 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
public <T> void registerAttributeType(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.- 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
protected AttributeProcessor<?> onUnknownAttribute(XmlAttribute attribute)
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
protected ElementProcessor<?> onUnknownElement(XmlElement element)
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
public AttributeProcessor<?> getAttributeProcessor(String localName)
Obtains theAttributeProcessorregistered with the specified localName (in the namespace).- Parameters:
localName- the name of theAttributeProcessorto return- Returns:
- the
AttributeProcessorornullif not found
-
getElementProcessor
public ElementProcessor<?> getElementProcessor(String localName)
Obtains theElementProcessorregistered with the specified localName (in the namespace).- Parameters:
localName- the name of theElementProcessorto return- Returns:
- the
ElementProcessorornullif not found
-
-