Module dev.metaschema.core
Package dev.metaschema.core.model
Class AbstractModuleLoader<T,M extends IModuleExtended<M,?,?,?,?>>
java.lang.Object
dev.metaschema.core.model.AbstractLoader<M>
dev.metaschema.core.model.AbstractModuleLoader<T,M>
- Type Parameters:
T- the Java type of the module bindingM- the Java type of the Metaschema module loaded by this loader
- All Implemented Interfaces:
ILoader<M>,IModuleLoader<M>
- Direct Known Subclasses:
BindingModuleLoader
public abstract class AbstractModuleLoader<T,M extends IModuleExtended<M,?,?,?,?>>
extends AbstractLoader<M>
implements IModuleLoader<M>
Provides methods to load a Metaschema expressed in XML.
Loaded Metaschema instances are cached to avoid the need to load them for every use. Any Metaschema imported is also loaded and cached automatically.
-
Nested Class Summary
Nested classes/interfaces inherited from interface dev.metaschema.core.model.IModuleLoader
IModuleLoader.IModulePostProcessor -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstruct a new Metaschema module loader, which use the provided module post processors when loading a module. -
Method Summary
Modifier and TypeMethodDescriptiongetImports(T binding) Get the list of Metaschema module URIs associated with the provided binding.protected abstract MParse theresourcebased on the providedxmlObject.protected abstract TparseModule(URI resource) Parse the provided XML resource as a Metaschema module.protected MparseResource(URI resource, Deque<URI> visitedResources) Parse the providedresource.Methods inherited from class dev.metaschema.core.model.AbstractLoader
getCachedEntries, getLoadedResources, load, load, load, loadInternal
-
Constructor Details
-
AbstractModuleLoader
protected AbstractModuleLoader()Construct a new Metaschema module loader, which use the provided module post processors when loading a module.
-
-
Method Details
-
newModule
@NonNull protected abstract M newModule(@NonNull URI resource, @NonNull T binding, @NonNull List<? extends M> importedModules) throws MetaschemaException Parse theresourcebased on the providedxmlObject.- Parameters:
resource- the URI of the resource being parsedbinding- the XML beans object to parseimportedModules- previously parsed Metaschema modules imported by the providedresource- Returns:
- the parsed resource as a Metaschema module
- Throws:
MetaschemaException- if an error occurred while parsing the XML beans object
-
getImports
Get the list of Metaschema module URIs associated with the provided binding.- Parameters:
binding- the Metaschema module binding declaring the imports- Returns:
- the list of Metaschema module URIs
-
parseResource
protected M parseResource(@NonNull URI resource, @NonNull Deque<URI> visitedResources) throws IOException Description copied from class:AbstractLoaderParse the providedresource.- Specified by:
parseResourcein classAbstractLoader<M extends IModuleExtended<M,?, ?, ?, ?>> - Parameters:
resource- the resource to parsevisitedResources- a stack representing previously parsed resources imported by the providedresource- Returns:
- the parsed resource
- Throws:
IOException- if an error occurred while parsing the resource
-
parseModule
Parse the provided XML resource as a Metaschema module.- Parameters:
resource- the resource to parse- Returns:
- the parsed Metaschema module
- Throws:
IOException- if a parsing error occurred
-