com.devsphere.mapping
Class HandlerUtils

java.lang.Object
  |
  +--com.devsphere.mapping.HandlerUtils

public class HandlerUtils
extends java.lang.Object

Utility class that implements operations used typically by handlers.


Method Summary
static java.util.ResourceBundle getBeanResources(java.lang.Class beanClass)
          Gets the resources associated with a bean using the default locale.
static java.util.ResourceBundle getBeanResources(java.lang.Class beanClass, java.util.Locale locale)
          Gets the resources associated with a bean using the given locale.
static java.util.ResourceBundle getBeanResources(java.lang.String beanName)
          Gets the resources associated with a bean using the default locale.
static java.util.ResourceBundle getBeanResources(java.lang.String beanName, java.util.Locale locale)
          Gets the resources associated with a bean using the given locale.
static java.lang.Object getResource(java.lang.String key, java.lang.Object defaultValue, java.lang.Class beanClass)
          Gets a resource object associated to a given key.
static java.lang.Object getResource(java.lang.String key, java.lang.Object defaultValue, java.lang.Class beanClass, java.util.Locale locale)
          Gets a resource object associated to a given key.
static java.lang.Object getResource(java.lang.String key, java.lang.Object defaultValue, java.lang.String beanName)
          Gets a resource object associated to a given key.
static java.lang.Object getResource(java.lang.String key, java.lang.Object defaultValue, java.lang.String beanName, java.util.Locale locale)
          Gets a resource object associated to a given key.
static java.util.Hashtable removeUserErrors(java.util.Hashtable errorTable)
          Makes a clone of an error table and then removes the clone's user errors, letting the original error table unchanged.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getBeanResources

public static java.util.ResourceBundle getBeanResources(java.lang.Class beanClass)
                                                 throws java.util.MissingResourceException
Gets the resources associated with a bean using the default locale. The base name of the resources is formed by adding "Resources" to the class name.
Parameters:
beanClass - the class whose name is used to form the base name of the resources.
Returns:
the ResourceBundle object containing the bean resources.
Throws:
NullPointerException - if beanClass is null.
java.util.MissingResourceException - if the bean resources aren't found.

getBeanResources

public static java.util.ResourceBundle getBeanResources(java.lang.Class beanClass,
                                                        java.util.Locale locale)
                                                 throws java.util.MissingResourceException
Gets the resources associated with a bean using the given locale. The base name of the resources is formed by adding "Resources" to the class name.
Parameters:
beanClass - the class whose name is used to form the base name of the resources.
locale - the locale object that is passed to the I18N API that loads the resources.
Returns:
the ResourceBundle object containing the bean resources.
Throws:
NullPointerException - if beanClass is null.
java.util.MissingResourceException - if the bean resources aren't found.

getBeanResources

public static java.util.ResourceBundle getBeanResources(java.lang.String beanName)
                                                 throws java.util.MissingResourceException
Gets the resources associated with a bean using the default locale. The base name of the resources is formed by adding "Resources" to beanName.
Parameters:
beanName - the bean name that is used to form the base name of the resources.
Returns:
the ResourceBundle object containing the bean resources.
Throws:
NullPointerException - if beanName is null.
java.util.MissingResourceException - if the bean resources aren't found.

getBeanResources

public static java.util.ResourceBundle getBeanResources(java.lang.String beanName,
                                                        java.util.Locale locale)
                                                 throws java.util.MissingResourceException
Gets the resources associated with a bean using the given locale. The base name of the resources is formed by adding "Resources" to beanName.
Parameters:
beanName - the bean name that is used to form the base name of the resources.
locale - the locale object that is passed to the I18N API that loads the resources.
Returns:
the ResourceBundle object containing the bean resources.
Throws:
NullPointerException - if beanName is null.
java.util.MissingResourceException - if the bean resources aren't found.

getResource

public static java.lang.Object getResource(java.lang.String key,
                                           java.lang.Object defaultValue,
                                           java.lang.Class beanClass)
Gets a resource object associated to a given key. If beanClass isn't null, it searches the resource object among the bean resources. If the bean resources don't exists or they don't contain a resource with the given key, this method tries to find the resource object within the framework's resources (FRAMEWORK_HOME/com/devsphere/mapping/resources/resources.properties).
Parameters:
key - the key of the resource.
defaultValue - the default value of the resource.
beanClass - the bean class whose resources are searched. (May be null.)
Returns:
the resource object or the default value if the resource isn't found.
Throws:
NullPointerException - if key is null.

getResource

public static java.lang.Object getResource(java.lang.String key,
                                           java.lang.Object defaultValue,
                                           java.lang.Class beanClass,
                                           java.util.Locale locale)
Gets a resource object associated to a given key. If beanClass isn't null, it searches the resource object among the bean resources. If the bean resources don't exists or they don't contain a resource with the given key, this method tries to find the resource object within the framework's resources (FRAMEWORK_HOME/com/devsphere/mapping/resources/resources.properties).
Parameters:
key - the key of the resource.
defaultValue - the default value of the resource.
beanClass - the bean class whose resources are searched. (May be null.)
locale - the locale object that is passed to the I18N API that loads the resources.
Returns:
the resource object or the default value if the resource isn't found.
Throws:
NullPointerException - if key is null.

getResource

public static java.lang.Object getResource(java.lang.String key,
                                           java.lang.Object defaultValue,
                                           java.lang.String beanName)
Gets a resource object associated to a given key. If beanName isn't null, it searches the resource object among the bean resources. If the bean resources don't exists or they don't contain a resource with the given key, this method tries to find the resource object within the framework's resources (FRAMEWORK_HOME/com/devsphere/mapping/resources/resources.properties).
Parameters:
key - the key of the resource.
defaultValue - the default value of the resource.
beanName - the bean name whose resources are searched. (May be null.)
Returns:
the resource object or the default value if the resource isn't found.
Throws:
NullPointerException - if key is null.

getResource

public static java.lang.Object getResource(java.lang.String key,
                                           java.lang.Object defaultValue,
                                           java.lang.String beanName,
                                           java.util.Locale locale)
Gets a resource object associated to a given key. If beanName isn't null, it searches the resource object among the bean resources. If the bean resources don't exists or they don't contain a resource with the given key, this method tries to find the resource object within the framework's resources (FRAMEWORK_HOME/com/devsphere/mapping/resources/resources.properties).
Parameters:
key - the key of the resource.
defaultValue - the default value of the resource.
beanName - the bean name whose resources are searched. (May be null.)
locale - the locale object that is passed to the I18N API that loads the resources.
Returns:
the resource object or the default value if the resource isn't found.
Throws:
NullPointerException - if key is null.

removeUserErrors

public static java.util.Hashtable removeUserErrors(java.util.Hashtable errorTable)
Makes a clone of an error table and then removes the clone's user errors, letting the original error table unchanged.
Parameters:
errorTable - the error table
Returns:
a clone of the error table whose user errors were removed, or null if errorTable is null or contains only user errors.
Throws:
java.lang.IllegalArgumentException - if errorTable wasn't created by this framework.