| java.lang.Object org.apache.struts2.config.Settings
All known Subclasses: org.apache.struts2.config.PropertiesSettings, org.apache.struts2.config.TestSettings, org.apache.struts2.config.DefaultSettings, org.apache.struts2.config.DelegatingSettings,
Settings | class Settings (Code) | | Settings retrieves and exposes default values used by the framework.
An application can override a factory default and provide its own value for a setting.
Implementation of the class is pluggable (the default implementation is
DefaultSettings ).
Pluggability gives applications to ability to customize how settings are retrieved.
As an example, an application may wish to check some custom property store
before delegating to the usual configuration and property files.
Key methods:
Key methods for subclasses (plugins):
|
Method Summary | |
public static String | get(String name) Provides a setting value as a String.
The method will throw an IllegalArgumentException if an error occurs
while retrieveing the property or if the property doesn't exist.
Parameters: name - the name of the setting to retrieve. | public String | getImpl(String name) Implements the
Settings.get(String) method. | public static Settings | getInstance() Provides the Settings object. | public static Locale | getLocale() Provides the Struts default locale. | public static Location | getLocation(String name) Provides the Location of a setting.
The Location is utilized as part of precise error reporting.
This method will throw an IllegalArgumentException if an error occurs
while retrieving the value or if the setting doesn't exist.
Parameters: name - the name of the property to get. | public Location | getLocationImpl(String name) Implements the
Settings.getLocation(String) method. | public static boolean | isSet(String name) Determines whether or not a setting has a registered value.
This method is useful for testing for the existance of setting without
throwing an IllegalArgumentException.
Parameters: name - the name of a setting to test. | public boolean | isSetImpl(String name) Implements the
Settings.isSet(String) method. | public static Iterator | list() Provides an Iterator of all properties names. | public Iterator | listImpl() Implements the
Settings.list() method. | public static void | reset() Resets the default and any plugin Setting instance to null. | public static void | set(String name, String value) Registers a value for a setting. | public void | setImpl(String name, String value) Implements the
Settings.set(String,String) method. | public static void | setInstance(Settings config) Registers a custom Settings implementation (plugin),
and resets the cached locale. |
get | public static String get(String name) throws IllegalArgumentException(Code) | | Provides a setting value as a String.
The method will throw an IllegalArgumentException if an error occurs
while retrieveing the property or if the property doesn't exist.
Parameters: name - the name of the setting to retrieve. the setting value as a String. throws: IllegalArgumentException - if an error occurs retrieving the property or the property does not exist. |
getInstance | public static Settings getInstance()(Code) | | Provides the Settings object.
This method will substitute the default instance if another instance is not registered.
the Settings object. |
getLocale | public static Locale getLocale()(Code) | | Provides the Struts default locale.
This method utilizes the struts.locale setting, which should be given
as the Java
java.util.Locale.toString toString() representation of a Locale object
("en", "de_DE", "_GB", "en_US_WIN", "de__POSIX", "fr_MAC", and so forth).
If a struts.locale setting is not registered,
then the default virtual machine locale is substituted and cached.
the Struts default locale if specified or the VM default locale. See Also: java.util.Locale.getDefault |
getLocation | public static Location getLocation(String name) throws IllegalArgumentException(Code) | | Provides the Location of a setting.
The Location is utilized as part of precise error reporting.
This method will throw an IllegalArgumentException if an error occurs
while retrieving the value or if the setting doesn't exist.
Parameters: name - the name of the property to get. the Location of a property. throws: IllegalArgumentException - if an error occurs retrieving the property or the property does not exist. |
isSet | public static boolean isSet(String name)(Code) | | Determines whether or not a setting has a registered value.
This method is useful for testing for the existance of setting without
throwing an IllegalArgumentException.
Parameters: name - the name of a setting to test. true if the setting exists and has a value, false otherwise. |
list | public static Iterator list()(Code) | | Provides an Iterator of all properties names.
an Iterator of all properties names. |
reset | public static void reset()(Code) | | Resets the default and any plugin Setting instance to null.
|
setInstance | public static void setInstance(Settings config) throws IllegalStateException(Code) | | Registers a custom Settings implementation (plugin),
and resets the cached locale.
This method can only be called once.
Parameters: config - a Settings implementation throws: IllegalStateException - if an error occurs when setting the settings implementation. |
|
|