gov.llnl.babel.config
Class Configuration

java.lang.Object
  extended by 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.


Constructor Summary
Configuration()
          The constructor for the Configuration class initializes the profile database.
 
Method Summary
 java.util.Map getConfiguration(java.lang.String language, java.lang.String profile_name)
          Return the configuration information associated with a language and a profile name.
 java.util.Set getLanguages()
          Return the languages supported by the Babel compiler as a set of strings.
 Profile getProfile(java.lang.String language, java.lang.String profile_name)
          Return the profile associated with a language and a profile name.
 java.util.Set getProfileNames(java.lang.String language)
          Given a particular language, return the valid profile names available for that language.
 void readConfiguration(java.lang.String uri)
          Parse the specified XML document to retrieve machine configuration information.
 void setMetadataDescription(Metadata metadata)
          Profide the metadata description that will be used to validate the configuration input file.
 void setMetadataDescription(java.lang.String URI)
          Provide 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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.

Method Detail

getLanguages

public java.util.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.


getProfileNames

public java.util.Set getProfileNames(java.lang.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.


getProfile

public Profile getProfile(java.lang.String language,
                          java.lang.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.


getConfiguration

public java.util.Map getConfiguration(java.lang.String language,
                                      java.lang.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.


setMetadataDescription

public void setMetadataDescription(java.lang.String URI)
                            throws java.io.IOException,
                                   org.xml.sax.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.

Throws:
java.io.IOException
org.xml.sax.SAXException

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.

Throws:
InvalidConfiguration

readConfiguration

public void readConfiguration(java.lang.String uri)
                       throws java.io.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.

Throws:
java.io.IOException
InvalidConfiguration