edu.cs.ai.kreator.control.config
Class AliasStringSelectionConfigurationOption

java.lang.Object
  extended by edu.cs.ai.kreator.control.config.ConfigurationObject
      extended by edu.cs.ai.kreator.control.config.ConfigurationOption
          extended by edu.cs.ai.kreator.control.config.StringSelectionConfigurationOption
              extended by edu.cs.ai.kreator.control.config.AliasStringSelectionConfigurationOption

public class AliasStringSelectionConfigurationOption
extends StringSelectionConfigurationOption

This is a little more sophisticated extension of "StringSelectionConfigurationOption". In principle it models the same, an option with several strings as alternatives. But every string may be addressed by some alias. For example, the alternatives for this option can be {"Naive Operator","Cautious Operator","Conservative Operator", "Priority Operator"} and "Naive Operator" may have the alias "0" and "naive". Both of the last values are valid values for this option and automatically translated. Additionally, every value may have a writeValue, which is used when writing into the configuration.

Author:
Matthias Thimm

Field Summary
protected  java.util.Map<java.lang.String,java.util.List<java.lang.Object>> aliases
          This field holds for any possible values "val" a list of possible aliases "aliases.get('val')".
protected  java.util.Map<java.lang.String,java.lang.String> writeValues
          The write values for the values.
 
Fields inherited from class edu.cs.ai.kreator.control.config.StringSelectionConfigurationOption
selectableValues
 
Fields inherited from class edu.cs.ai.kreator.control.config.ConfigurationOption
REQUIRES_NO_RESTART, REQUIRES_RESTART
 
Fields inherited from class edu.cs.ai.kreator.control.config.ConfigurationObject
IS_EDITABLE, IS_INVISIBLE, IS_NOT_EDITABLE, IS_VISIBLE, PATHCAPTION_DELIMITER, PATHID_DELIMITER
 
Constructor Summary
AliasStringSelectionConfigurationOption(java.lang.String id, java.lang.String caption, java.lang.String description)
           
AliasStringSelectionConfigurationOption(java.lang.String id, java.lang.String caption, java.lang.String description, int requiresRestart)
           
AliasStringSelectionConfigurationOption(java.lang.String id, java.lang.String caption, java.lang.String description, int visible, int editable)
           
AliasStringSelectionConfigurationOption(java.lang.String id, java.lang.String caption, java.lang.String description, int visible, int editable, int requiresRestart)
           
 
Method Summary
 void addAlias(java.lang.String value, java.lang.Object alias)
          This method adds the given "alias" to the list of possible aliases of "value".
 boolean isValid(java.lang.Object value)
          Checks whether the given value object is valid for this option.
 java.lang.Object parseValue(java.lang.String value)
          Parses the given value (read from the XML) into a usable format appropriate for usage.
 void setWriteValue(java.lang.String value, java.lang.String writeValue)
          Sets the given writeValue for value.
 java.lang.String writeValue(java.lang.Object value)
          Translates the given value to a string appropriate to be saved in the XML.
 
Methods inherited from class edu.cs.ai.kreator.control.config.StringSelectionConfigurationOption
addSelectableValue, getSelectableValues
 
Methods inherited from class edu.cs.ai.kreator.control.config.ConfigurationOption
getDefaultValue, hasDefaultValue, requiresRestart, setDefaultValue
 
Methods inherited from class edu.cs.ai.kreator.control.config.ConfigurationObject
getCaption, getDescription, getId, getParent, getPathCaption, getPathId, hasParent, isEditable, isVisible, setParent, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

aliases

protected java.util.Map<java.lang.String,java.util.List<java.lang.Object>> aliases
This field holds for any possible values "val" a list of possible aliases "aliases.get('val')".


writeValues

protected java.util.Map<java.lang.String,java.lang.String> writeValues
The write values for the values. A value "val" is saved into the configuration as "writeVaules.get('val')".

Constructor Detail

AliasStringSelectionConfigurationOption

public AliasStringSelectionConfigurationOption(java.lang.String id,
                                               java.lang.String caption,
                                               java.lang.String description)

AliasStringSelectionConfigurationOption

public AliasStringSelectionConfigurationOption(java.lang.String id,
                                               java.lang.String caption,
                                               java.lang.String description,
                                               int visible,
                                               int editable)

AliasStringSelectionConfigurationOption

public AliasStringSelectionConfigurationOption(java.lang.String id,
                                               java.lang.String caption,
                                               java.lang.String description,
                                               int requiresRestart)

AliasStringSelectionConfigurationOption

public AliasStringSelectionConfigurationOption(java.lang.String id,
                                               java.lang.String caption,
                                               java.lang.String description,
                                               int visible,
                                               int editable,
                                               int requiresRestart)
Method Detail

addAlias

public void addAlias(java.lang.String value,
                     java.lang.Object alias)
              throws java.lang.IllegalArgumentException
This method adds the given "alias" to the list of possible aliases of "value".

Parameters:
value - a value of this option.
alias - an alias for the given option.
Throws:
java.lang.IllegalArgumentException - if the value is not valid for this option.

setWriteValue

public void setWriteValue(java.lang.String value,
                          java.lang.String writeValue)
Sets the given writeValue for value.

Parameters:
value - a value for this option.
writeValue - the string to be used when writing the configuration.

isValid

public boolean isValid(java.lang.Object value)
Description copied from class: ConfigurationOption
Checks whether the given value object is valid for this option.

Overrides:
isValid in class StringSelectionConfigurationOption
Parameters:
value - a value.
Returns:
"TRUE" if the given value is valid for this option.

parseValue

public java.lang.Object parseValue(java.lang.String value)
                            throws java.lang.IllegalArgumentException
Description copied from class: ConfigurationOption
Parses the given value (read from the XML) into a usable format appropriate for usage. NOTE: This is the inverse to ConfigurationOption#writeValue(java.langObject)

Overrides:
parseValue in class StringSelectionConfigurationOption
Parameters:
value - a value as string.
Returns:
the option's value in an appropriate format.
Throws:
java.lang.IllegalArgumentException - if the string could not be parsed.

writeValue

public java.lang.String writeValue(java.lang.Object value)
                            throws java.lang.IllegalArgumentException
Description copied from class: ConfigurationOption
Translates the given value to a string appropriate to be saved in the XML. This method should only be invoked on a value if ConfigurationOption#isValid(java.lang.Object) verified the validity of the value. NOTE: This is the inverse to ConfigurationOption#parseValue(java.lang.String)

Overrides:
writeValue in class StringSelectionConfigurationOption
Parameters:
value - a value of this option.
Returns:
a string representation of the value.
Throws:
java.lang.IllegalArgumentException - if the value does not conform to this option.