gov.llnl.babel.config
Class Configuration
java.lang.Object
gov.llnl.babel.config.Configuration
public class Configuration
extends java.lang.Object
Class Configuration
contains configuration information
from the machine configuration database for the Babel compiler. It
defines the languages supported by the Babel compiler, the valid
configuration profiles for each language, and the parameter choices
for each option. An optional Metadata
object may be
provided to validate the correctness of the configuration information.
Configuration() - The constructor for the
Configuration class
initializes the profile database.
|
Map | getConfiguration(String language, String profile_name) - Return the configuration information associated with a language
and a profile name.
|
Set | getLanguages() - Return the languages supported by the Babel compiler as a set of
strings.
|
Profile | getProfile(String language, String profile_name) - Return the profile associated with a language and a profile
name.
|
Set | getProfileNames(String language) - Given a particular language, return the valid profile names
available for that language.
|
void | readConfiguration(String uri) - Parse the specified XML document to retrieve machine configuration
information.
|
void | setMetadataDescription(String URI) - Provide the metadata description that will be used to validate
the configuration input file.
|
void | setMetadataDescription(Metadata metadata) - Profide the metadata description that will be used to validate
the configuration input file.
|
void | validateProfile(Profile profile) - Validate the profile against the metadata description set by a
previous call to
setMetadataDescription .
|
Configuration
public Configuration()
The constructor for the Configuration
class
initializes the profile database. Machine configuration
profiles are read into the configuration object using method
readConfiguration
.
getConfiguration
public Map getConfiguration(String language,
String profile_name)
Return the configuration information associated with a language
and a profile name. The configuration information is held in a
Map of (keyword,value) pairs, where both keyword and value are
strings. This routine will return null if the language or the
profile name is invalid.
getLanguages
public Set getLanguages()
Return the languages supported by the Babel compiler as a set of
strings. This return argument will never be null, although the
map may not contain any entries.
getProfile
public Profile getProfile(String language,
String profile_name)
Return the profile associated with a language and a profile
name. This routine will return null if the language or the
profile name is invalid.
getProfileNames
public Set getProfileNames(String language)
Given a particular language, return the valid profile names
available for that language. This routine will return null
if the language is not supported. The set of profile names
will be empty if no profiles are defined for the language.
readConfiguration
public void readConfiguration(String uri)
throws IOException,
InvalidConfiguration
Parse the specified XML document to retrieve machine configuration
information. This private method builds the internal class data
structures based on the XML machine configuration document. It
first creates a DOM document using the XML DOM parser and then
analyzes the structure of that document. Finally, it checks the
validity of that document using validateProfile
.
setMetadataDescription
public void setMetadataDescription(String URI)
throws IOException,
SAXException
Provide the metadata description that will be used to validate
the configuration input file. Although the XML DTD provides
some amount of validation, the metadata description is required
to verify that all options exist and the chosen values for each
option are valid. An IOException
will be thrown if
the URI is invalid and a SAXException
will be thrown
if a parse error occurs while reading the XML metadata file.
setMetadataDescription
public void setMetadataDescription(Metadata metadata)
Profide the metadata description that will be used to validate
the configuration input file. If null, then validation will be
disabled.
validateProfile
public void validateProfile(Profile profile)
throws InvalidConfiguration
Validate the profile against the metadata description set by a
previous call to setMetadataDescription
. If no
previous metadata profile was set, then no validation will be
performed. If the profile is invalid, then an exception of type
InvalidConfigutation
will be thrown.