public abstract class AbstractXmlResourceFactory extends Object implements ResourceFactory
Modifier and Type | Field and Description |
---|---|
static String |
CONTENTBASE_KEY
A key for the content base.
|
CONFIG_PREFIX
Modifier | Constructor and Description |
---|---|
protected |
AbstractXmlResourceFactory()
Default-Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
configureReader(XMLReader reader,
RootXmlReadHandler handler)
Configures the xml reader.
|
Resource |
create(ResourceManager manager,
ResourceData data,
ResourceKey context)
Creates a resource by interpreting the data given in the resource-data object.
|
protected Resource |
createResource(ResourceKey targetKey,
RootXmlReadHandler handler,
Object createdProduct,
Class createdType)
Creates a Resource object for the given product.
|
protected RootXmlReadHandler |
createRootHandler(ResourceManager manager,
ResourceKey targetKey,
XmlFactoryModule[] rootHandlers,
ResourceKey contextKey,
long version) |
protected Object |
finishResult(Object res,
ResourceManager manager,
ResourceData data,
ResourceKey context)
Finishes up the result.
|
protected abstract Configuration |
getConfiguration()
Returns the configuration that should be used to initialize this factory.
|
protected ErrorHandler |
getErrorHandler()
Returns the XML-Error handler that should be registered with the XML parser.
|
protected XmlFactoryModule[] |
getModules()
Returns the registered XmlFactoryModules as array.
|
protected SAXParser |
getParser()
Returns a SAX parser.
|
void |
initializeDefaults()
Loads all XmlFactoryModule-implementations from the given configuration.
|
Object |
parseDirectly(ResourceManager manager,
InputSource input,
ResourceKey context,
Map parameters)
A method to allow to invoke the parsing without accessing the LibLoader layer.
|
void |
registerModule(XmlFactoryModule factoryModule)
Registers a factory module for being used during the parsing.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getFactoryType
public static final String CONTENTBASE_KEY
protected AbstractXmlResourceFactory()
protected SAXParser getParser() throws ParserConfigurationException, SAXException
ParserConfigurationException
- if there is a problem configuring the parser.SAXException
- if there is a problem with the parser initialisationprotected void configureReader(XMLReader reader, RootXmlReadHandler handler)
handler
- the parser implementation that will handle the SAX-Callbacks.reader
- the xml reader that should be configured.public Resource create(ResourceManager manager, ResourceData data, ResourceKey context) throws ResourceCreationException, ResourceLoadingException
create
in interface ResourceFactory
manager
- the resource manager used for all resource loading.data
- the resource-data from where the binary data is read.context
- the resource context used to resolve relative resource paths.ResourceCreationException
- if the resource could not be parsed due to syntaxctial or logical errors in the
data.ResourceLoadingException
- if the resource could not be accessed from the physical storage.protected RootXmlReadHandler createRootHandler(ResourceManager manager, ResourceKey targetKey, XmlFactoryModule[] rootHandlers, ResourceKey contextKey, long version)
public Object parseDirectly(ResourceManager manager, InputSource input, ResourceKey context, Map parameters) throws ResourceKeyCreationException, ResourceCreationException, ResourceLoadingException
manager
- the resource manager used for all resource loading.input
- the raw-data given as SAX-InputSource.context
- the resource context used to resolve relative resource paths.parameters
- the parse parameters.ResourceCreationException
- if the resource could not be parsed due to syntaxctial or logical errors in
the data.ResourceLoadingException
- if the resource could not be accessed from the physical storage.ResourceKeyCreationException
- if creating the context key failed.protected final XmlFactoryModule[] getModules()
protected Resource createResource(ResourceKey targetKey, RootXmlReadHandler handler, Object createdProduct, Class createdType)
targetKey
- the target key.handler
- the root handler used for the parsing.createdProduct
- the created product.createdType
- the type information for the object that has been parsed.protected Object finishResult(Object res, ResourceManager manager, ResourceData data, ResourceKey context) throws ResourceCreationException, ResourceLoadingException
res
- the parsed resource.manager
- the resource manager that was used to load the resource.data
- the data object from where the resource is loaded.context
- the context that resolves relative resource paths.ResourceCreationException
- if the post initialization fails.ResourceLoadingException
- if loading external resources failed with an IO error.protected abstract Configuration getConfiguration()
public void initializeDefaults()
initializeDefaults
in interface ResourceFactory
getConfiguration()
public void registerModule(XmlFactoryModule factoryModule)
factoryModule
- the factory module.NullPointerException
- if the module given is null.protected ErrorHandler getErrorHandler()
Copyright © 2019 Hitachi Vantara. All rights reserved.