Class ModuleLoader
- java.lang.Object
-
- gov.nist.secauto.metaschema.core.model.xml.AbstractLoader<IModule>
-
- gov.nist.secauto.metaschema.core.model.xml.ModuleLoader
-
public class ModuleLoader extends AbstractLoader<IModule>
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.
-
-
Constructor Summary
Constructors Constructor Description ModuleLoader()
Construct a new Metaschema loader.ModuleLoader(Set<IConstraintSet> additionalConstraintSets)
Construct a new Metaschema loader, which will incorporate the additional provided constraints into matching loaded definitions.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
allowEntityResolution()
Enable a mode that allows XML entity resolution.protected Set<IConstraintSet>
getRegisteredConstraintSets()
Get the set of additional constraints associated with this loader.protected IModule
newXmlMetaschema(URI resource, gov.nist.secauto.metaschema.core.model.xml.xmlbeans.METASCHEMADocument xmlObject, List<IModule> importedModules)
Parse theresource
based on the providedxmlObject
.protected gov.nist.secauto.metaschema.core.model.xml.xmlbeans.METASCHEMADocument
parseModule(URI resource)
Parse the provided XML resource as a Metaschema module.protected IModule
parseResource(URI resource, Deque<URI> visitedResources)
Parse the providedresource
.-
Methods inherited from class gov.nist.secauto.metaschema.core.model.xml.AbstractLoader
getCachedEntries, getLoadedResources, load, load, load, load, loadInternal
-
-
-
-
Constructor Detail
-
ModuleLoader
public ModuleLoader()
Construct a new Metaschema loader.
-
ModuleLoader
public ModuleLoader(@NonNull Set<IConstraintSet> additionalConstraintSets)
Construct a new Metaschema loader, which will incorporate the additional provided constraints into matching loaded definitions.- Parameters:
additionalConstraintSets
- additional constraints to associate with loaded definitions
-
-
Method Detail
-
getRegisteredConstraintSets
@NonNull protected Set<IConstraintSet> getRegisteredConstraintSets()
Get the set of additional constraints associated with this loader.- Returns:
- the set of constraints
-
allowEntityResolution
public void allowEntityResolution()
Enable a mode that allows XML entity resolution. This may be needed to parse some resource files that contain entities. Enabling entity resolution is a less secure, which requires trust in the resource content being parsed.
-
newXmlMetaschema
protected IModule newXmlMetaschema(@NonNull URI resource, @NonNull gov.nist.secauto.metaschema.core.model.xml.xmlbeans.METASCHEMADocument xmlObject, @NonNull List<IModule> importedModules) throws MetaschemaException
Parse theresource
based on the providedxmlObject
.- Parameters:
resource
- the URI of the resource being parsedxmlObject
- 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
-
parseResource
protected IModule parseResource(@NonNull URI resource, @NonNull Deque<URI> visitedResources) throws IOException
Description copied from class:AbstractLoader
Parse the providedresource
.- Specified by:
parseResource
in classAbstractLoader<IModule>
- 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
protected gov.nist.secauto.metaschema.core.model.xml.xmlbeans.METASCHEMADocument parseModule(@NonNull URI resource) throws IOException
Parse the provided XML resource as a Metaschema module.- Parameters:
resource
- the resource to parse- Returns:
- the XMLBeans representation of the Metaschema module
- Throws:
IOException
- if a parsing error occurred
-
-