org.apache.struts2.config
Class Settings

java.lang.Object
  extended by org.apache.struts2.config.Settings
Direct Known Subclasses:
DefaultSettings, DelegatingSettings, PropertiesSettings

public class Settings
extends java.lang.Object

Handles all Struts config properties. Implementation of this class is pluggable (the default implementation is DefaultSettings). This gives developers to ability to customize how Struts properties are set and retrieved. As an example, a developer may wish to check a separate property store before delegating to the Struts one.

Key methods:

Key methods for subclassers:


Constructor Summary
Settings()
           
 
Method Summary
static java.lang.String get(java.lang.String name)
          Returns a property as an Object.
 java.lang.String getImpl(java.lang.String aName)
          Implementation of the get(String) method.
static Settings getInstance()
          Gets the current settings implementation.
static java.util.Locale getLocale()
          Returns the Struts locale.
static boolean isSet(java.lang.String name)
          Determines whether or not a value has been set.
 boolean isSetImpl(java.lang.String name)
          Implementation of the isSet(String) method.
static java.util.Iterator list()
          Returns an Iterator of all properties names.
 java.util.Iterator listImpl()
          Implementation of the list() method.
static void reset()
           
static void set(java.lang.String name, java.lang.String value)
          Sets a property.
 void setImpl(java.lang.String name, java.lang.String value)
          Implementation of the set(String, String) method.
static void setInstance(Settings config)
          Sets the current settings implementation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Settings

public Settings()
Method Detail

setInstance

public static void setInstance(Settings config)
                        throws java.lang.IllegalStateException
Sets the current settings implementation. Can only be called once.

Parameters:
config - a Settings implementation
Throws:
java.lang.IllegalStateException - if an error occurs when setting the settings implementation.

getInstance

public static Settings getInstance()
Gets the current settings implementation.

Returns:
the current settings implementation.

getLocale

public static java.util.Locale getLocale()
Returns the Struts locale. Keys off the property struts.locale which should be set as the Java toString() representation of a Locale object (i.e., "en", "de_DE", "_GB", "en_US_WIN", "de__POSIX", "fr_MAC", etc).

If no locale is specified then the default VM locale is used (Locale.getDefault()).

Returns:
the Struts locale if specified or the VM default locale.

isSet

public static boolean isSet(java.lang.String name)
Determines whether or not a value has been set. Useful for testing for the existance of parameter without throwing an IllegalArgumentException.

Parameters:
name - the name of the property to test.
Returns:
true if the property exists and has a value, false otherwise.

get

public static java.lang.String get(java.lang.String name)
                            throws java.lang.IllegalArgumentException
Returns a property as an Object. This 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 property to get.
Returns:
the property as an Object.
Throws:
java.lang.IllegalArgumentException - if an error occurs retrieveing the property or the property does not exist.

list

public static java.util.Iterator list()
Returns an Iterator of all properties names.

Returns:
an Iterator of all properties names.

isSetImpl

public boolean isSetImpl(java.lang.String name)
Implementation of the isSet(String) method.

See Also:
isSet(String)

set

public static void set(java.lang.String name,
                       java.lang.String value)
                throws java.lang.IllegalArgumentException,
                       java.lang.UnsupportedOperationException
Sets a property. Throws an exception if an error occurs when setting the property or if the Settings implementation does not support setting properties.

Parameters:
name - the name of the property to set.
value - the property to set.
Throws:
java.lang.IllegalArgumentException - if an error occurs when setting the property.
java.lang.UnsupportedOperationException - if the config implementation does not support setting properties.

setImpl

public void setImpl(java.lang.String name,
                    java.lang.String value)
             throws java.lang.IllegalArgumentException,
                    java.lang.UnsupportedOperationException
Implementation of the set(String, String) method.

Throws:
java.lang.IllegalArgumentException
java.lang.UnsupportedOperationException
See Also:
set(String, String)

getImpl

public java.lang.String getImpl(java.lang.String aName)
                         throws java.lang.IllegalArgumentException
Implementation of the get(String) method.

Throws:
java.lang.IllegalArgumentException
See Also:
get(String)

listImpl

public java.util.Iterator listImpl()
Implementation of the list() method.

See Also:
list()

reset

public static void reset()


Copyright © 2000-2006 Apache Software Foundation. All Rights Reserved.