Package com.inductiveautomation.snap.web
Class Settings
- java.lang.Object
-
- com.inductiveautomation.snap.web.Settings
-
- All Implemented Interfaces:
RMJSONArchiver.GetClass
,RMJSONArchiver.GetKeys
,RMJSONArchiver.GetValue
,RMJSONArchiver.SetValue
,RMKey.Get
,RMKey.GetSet
,WebFile.Updater
public class Settings extends java.lang.Object implements RMJSONArchiver.GetKeys, RMJSONArchiver.GetValue, RMJSONArchiver.SetValue, RMJSONArchiver.GetClass, RMKey.GetSet, WebFile.Updater
An object to get, set and store site settings.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
Settings.SettingsList<E>
The List.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListItem(java.lang.String aKey, java.lang.Object aValue)
Adds a list item.void
addListItem(java.lang.String aKey, java.lang.Object aValue, int anIndex)
Adds a list item at given index.protected void
firePropertyChange(java.lang.String aName, java.lang.Object oldVal, java.lang.Object newVal, int anIndex)
Override to forward to parents if present.static Settings
get(WebFile aFile)
Returns the settings for given file.java.lang.Object
get(java.lang.String aKey)
Returns a value.<T> T
get(java.lang.String aKey, java.lang.Class<T> aClass)
Returns a value of a given class.java.lang.Object
get(java.lang.String aKey, java.lang.Object aDefault)
Returns a value.boolean
getBoolValue(java.lang.String aKey)
Returns an bool value.boolean
getBoolValue(java.lang.String aKey, boolean aDefault)
Returns an bool value.WebFile
getFile()
Returns the source file.float
getFloatValue(java.lang.String aKey)
Returns a float value.float
getFloatValue(java.lang.String aKey, float aDefault)
Returns a float value.int
getIntValue(java.lang.String aKey)
Returns an int value.int
getIntValue(java.lang.String aKey, int aDefault)
Returns an int value.java.lang.String
getJSONClass()
Returns a list of keys to be uses to retrieve persistent attributes from an object.java.util.Collection<java.lang.String>
getJSONKeys()
Returns a list of keys to be uses to retrieve persistent attributes from an object.java.lang.Object
getJSONValue(java.lang.String aKey)
Returns a list of keys to be uses to retrieve persistent attributes from an object.java.lang.Object
getKeyValue(java.lang.String aKey)
Settings.SettingsList
getList(java.lang.String aKey)
Returns a List value.Settings.SettingsList
getList(java.lang.String aKey, boolean doCreate)
Returns a List value, with option to create if missing.Settings
getSettings(java.lang.String aKey)
Returns the settings for key.Settings
getSettings(java.lang.String aKey, boolean doCreate)
Returns the settings for key, with option to create if missing.java.lang.String
getStringValue(java.lang.String aKey)
Returns as a String value.java.lang.String
getStringValue(java.lang.String aKey, java.lang.String aDefault)
Returns as a String value.void
put(java.lang.String aKey, java.lang.Object aValue)
Sets a value.java.lang.Object
removeListItem(java.lang.String aKey, int anIndex)
Removes a list item at given index.int
removeListItem(java.lang.String aKey, java.lang.Object aValue)
Removes a list item at given index.void
setJSONValue(java.lang.String aKey, java.lang.Object aValue)
Returns a list of keys to be uses to retrieve persistent attributes from an object.boolean
setKeyValue(java.lang.String aKey, java.lang.Object aValue)
protected java.lang.Object
simplePut(java.lang.String aKey, java.lang.Object aValue)
Sets a value for a simple key without firing property change.java.lang.String
toString()
Standard toString implementation.void
updateFile(WebFile aFile)
Saves the file.
-
-
-
Constructor Detail
-
Settings
public Settings()
Creates new Settings.
-
Settings
public Settings(WebFile aFile)
Creates a new Settings from a byte source.
-
-
Method Detail
-
getFile
public WebFile getFile()
Returns the source file.
-
get
public java.lang.Object get(java.lang.String aKey)
Returns a value.
-
get
public java.lang.Object get(java.lang.String aKey, java.lang.Object aDefault)
Returns a value.
-
get
public <T> T get(java.lang.String aKey, java.lang.Class<T> aClass)
Returns a value of a given class.
-
put
public void put(java.lang.String aKey, java.lang.Object aValue)
Sets a value.
-
simplePut
protected java.lang.Object simplePut(java.lang.String aKey, java.lang.Object aValue)
Sets a value for a simple key without firing property change.
-
getStringValue
public java.lang.String getStringValue(java.lang.String aKey)
Returns as a String value.
-
getStringValue
public java.lang.String getStringValue(java.lang.String aKey, java.lang.String aDefault)
Returns as a String value.
-
getBoolValue
public boolean getBoolValue(java.lang.String aKey)
Returns an bool value.
-
getBoolValue
public boolean getBoolValue(java.lang.String aKey, boolean aDefault)
Returns an bool value.
-
getIntValue
public int getIntValue(java.lang.String aKey)
Returns an int value.
-
getIntValue
public int getIntValue(java.lang.String aKey, int aDefault)
Returns an int value.
-
getFloatValue
public float getFloatValue(java.lang.String aKey)
Returns a float value.
-
getFloatValue
public float getFloatValue(java.lang.String aKey, float aDefault)
Returns a float value.
-
getList
public Settings.SettingsList getList(java.lang.String aKey)
Returns a List value.
-
getList
public Settings.SettingsList getList(java.lang.String aKey, boolean doCreate)
Returns a List value, with option to create if missing.
-
addListItem
public void addListItem(java.lang.String aKey, java.lang.Object aValue)
Adds a list item.
-
addListItem
public void addListItem(java.lang.String aKey, java.lang.Object aValue, int anIndex)
Adds a list item at given index.
-
removeListItem
public java.lang.Object removeListItem(java.lang.String aKey, int anIndex)
Removes a list item at given index.
-
removeListItem
public int removeListItem(java.lang.String aKey, java.lang.Object aValue)
Removes a list item at given index.
-
getSettings
public Settings getSettings(java.lang.String aKey)
Returns the settings for key.
-
getSettings
public Settings getSettings(java.lang.String aKey, boolean doCreate)
Returns the settings for key, with option to create if missing.
-
firePropertyChange
protected void firePropertyChange(java.lang.String aName, java.lang.Object oldVal, java.lang.Object newVal, int anIndex)
Override to forward to parents if present.
-
getJSONClass
public java.lang.String getJSONClass()
Description copied from interface:RMJSONArchiver.GetClass
Returns a list of keys to be uses to retrieve persistent attributes from an object.- Specified by:
getJSONClass
in interfaceRMJSONArchiver.GetClass
-
setJSONValue
public void setJSONValue(java.lang.String aKey, java.lang.Object aValue)
Description copied from interface:RMJSONArchiver.SetValue
Returns a list of keys to be uses to retrieve persistent attributes from an object.- Specified by:
setJSONValue
in interfaceRMJSONArchiver.SetValue
-
getJSONValue
public java.lang.Object getJSONValue(java.lang.String aKey)
Description copied from interface:RMJSONArchiver.GetValue
Returns a list of keys to be uses to retrieve persistent attributes from an object.- Specified by:
getJSONValue
in interfaceRMJSONArchiver.GetValue
-
getJSONKeys
public java.util.Collection<java.lang.String> getJSONKeys()
Description copied from interface:RMJSONArchiver.GetKeys
Returns a list of keys to be uses to retrieve persistent attributes from an object.- Specified by:
getJSONKeys
in interfaceRMJSONArchiver.GetKeys
-
getKeyValue
public java.lang.Object getKeyValue(java.lang.String aKey)
- Specified by:
getKeyValue
in interfaceRMKey.Get
-
setKeyValue
public boolean setKeyValue(java.lang.String aKey, java.lang.Object aValue)
- Specified by:
setKeyValue
in interfaceRMKey.GetSet
-
toString
public java.lang.String toString()
Standard toString implementation.- Overrides:
toString
in classjava.lang.Object
-
updateFile
public void updateFile(WebFile aFile)
Saves the file.- Specified by:
updateFile
in interfaceWebFile.Updater
-
-