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

java.lang.Object
  extended by edu.cs.ai.kreator.control.config.ConfigurationObject
      extended by edu.cs.ai.kreator.control.config.ConfigurationOption
Direct Known Subclasses:
BooleanConfigurationOption, DoubleBoolConfigOption, DoubleConfigurationOption, FontStyleConfigurationOption, IntBoolConfigOption, IntegerConfigurationOption, IntegerWithoutSpinnerConfigurationOption, StringBooleanConfigurationOption, StringConfigurationOption, StringListConfigurationOption, StringSelectionConfigurationOption

public abstract class ConfigurationOption
extends ConfigurationObject

This class represents the template for a single configuration option.

Author:
Matthias Thimm

Field Summary
static int REQUIRES_NO_RESTART
          Static constant for a configuration option that requires no restart.
static int REQUIRES_RESTART
          Static constant for a configuration option that requires a 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
ConfigurationOption(java.lang.String id, java.lang.String caption, java.lang.String description)
           
ConfigurationOption(java.lang.String id, java.lang.String caption, java.lang.String description, int requiresRestart)
          Creates a new configuration option with the given caption, id, and restart flag, that is both visible and editable and has no parent.
ConfigurationOption(java.lang.String id, java.lang.String caption, java.lang.String description, int visible, int editable)
           
ConfigurationOption(java.lang.String id, java.lang.String caption, java.lang.String description, int visible, int editable, int requiresRestart)
          Creates a new configuration object with the given id, caption, the given visibility, the given editibility, the given restart flag and no parent.
 
Method Summary
 java.lang.Object getDefaultValue()
          Returns the default value of this configuration option.
 boolean hasDefaultValue()
          Checks whether this configuration option features a default value.
abstract  boolean isValid(java.lang.Object value)
          Checks whether the given value object is valid for this option.
abstract  java.lang.Object parseValue(java.lang.String value)
          Parses the given value (read from the XML) into a usable format appropriate for usage.
 boolean requiresRestart()
          Checks whether this configuration option requires restart of KReator after change.
 void setDefaultValue(java.lang.Object defaultValue)
          Sets this option's default value
abstract  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.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

REQUIRES_RESTART

public static final int REQUIRES_RESTART
Static constant for a configuration option that requires a restart.

See Also:
Constant Field Values

REQUIRES_NO_RESTART

public static final int REQUIRES_NO_RESTART
Static constant for a configuration option that requires no restart.

See Also:
Constant Field Values
Constructor Detail

ConfigurationOption

public ConfigurationOption(java.lang.String id,
                           java.lang.String caption,
                           java.lang.String description,
                           int requiresRestart)
Creates a new configuration option with the given caption, id, and restart flag, that is both visible and editable and has no parent.

Parameters:
id - The id of this configuration object.
description - The description of this configuration object.
caption - The caption of this configuration object
requiresRestart - one of ConfigurationOption.REQUIRES_RESTART, ConfigurationOption.REQUIRES_NO_RESTART

ConfigurationOption

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

ConfigurationOption

public ConfigurationOption(java.lang.String id,
                           java.lang.String caption,
                           java.lang.String description,
                           int visible,
                           int editable,
                           int requiresRestart)
Creates a new configuration object with the given id, caption, the given visibility, the given editibility, the given restart flag and no parent.

Parameters:
id - The id of this configuration object.
caption - The caption of this configuration object.
description - The description of this configuration object.
visible - whether this configuration object is visible (one of ConfigurationObject.IS_VISIBLE, ConfigurationObject.IS_INVISIBLE).
editable - whether this configuration object is editable (one of ConfigurationObject.IS_EDITABLE, ConfigurationObject.IS_NOT_EDITABLE).
requiresRestart - one of ConfigurationOption.REQUIRES_RESTART, ConfigurationOption.REQUIRES_NO_RESTART

ConfigurationOption

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

requiresRestart

public boolean requiresRestart()
Checks whether this configuration option requires restart of KReator after change.

Returns:
"true" iff this configuration option requires restart of KReator after change.

getDefaultValue

public java.lang.Object getDefaultValue()
Returns the default value of this configuration option.

Returns:
the default value of this configuration option.

setDefaultValue

public void setDefaultValue(java.lang.Object defaultValue)
Sets this option's default value

Parameters:
defaultValue - a default value.

hasDefaultValue

public boolean hasDefaultValue()
Checks whether this configuration option features a default value.

Returns:
"TRUE" if this configuration option features a default value, "FALSE" otherwise.

isValid

public abstract boolean isValid(java.lang.Object value)
Checks whether the given value object is valid for this option.

Parameters:
value - a value.
Returns:
"TRUE" if the given value is valid for this option.

parseValue

public abstract java.lang.Object parseValue(java.lang.String value)
                                     throws java.lang.IllegalArgumentException
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)

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 abstract java.lang.String writeValue(java.lang.Object value)
                                     throws java.lang.IllegalArgumentException
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)

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.