java.lang.Object
esa.opensf.osfi.ParamReader
ParamReader.
Constructs the list of parameters associated with a model stored in a XML configuration file.
Uses the DOM tree specification.
Constructs the list of parameters associated with a model stored in a XML configuration file.
Uses the DOM tree specification.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnum to represent different categories of warnings. -
Constructor Summary
ConstructorsConstructorDescriptionParamReader(String xmlFile) Parses a given configuration XML file and stores the parameters read from it.ParamReader(String xmlFile, String xsdFile) Deprecated.ParamReader(Element el, String pathPrefix) Parses a given configuration XML subtree and stores the parameters read from it. -
Method Summary
Modifier and TypeMethodDescriptionbooleanexistParameter(String name) Checks the existence of a parameter within a configuration file.getParameter(String name) Retrieves the parameter object corresponding with given name in the configuration file.getParameters(String groupName) static booleanDetermines whether a given parameter attribute is E2E-ICD standard.static LoadResult<ParamReader>load(LoadResult<Document> xml, boolean stopOnSingleParamError) Parse the contents of an XML document into OSFI parameters.static LoadResult<ParamReader>Parse the contents of an XML document into OSFI parameters.static LoadResult<ParamReader>load(LoadResult<Document> xml, boolean stopOnSingleParamError, Map<String, Parameter> map, Set<ParamReader.WarningType> suppWarns) Parse the contents of an XML document into OSFI parameters.voidsetParameter(String paramName, Parameter value) Changes the stored value of a certain parameter.booleanvalidateAgainst(String xsdFile) Validate the XML file read against the given XSD schema.booleanValidate the XML file read against the XSD schema referenced in the file itself.voidwrite()Prints a textual representation of the list of Parameters on screen.
-
Constructor Details
-
ParamReader
@Deprecated(since="3.5.0") public ParamReader(String xmlFile, String xsdFile) throws FileNotFoundException, XmlParseException Deprecated.Use the single argument version and callvalidateAgainst(String)Creates an instance of the ParamReader class, parses a given configuration XML file and stores every valid parameter.- Parameters:
xmlFile- Configuration XML filexsdFile- Configuration XSD schema. Validating against an XSD schema is optional- Throws:
XmlParseException- if error while parsingFileNotFoundException- if the XML file does not exist or cannot be read
-
ParamReader
Parses a given configuration XML file and stores the parameters read from it.- Parameters:
xmlFile- Configuration XML file- Throws:
XmlParseException- if any error occurs while parsingFileNotFoundException- if the XML file does not exist or cannot be read
-
ParamReader
Parses a given configuration XML subtree and stores the parameters read from it. This allows the user to read parameter objects from an OSFI-compliant fragment of a non-OSFI file.- Parameters:
el- Element that will be considered the root of the given tree. Note that this element is not parsed itself, only its children are. Thus, if a single parameter is to be parsed, it needs to be wrapped by an element.pathPrefix- Path up to and including el. If not null, paths of child parameters/groups will be prefixed with this string plus a period.- Throws:
XmlParseException- if error while parsing
-
-
Method Details
-
load
public static LoadResult<ParamReader> load(LoadResult<Document> xml, boolean stopOnSingleParamError, Map<String, Parameter> map, Set<ParamReader.WarningType> suppWarns) Parse the contents of an XML document into OSFI parameters.- Parameters:
xml- Returned by calling one of the loader functions inXmlFilesstopOnSingleParamError- If true, an error loading a single parameter will stop the process. Otherwise, only a fatal error (e.g. a structural).map- Container that will be used to store the parameters read.suppWarns- The types of warnings that will be suppressed.- Returns:
- Result object with the parsed parameters (if successful) and the list of warnings and errors ocurred during the parsing.
-
load
public static LoadResult<ParamReader> load(LoadResult<Document> xml, boolean stopOnSingleParamError, Map<String, Parameter> map) Parse the contents of an XML document into OSFI parameters. Equivalent to callingload(LoadResult, boolean, Map, Set)with a a default set of suppressed warnings.- Parameters:
xml- Returned by calling one of the loader functions inXmlFilesstopOnSingleParamError- If true, an error loading a single parameter will stop the process. Otherwise, only a fatal error (e.g. a structural).map- Container that will be used to store the parameters read.- Returns:
- Result object with the parsed parameters (if successful) and the list of warnings and errors ocurred during the parsing.
- See Also:
-
load
public static LoadResult<ParamReader> load(LoadResult<Document> xml, boolean stopOnSingleParamError) Parse the contents of an XML document into OSFI parameters. Equivalent to callingthe other overloadwith a new empty map as the third argument.- Parameters:
xml- Returned by calling one of the loader functions inXmlFilesstopOnSingleParamError- If true, an error loading a single parameter will stop the process. Otherwise, only a fatal error (e.g. a structural)- Returns:
- Result object with the parsed parameters (if successful) and the list of warnings and errors ocurred during the parsing.
- See Also:
-
validateAgainst
Validate the XML file read against the given XSD schema.- Parameters:
xsdFile- Path to a schema file which must exist- Returns:
- true if the validation succeeds, false otherwise.
- Throws:
IllegalArgumentException- if the schema cannot be loaded
-
validateAgainstInternalSchema
public boolean validateAgainstInternalSchema()Validate the XML file read against the XSD schema referenced in the file itself.- Returns:
- true if the validation succeeds, false otherwise.
-
getParameter
Retrieves the parameter object corresponding with given name in the configuration file.- Parameters:
name- Parameter full path.- Returns:
- Parameter instance, or null if no parameter exists with that name.
-
getParameters
- Parameters:
groupName- Full name of the group- Returns:
- List of parameters under a certain group, including direct and indirect children.
-
getAllParameters
- Returns:
- A map containing all stored parameters.
-
existParameter
Checks the existence of a parameter within a configuration file.
- Parameters:
name- Parameter name (full path and name)- Returns:
- boolean True if the parameter exists False otherwise.
-
setParameter
Changes the stored value of a certain parameter. Shows an error if cannot find parameter.- Parameters:
paramName- - full name of the parametervalue- - new value- Throws:
IllegalArgumentException- if parameter did not already exist
-
write
public void write()Prints a textual representation of the list of Parameters on screen.
-
isStandardAttribute
Determines whether a given parameter attribute is E2E-ICD standard.- Parameters:
key- attribute name- Returns:
- true if the parameter is interpreted by this class, false otherwise.
- See Also:
-
collectOtherAttributes(Element, Map, java.util.function.Supplier)
-
validateAgainst(String)