org.pentaho.reporting.libraries.xmlns.parser

Class AbstractXmlResourceFactory

public abstract class AbstractXmlResourceFactory extends Object implements ResourceFactory

A base-class for resource-factories that load their resources from XML files. This class provides a multiplexing option. For this, the parser looks at the root-element of the document to be parsed and selects the most suitable XmlFactoryModule implementation registered.

Author: Thomas Morgner

Field Summary
static StringCONTENTBASE_KEY
A key for the content base.
Method Summary
Resourcecreate(ResourceManager manager, ResourceData data, ResourceKey context)
Creates a resource by interpreting the data given in the resource-data object.
voidinitializeDefaults()
Loads all XmlFactoryModule-implementations from the given configuration.
ObjectparseDirectly(ResourceManager manager, InputSource input, ResourceKey context, Map parameters)
A method to allow to invoke the parsing without accessing the LibLoader layer.
voidregisterModule(XmlFactoryModule factoryModule)
Registers a factory module for being used during the parsing.

Field Detail

CONTENTBASE_KEY

public static final String CONTENTBASE_KEY
A key for the content base.

Method Detail

create

public Resource create(ResourceManager manager, ResourceData data, ResourceKey context)
Creates a resource by interpreting the data given in the resource-data object. If additional datastreams need to be parsed, the provided resource manager should be used. This method parses the given resource-data as XML stream.

Parameters: 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.

Returns: the parsed result, never null.

Throws: 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.

initializeDefaults

public void initializeDefaults()
Loads all XmlFactoryModule-implementations from the given configuration.

See Also: getConfiguration

parseDirectly

public Object parseDirectly(ResourceManager manager, InputSource input, ResourceKey context, Map parameters)
A method to allow to invoke the parsing without accessing the LibLoader layer. The data to be parsed is held in the given InputSource object.

Parameters: 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.

Returns: the parsed result, never null.

Throws: 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.

registerModule

public void registerModule(XmlFactoryModule factoryModule)
Registers a factory module for being used during the parsing. If the factory module does not return a result that matches the factory's type, the parsing will always fail.

Parameters: factoryModule the factory module.

Throws: NullPointerException if the module given is null.