- All Implemented Interfaces:
Serializable
A GMCConfiguration is composed of a number of GMCSection's, each of which encapsulates a set of key-value pairs, where the keys correspond to commandline parameters and the value is the value assigned to that parameter. In addition, there can be any number of "free arguments" that are not assigned to any parameter. The free arguments are always strings.
A configuration is typically generated by parsing a command line, or at least
the suffix of a command line after the initial command(s). The command line
suffix -verbose -errBound=10 filename.c, for example, would
yield a configuration with an anonymous GMCSection in which "verbose" is
mapped to true, "errBound" is mapped to the integer 10, and with one free
argument "fileName.c".
A configuration has associated to it a set of options, which are specified when the configuration is instantiated. And each GMCSection has associated to it a configuration.
Each option is an instance of class Option. An option has a name and
a type. The type is one of STRING, INTEGER, DOUBLE, BOOLEAN, or MAP. The type
determines the kind of value that can be assigned to an option. The first
four are "scalar" types and take values of type String, Integer, Double, and
Boolean, respectively.
An option of MAP type may be assigned a value of type Mapinvalid input: '<'String,Object>.
This kind of option is provided for command line arguments such as
-inputX=10 -inputB=true -inputZ="hello". This constructs a map
from String to Object which maps "X" to the Integer 10, "B" to the Boolean
true, and "Z" to the String "hello". This map is the value that is assigned
to the option named "input". In general, the values of the map can be any
scalar values, and their types will be inferred from their format. For
example 1.0 will be interpreted as a Double, 1 as an Integer, "1" (with
quotes) a String.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe reserved name of the anonymous GMCSection of a configuration. -
Constructor Summary
ConstructorsConstructorDescriptionGMCConfiguration(Collection<Option> options) Constructs new configuration with the set of options obtained from the given collection. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSection(GMCSection section) Adds a section to the NON-anonymous section map.clone()Returns a deep copy of this configuration.Returns the anonymous sectionintReturns the number of NON-anonymous sections.Returns the option with the given name associated to this configuration, or null if there is none.Returns the set of options associated to this configuration.booleangetSection(String name) Returns the section with the given name, or null if there is none.Returns an iterable object of the NON-anonymous sections.booleanisQuiet()voidprint(PrintStream out) Prints the current state of this configuration in a manner similar to what would appear on a commandline.booleanvoidread(GMCConfiguration that) Modifies this configuration by reading in the values of the given configuration and using those to set values of this one.voidsetAnonymousSection(GMCSection section) Updates the anonymous section with the given section.voidvoidsetPrintTransition(boolean printTransitions) voidsetQuiet(boolean isQuiet) voidsetSaveStates(boolean saveStates)
-
Field Details
-
ANONYMOUS_SECTION
The reserved name of the anonymous GMCSection of a configuration.- See Also:
-
out
-
-
Constructor Details
-
GMCConfiguration
Constructs new configuration with the set of options obtained from the given collection. The set of options associated to this configuration is determined from the given collection. Duplicates in the collection will be ignored. The new configuration will be empty: i.e., it will have no entries, i.e., nothing will be assigned to any option.- Parameters:
options- a collection of non-null options; duplicates will be ignored. The options must have distinct names- Throws:
IllegalArgumentException- if two options in the collection have the same name
-
-
Method Details
-
getOptions
Returns the set of options associated to this configuration. This returns all options associated to this configuration, not just those that have a value assigned to them.- Returns:
- the set of options
-
getOption
Returns the option with the given name associated to this configuration, or null if there is none.- Parameters:
name- the name of an option- Returns:
- the option with that name
-
getSection
Returns the section with the given name, or null if there is none.- Parameters:
name- the name of the section- Returns:
- the section with that name
-
getAnonymousSection
Returns the anonymous section- Returns:
- the anonymous sections
-
getNumSections
public int getNumSections()Returns the number of NON-anonymous sections.- Returns:
- the number of NON-anonymous sections.
-
setAnonymousSection
Updates the anonymous section with the given section. Also updates the configuration associates with the given section to be this configuration.- Parameters:
section- The section to be used as the anonymous section of this configuration.
-
isQuiet
public boolean isQuiet() -
setQuiet
public void setQuiet(boolean isQuiet) -
addSection
Adds a section to the NON-anonymous section map. Also updates the configuration associates with the given section to be this configuration.
Precondition:!section.getName().equals(DEFAULT_SECTION).- Parameters:
section- The section to be added
-
clone
Returns a deep copy of this configuration. The two configurations will share references to the same options, and to the same Strings, but not to anything else. As options and strings are immutable, this should not be a problem.- Returns:
- deep copy of this configuration
-
getSections
Returns an iterable object of the NON-anonymous sections.- Returns:
- the iterable object of the NON-anonymous sections.
-
read
Modifies this configuration by reading in the values of the given configuration and using those to set values of this one. Existing entries in this one may be overwritten in the process.- Parameters:
that- another configuration; the set of options associated to that should be a subset of the set of options associated to this
-
print
Prints the current state of this configuration in a manner similar to what would appear on a commandline. Each scalar assignment appears on one line. At the end the free arguments are printed, one on each line.- Parameters:
out- print stream to which to print
-
printTransitions
public boolean printTransitions() -
setPrintTransition
public void setPrintTransition(boolean printTransitions) -
setPrintStream
-
setSaveStates
public void setSaveStates(boolean saveStates) -
getSaveStates
public boolean getSaveStates()
-