OSFI-Java  3.10.0
OpenSF Integration Library
esa.opensf.osfi.ParamReader Class Reference

Classes

class  ParamParsingException
 
enum  WarningType
 

Public Member Functions

 ParamReader (final String xmlFile, final String xsdFile) throws FileNotFoundException, XmlParseException
 
 ParamReader (String xmlFile) throws FileNotFoundException, XmlParseException
 
 ParamReader (Element el, String pathPrefix) throws XmlParseException
 
boolean validateAgainst (final String xsdFile)
 
boolean validateAgainstInternalSchema ()
 
Parameter getParameter (String name)
 
List< ParametergetParameters (String groupName)
 
Map< String, ParametergetAllParameters ()
 
boolean existParameter (String name)
 
void setParameter (String paramName, Parameter value)
 
void write ()
 

Static Public Member Functions

static LoadResult< ParamReaderload (final LoadResult< Document > xml, final boolean stopOnSingleParamError, final Map< String, Parameter > map, final Set< WarningType > suppWarns)
 
static LoadResult< ParamReaderload (final LoadResult< Document > xml, final boolean stopOnSingleParamError, final Map< String, Parameter > map)
 
static LoadResult< ParamReaderload (final LoadResult< Document > xml, final boolean stopOnSingleParamError)
 
static boolean isStandardAttribute (String key)
 

Detailed Description

ParamReader.
Constructs the list of parameters associated with a model stored in a XML configuration file.
Uses the DOM tree specification.

Author
ridr

Constructor & Destructor Documentation

◆ ParamReader() [1/3]

esa.opensf.osfi.ParamReader.ParamReader ( final String  xmlFile,
final String  xsdFile 
) throws FileNotFoundException, XmlParseException

Creates an instance of the ParamReader class, parses a given configuration XML file and stores every valid parameter.

Parameters
xmlFileConfiguration XML file
xsdFileConfiguration XSD schema. Validating against an XSD schema is optional
Exceptions
XmlParseExceptionif error while parsing
FileNotFoundExceptionif the XML file does not exist or cannot be read
Deprecated:
Use the single argument version and call validateAgainst(String)

References esa.opensf.osfi.XMLParser.read().

◆ ParamReader() [2/3]

esa.opensf.osfi.ParamReader.ParamReader ( String  xmlFile) throws FileNotFoundException, XmlParseException

Parses a given configuration XML file and stores the parameters read from it.

Parameters
xmlFileConfiguration XML file
Exceptions
XmlParseExceptionif any error occurs while parsing
FileNotFoundExceptionif the XML file does not exist or cannot be read

References esa.opensf.osfi.xmlutils.XmlFiles.load().

◆ ParamReader() [3/3]

esa.opensf.osfi.ParamReader.ParamReader ( Element  el,
String  pathPrefix 
) throws XmlParseException

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
elElement 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.
pathPrefixPath up to and including el. If not null, paths of child parameters/groups will be prefixed with this string plus a period.
Exceptions
XmlParseExceptionif error while parsing

Member Function Documentation

◆ existParameter()

boolean esa.opensf.osfi.ParamReader.existParameter ( String  name)

Checks the existence of a parameter within a configuration file.

Parameters
nameParameter name (full path and name)
Returns
boolean True if the parameter exists False otherwise.

◆ getAllParameters()

Map<String, Parameter> esa.opensf.osfi.ParamReader.getAllParameters ( )
Returns
A map containing all stored parameters.

◆ getParameter()

Parameter esa.opensf.osfi.ParamReader.getParameter ( String  name)

Retrieves the parameter object corresponding with given name in the configuration file.

Parameters
nameParameter full path.
Returns
Parameter instance, or null if no parameter exists with that name.

◆ getParameters()

List<Parameter> esa.opensf.osfi.ParamReader.getParameters ( String  groupName)
Returns
List of parameters under a certain group, including direct and indirect children.
Parameters
groupNameFull name of the group

◆ isStandardAttribute()

static boolean esa.opensf.osfi.ParamReader.isStandardAttribute ( String  key)
static

Determines whether a given parameter attribute is E2E-ICD standard.

Parameters
keyattribute name
Returns
true if the parameter is interpreted by this class, false otherwise.
See also
#collectOtherAttributes(Element, Map, java.util.function.Supplier)

◆ load() [1/3]

static LoadResult<ParamReader> esa.opensf.osfi.ParamReader.load ( final LoadResult< Document >  xml,
final boolean  stopOnSingleParamError 
)
static

Parse the contents of an XML document into OSFI parameters. Equivalent to calling the other overload with a new empty map as the third argument.

Parameters
xmlReturned by calling one of the loader functions in XmlFiles
stopOnSingleParamErrorIf 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
#load(LoadResult, boolean, Map)

References esa.opensf.osfi.ParamReader.load().

◆ load() [2/3]

static LoadResult<ParamReader> esa.opensf.osfi.ParamReader.load ( final LoadResult< Document >  xml,
final boolean  stopOnSingleParamError,
final Map< String, Parameter map 
)
static

Parse the contents of an XML document into OSFI parameters. Equivalent to calling load(LoadResult, boolean, Map, Set) with a a default set of suppressed warnings.

Parameters
xmlReturned by calling one of the loader functions in XmlFiles
stopOnSingleParamErrorIf true, an error loading a single parameter will stop the process. Otherwise, only a fatal error (e.g. a structural).
mapContainer 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(LoadResult, boolean, Map, Set)

References esa.opensf.osfi.ParamReader.load().

◆ load() [3/3]

static LoadResult<ParamReader> esa.opensf.osfi.ParamReader.load ( final LoadResult< Document >  xml,
final boolean  stopOnSingleParamError,
final Map< String, Parameter map,
final Set< WarningType suppWarns 
)
static

Parse the contents of an XML document into OSFI parameters.

Parameters
xmlReturned by calling one of the loader functions in XmlFiles
stopOnSingleParamErrorIf true, an error loading a single parameter will stop the process. Otherwise, only a fatal error (e.g. a structural).
mapContainer that will be used to store the parameters read.
suppWarnsThe 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.

References esa.opensf.osfi.LoadResult< R >.loadEvents, esa.opensf.osfi.LoadResult< R >.result, and esa.opensf.osfi.LoadResult< R >.source.

◆ setParameter()

void esa.opensf.osfi.ParamReader.setParameter ( String  paramName,
Parameter  value 
)

Changes the stored value of a certain parameter. Shows an error if cannot find parameter.

Parameters
paramName- full name of the parameter
value- new value
Exceptions
IllegalArgumentExceptionif parameter did not already exist

References esa.opensf.osfi.Logger.error(), esa.opensf.osfi.ParamReader.existParameter(), and esa.opensf.osfi.Logger.warning().

◆ validateAgainst()

boolean esa.opensf.osfi.ParamReader.validateAgainst ( final String  xsdFile)

Validate the XML file read against the given XSD schema.

Returns
true if the validation succeeds, false otherwise.
Parameters
xsdFilePath to a schema file which must exist
Exceptions
IllegalArgumentExceptionif the schema cannot be loaded

References esa.opensf.osfi.xmlutils.DomUtils.validateAgainst().

◆ validateAgainstInternalSchema()

boolean esa.opensf.osfi.ParamReader.validateAgainstInternalSchema ( )

Validate the XML file read against the XSD schema referenced in the file itself.

Returns
true if the validation succeeds, false otherwise.

References esa.opensf.osfi.xmlutils.DomUtils.validateAgainstInternalSchema().

◆ write()

void esa.opensf.osfi.ParamReader.write ( )

Prints a textual representation of the list of Parameters on screen.

References esa.opensf.osfi.Logger.info().


The documentation for this class was generated from the following file: