Class XMLRequirementsParser
- java.lang.Object
-
- gov.nist.secauto.decima.xml.requirement.XMLRequirementsParser
-
- All Implemented Interfaces:
RequirementsParser
public class XMLRequirementsParser extends Object implements RequirementsParser
-
-
Constructor Summary
Constructors Constructor Description XMLRequirementsParser()XMLRequirementsParser(List<Source> extensionSchemaSources)Constructs a requirements parser with a list of extension schema that describe possible requirements definition extensions.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.jdom2.input.sax.SAXEngineinitSAXEngine(Source[] schemaSources)static RequirementsParserinstance()Retrieve a singleton instance of a basicXMLRequirementsParserthat supports no extensions.voidparse(File file, RequirementAppender appender)Parse requirements from a file source.voidparse(URL url, RequirementAppender appender)Parse requirements from a URL source.protected voidparseMetadata(org.jdom2.Element element, AbstractRequirement requirement)protected BaseRequirementparseRequirement(org.jdom2.Element requirement, Map<String,Specification> resources, URI base)protected voidparseRequirements(org.jdom2.Document document, URI base, RequirementAppender appender)protected Map<String,Specification>parseResources(List<org.jdom2.Element> resources, URI base)
-
-
-
Constructor Detail
-
XMLRequirementsParser
public XMLRequirementsParser() throws org.jdom2.JDOMException, MalformedURLException, SAXException- Throws:
org.jdom2.JDOMExceptionMalformedURLExceptionSAXException
-
XMLRequirementsParser
public XMLRequirementsParser(List<Source> extensionSchemaSources) throws org.jdom2.JDOMException, MalformedURLException, SAXException
Constructs a requirements parser with a list of extension schema that describe possible requirements definition extensions.- Parameters:
extensionSchemaSources- extension schema that describe requirements definition extensions- Throws:
org.jdom2.JDOMException- if an error occurred while constructing the JDOM2 SAX parserMalformedURLException- if one of the schema sources was a malformed URLSAXException- if an error occurred while parsing the schema
-
-
Method Detail
-
instance
public static RequirementsParser instance()
Retrieve a singleton instance of a basicXMLRequirementsParserthat supports no extensions. This singleton instance is constructed by callingXMLRequirementsParser(). If a parser is needed that supports extension elements and attributes, then an new parser instance must be constructed using the constructorXMLRequirementsParser(List).- Returns:
- a singleton instance of the
XMLRequirementsParser - Throws:
RuntimeException- in the rare case where a new requirement parser failed to be created due to another error- See Also:
XMLRequirementsParser()
-
initSAXEngine
protected org.jdom2.input.sax.SAXEngine initSAXEngine(Source[] schemaSources) throws MalformedURLException, SAXException, org.jdom2.JDOMException
- Throws:
MalformedURLExceptionSAXExceptionorg.jdom2.JDOMException
-
parse
public void parse(File file, RequirementAppender appender) throws RequirementsParserException
Parse requirements from a file source.- Parameters:
file- the file containing the requirementsappender- theRequirementAppenderused to add the parsed requirements to an associatedRequirementsManager- Throws:
RequirementsParserException- if an error occurred while parsing the requirements
-
parse
public void parse(URL url, RequirementAppender appender) throws RequirementsParserException, URISyntaxException
Parse requirements from a URL source.- Specified by:
parsein interfaceRequirementsParser- Parameters:
url- the URL pointing to the resource containing the requirementsappender- theRequirementAppenderused to add the parsed requirements to an associatedRequirementsManager- Throws:
RequirementsParserException- if an error occurred while parsing the requirementsURISyntaxException- if the provided URL is not a valid URI
-
parseRequirements
protected void parseRequirements(org.jdom2.Document document, URI base, RequirementAppender appender)
-
parseResources
protected Map<String,Specification> parseResources(List<org.jdom2.Element> resources, URI base)
-
parseRequirement
protected BaseRequirement parseRequirement(org.jdom2.Element requirement, Map<String,Specification> resources, URI base)
-
parseMetadata
protected void parseMetadata(org.jdom2.Element element, AbstractRequirement requirement)
-
-