Package net.sourceforge.jnlp.config
Class Setting
- java.lang.Object
-
- net.sourceforge.jnlp.config.Setting
-
public class Setting extends java.lang.ObjectRepresents a value for a configuration. Provides methods to get the value as well as marking the value as locked. Each instance of this class has an associated ValueChecker. This checker can be used to check if the current value is valid. The default value _must_ be valid. Null values can not originate externally so are (mostly) considered valid.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringdefaultValueprivate java.lang.Stringdescriptionprivate booleanlockedprivate java.lang.Stringnameprivate java.lang.Stringsourceprivate ValueValidatorvalidatorprivate java.lang.Stringvalue
-
Constructor Summary
Constructors Modifier Constructor Description privateSetting(java.lang.String name, java.lang.String description, boolean locked, ValueValidator validator, java.lang.String defaultValue, java.lang.String value, java.lang.String source)Creates a new Settings object
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Settingcopy()Creates a copy of this setting(package private) SettingcopyValuesFrom(Setting src)Creates a copy of this setting and copies the following attributes fromsrc: - value - locked - sourcestatic SettingcreateDefault(java.lang.String key, java.lang.String value, ValueValidator validator)static SettingcreateFromPropertyFile(java.lang.String key, java.lang.String value, boolean locked, java.net.URL propertyFile)static SettingcreateUnknown(java.lang.String key, java.lang.String value)java.lang.StringgetDefaultValue()java.lang.StringgetDescription()java.lang.StringgetName()java.lang.StringgetSource()ValueValidatorgetValidator()java.lang.StringgetValue()booleanisLocked()voidsetLocked(boolean locked)voidsetValue(java.lang.String value)Note that setting the value is not enforced - it is the caller's responsibility to check if a value is locked or not before setting a new valuejava.lang.StringtoString()
-
-
-
Field Detail
-
name
private final java.lang.String name
-
description
private final java.lang.String description
-
validator
private final ValueValidator validator
-
source
private final java.lang.String source
-
defaultValue
private final java.lang.String defaultValue
-
value
private java.lang.String value
-
locked
private boolean locked
-
-
Constructor Detail
-
Setting
private Setting(java.lang.String name, java.lang.String description, boolean locked, ValueValidator validator, java.lang.String defaultValue, java.lang.String value, java.lang.String source)Creates a new Settings object- Parameters:
name- the name of this settingdescription- a human readable description of this settinglocked- whether this setting is currently lockedvalidator- theValueValidatorthat can be used to validate the valuedefaultValue- the default value of this setting. If this is not a recognized setting, use null.value- the initial value of this settingsource- the origin of the value (a file, or perhaps "<internal>")
-
-
Method Detail
-
createDefault
public static Setting createDefault(java.lang.String key, java.lang.String value, ValueValidator validator)
-
createUnknown
public static Setting createUnknown(java.lang.String key, java.lang.String value)
-
createFromPropertyFile
public static Setting createFromPropertyFile(java.lang.String key, java.lang.String value, boolean locked, java.net.URL propertyFile)
-
copy
public Setting copy()
Creates a copy of this setting
-
copyValuesFrom
Setting copyValuesFrom(Setting src)
Creates a copy of this setting and copies the following attributes fromsrc: - value - locked - source
-
getValidator
public ValueValidator getValidator()
- Returns:
- the
ValueValidatorthat can be used to check if the current value is valid
-
getDefaultValue
public java.lang.String getDefaultValue()
- Returns:
- the default value for this setting. May be null if this is not one of the supported settings
-
getDescription
public java.lang.String getDescription()
- Returns:
- a human readable description of this setting
-
getName
public java.lang.String getName()
- Returns:
- the name (like foo.bar.baz) of this setting
-
getSource
public java.lang.String getSource()
- Returns:
- the source of the current value of this setting. May be a string like "internal" or it may be the location of the properties file
-
getValue
public java.lang.String getValue()
- Returns:
- the current value of this setting
-
isLocked
public boolean isLocked()
- Returns:
- true if this setting is locked
-
setValue
public void setValue(java.lang.String value)
Note that setting the value is not enforced - it is the caller's responsibility to check if a value is locked or not before setting a new value- Parameters:
value- the new value
-
setLocked
public void setLocked(boolean locked)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-