Class 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 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

      • 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 the resource based on the provided xmlObject.
        Parameters:
        resource - the URI of the resource being parsed
        xmlObject - the XML beans object to parse
        importedModules - previously parsed Metaschema modules imported by the provided resource
        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 provided resource.
        Specified by:
        parseResource in class AbstractLoader<IModule>
        Parameters:
        resource - the resource to parse
        visitedResources - a stack representing previously parsed resources imported by the provided resource
        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