org.apache.myfaces.commons.util
Class WebConfigParamUtils

java.lang.Object
  extended by org.apache.myfaces.commons.util.WebConfigParamUtils

public final class WebConfigParamUtils
extends Object

Utility class to handle web config parameters

Since:
1.0.1
Author:
Leonardo Uribe

Field Summary
static String[] COMMON_FALSE_VALUES
           
static String[] COMMON_TRUE_VALUES
           
 
Constructor Summary
WebConfigParamUtils()
           
 
Method Summary
static boolean getBooleanInitParameter(javax.faces.context.ExternalContext context, String name)
          Gets the boolean init parameter value from the specified context.
static boolean getBooleanInitParameter(javax.faces.context.ExternalContext context, String[] names)
          Gets the boolean init parameter value from the specified context.
static boolean getBooleanInitParameter(javax.faces.context.ExternalContext context, String[] names, boolean defaultValue)
          Gets the boolean init parameter value from the specified context.
static boolean getBooleanInitParameter(javax.faces.context.ExternalContext context, String[] names, boolean defaultValue, String[] valuesIgnoreCase, boolean returnOnValueEqualsIgnoreCase)
          Gets the boolean init parameter value from the specified context.
static boolean getBooleanInitParameter(javax.faces.context.ExternalContext context, String name, boolean defaultValue)
          Gets the boolean init parameter value from the specified context.
static boolean getBooleanInitParameter(javax.faces.context.ExternalContext context, String name, boolean defaultValue, String[] valuesIgnoreCase, boolean returnOnValueEqualsIgnoreCase)
          Gets the boolean init parameter value from the specified context.
static
<T> T
getInstanceInitParameter(javax.faces.context.ExternalContext context, String name, String deprecatedName, T defaultValue)
          Gets the init parameter value from the specified context and instanciate it.
static int getIntegerInitParameter(javax.faces.context.ExternalContext context, String name)
          Gets the int init parameter value from the specified context.
static int getIntegerInitParameter(javax.faces.context.ExternalContext context, String[] names)
          Gets the int init parameter value from the specified context.
static int getIntegerInitParameter(javax.faces.context.ExternalContext context, String[] names, int defaultValue)
          Gets the int init parameter value from the specified context.
static int getIntegerInitParameter(javax.faces.context.ExternalContext context, String name, int defaultValue)
          Gets the int init parameter value from the specified context.
static long getLongInitParameter(javax.faces.context.ExternalContext context, String name)
          Gets the long init parameter value from the specified context.
static long getLongInitParameter(javax.faces.context.ExternalContext context, String[] names)
          Gets the long init parameter value from the specified context.
static long getLongInitParameter(javax.faces.context.ExternalContext context, String[] names, long defaultValue)
          Gets the long init parameter value from the specified context.
static long getLongInitParameter(javax.faces.context.ExternalContext context, String name, long defaultValue)
          Gets the long init parameter value from the specified context.
static String getStringInitParameter(javax.faces.context.ExternalContext context, String name)
          Gets the String init parameter value from the specified context.
static String getStringInitParameter(javax.faces.context.ExternalContext context, String[] names)
          Gets the String init parameter value from the specified context.
static String getStringInitParameter(javax.faces.context.ExternalContext context, String[] names, String defaultValue)
          Gets the String init parameter value from the specified context.
static String getStringInitParameter(javax.faces.context.ExternalContext context, String name, String defaultValue)
          Gets the String init parameter value from the specified context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMMON_TRUE_VALUES

public static final String[] COMMON_TRUE_VALUES

COMMON_FALSE_VALUES

public static final String[] COMMON_FALSE_VALUES
Constructor Detail

WebConfigParamUtils

public WebConfigParamUtils()
Method Detail

getStringInitParameter

public static String getStringInitParameter(javax.faces.context.ExternalContext context,
                                            String name)
Gets the String init parameter value from the specified context. If the parameter is an empty String or a String containing only white space, this method returns null

Parameters:
context - the application's external context
name - the init parameter's name
Returns:
the parameter if it was specified and was not empty, null otherwise
Throws:
NullPointerException - if context or name is null

getStringInitParameter

public static String getStringInitParameter(javax.faces.context.ExternalContext context,
                                            String name,
                                            String defaultValue)
Gets the String init parameter value from the specified context. If the parameter is an empty String or a String containing only white space, this method returns null

Parameters:
context - the application's external context
name - the init parameter's name
defaultValue - the value by default if null or empty
Returns:
the parameter if it was specified and was not empty, null otherwise
Throws:
NullPointerException - if context or name is null

getStringInitParameter

public static String getStringInitParameter(javax.faces.context.ExternalContext context,
                                            String[] names)
Gets the String init parameter value from the specified context. If the parameter is an empty String or a String containing only white space, this method returns null

Parameters:
context - the application's external context
names - the init parameter's names, the first one is scanned first. Usually used when a param has multiple aliases
Returns:
the parameter if it was specified and was not empty, null otherwise
Throws:
NullPointerException - if context or name is null

getStringInitParameter

public static String getStringInitParameter(javax.faces.context.ExternalContext context,
                                            String[] names,
                                            String defaultValue)
Gets the String init parameter value from the specified context. If the parameter is an empty String or a String containing only white space, this method returns null

Parameters:
context - the application's external context
names - the init parameter's names, the first one is scanned first. Usually used when a param has multiple aliases
defaultValue - the value by default if null or empty
Returns:
the parameter if it was specified and was not empty, null otherwise
Throws:
NullPointerException - if context or name is null

getBooleanInitParameter

public static boolean getBooleanInitParameter(javax.faces.context.ExternalContext context,
                                              String name)
Gets the boolean init parameter value from the specified context. If the parameter was not specified, the default value is used instead.

Parameters:
context - the application's external context
name - the init parameter's name
deprecatedName - the init parameter's deprecated name.
defaultValue - the default value to return in case the parameter was not set
Returns:
the init parameter value as a boolean
Throws:
NullPointerException - if context or name is null

getBooleanInitParameter

public static boolean getBooleanInitParameter(javax.faces.context.ExternalContext context,
                                              String name,
                                              boolean defaultValue)
Gets the boolean init parameter value from the specified context. If the parameter was not specified, the default value is used instead.

Parameters:
context - the application's external context
name - the init parameter's name
deprecatedName - the init parameter's deprecated name.
defaultValue - the default value to return in case the parameter was not set
Returns:
the init parameter value as a boolean
Throws:
NullPointerException - if context or name is null

getBooleanInitParameter

public static boolean getBooleanInitParameter(javax.faces.context.ExternalContext context,
                                              String name,
                                              boolean defaultValue,
                                              String[] valuesIgnoreCase,
                                              boolean returnOnValueEqualsIgnoreCase)
Gets the boolean init parameter value from the specified context. If the parameter was not specified, the default value is used instead.

Parameters:
context - the application's external context
name - the init parameter's name
deprecatedName - the init parameter's deprecated name.
defaultValue - the default value to return in case the parameter was not set
valuesIgnoreCase - an array of valid values to match
returnOnValueEqualsIgnoreCase - the value to return in case the parameter match with valuesIgnoreCase
Returns:
the init parameter value as a boolean
Throws:
NullPointerException - if context or name is null

getBooleanInitParameter

public static boolean getBooleanInitParameter(javax.faces.context.ExternalContext context,
                                              String[] names)
Gets the boolean init parameter value from the specified context. If the parameter was not specified, the default value is used instead.

Parameters:
context - the application's external context
names - the init parameter's names
Returns:
the init parameter value as a boolean
Throws:
NullPointerException - if context or name is null

getBooleanInitParameter

public static boolean getBooleanInitParameter(javax.faces.context.ExternalContext context,
                                              String[] names,
                                              boolean defaultValue)
Gets the boolean init parameter value from the specified context. If the parameter was not specified, the default value is used instead.

Parameters:
context - the application's external context
names - the init parameter's names
defaultValue - the default value to return in case the parameter was not set
Returns:
the init parameter value as a boolean
Throws:
NullPointerException - if context or name is null

getBooleanInitParameter

public static boolean getBooleanInitParameter(javax.faces.context.ExternalContext context,
                                              String[] names,
                                              boolean defaultValue,
                                              String[] valuesIgnoreCase,
                                              boolean returnOnValueEqualsIgnoreCase)
Gets the boolean init parameter value from the specified context. If the parameter was not specified, the default value is used instead.

Parameters:
context - the application's external context
names - the init parameter's names
defaultValue - the default value to return in case the parameter was not set
valuesIgnoreCase - an array of valid values to match
returnOnValueEqualsIgnoreCase - the value to return in case the parameter match with valuesIgnoreCase
Returns:
the init parameter value as a boolean
Throws:
NullPointerException - if context or name is null

getIntegerInitParameter

public static int getIntegerInitParameter(javax.faces.context.ExternalContext context,
                                          String name)
Gets the int init parameter value from the specified context. If the parameter was not specified, the default value is used instead.

Parameters:
context - the application's external context
name - the init parameter's name
deprecatedName - the init parameter's deprecated name.
defaultValue - the default value to return in case the parameter was not set
Returns:
the init parameter value as a int
Throws:
NullPointerException - if context or name is null

getIntegerInitParameter

public static int getIntegerInitParameter(javax.faces.context.ExternalContext context,
                                          String name,
                                          int defaultValue)
Gets the int init parameter value from the specified context. If the parameter was not specified, the default value is used instead.

Parameters:
context - the application's external context
name - the init parameter's name
deprecatedName - the init parameter's deprecated name.
defaultValue - the default value to return in case the parameter was not set
Returns:
the init parameter value as a int
Throws:
NullPointerException - if context or name is null

getIntegerInitParameter

public static int getIntegerInitParameter(javax.faces.context.ExternalContext context,
                                          String[] names)
Gets the int init parameter value from the specified context. If the parameter was not specified, the default value is used instead.

Parameters:
context - the application's external context
names - the init parameter's names
Returns:
the init parameter value as a int
Throws:
NullPointerException - if context or name is null

getIntegerInitParameter

public static int getIntegerInitParameter(javax.faces.context.ExternalContext context,
                                          String[] names,
                                          int defaultValue)
Gets the int init parameter value from the specified context. If the parameter was not specified, the default value is used instead.

Parameters:
context - the application's external context
names - the init parameter's names
defaultValue - the default value to return in case the parameter was not set
Returns:
the init parameter value as a int
Throws:
NullPointerException - if context or name is null

getLongInitParameter

public static long getLongInitParameter(javax.faces.context.ExternalContext context,
                                        String name)
Gets the long init parameter value from the specified context. If the parameter was not specified, the default value is used instead.

Parameters:
context - the application's external context
name - the init parameter's name
deprecatedName - the init parameter's deprecated name.
defaultValue - the default value to return in case the parameter was not set
Returns:
the init parameter value as a long
Throws:
NullPointerException - if context or name is null

getLongInitParameter

public static long getLongInitParameter(javax.faces.context.ExternalContext context,
                                        String name,
                                        long defaultValue)
Gets the long init parameter value from the specified context. If the parameter was not specified, the default value is used instead.

Parameters:
context - the application's external context
name - the init parameter's name
deprecatedName - the init parameter's deprecated name.
defaultValue - the default value to return in case the parameter was not set
Returns:
the init parameter value as a long
Throws:
NullPointerException - if context or name is null

getLongInitParameter

public static long getLongInitParameter(javax.faces.context.ExternalContext context,
                                        String[] names)
Gets the long init parameter value from the specified context. If the parameter was not specified, the default value is used instead.

Parameters:
context - the application's external context
names - the init parameter's names
Returns:
the init parameter value as a long
Throws:
NullPointerException - if context or name is null

getLongInitParameter

public static long getLongInitParameter(javax.faces.context.ExternalContext context,
                                        String[] names,
                                        long defaultValue)
Gets the long init parameter value from the specified context. If the parameter was not specified, the default value is used instead.

Parameters:
context - the application's external context
names - the init parameter's names
defaultValue - the default value to return in case the parameter was not set
Returns:
the init parameter value as a long
Throws:
NullPointerException - if context or name is null

getInstanceInitParameter

public static <T> T getInstanceInitParameter(javax.faces.context.ExternalContext context,
                                             String name,
                                             String deprecatedName,
                                             T defaultValue)
Gets the init parameter value from the specified context and instanciate it. If the parameter was not specified, the default value is used instead.

Parameters:
context - the application's external context
name - the init parameter's name
deprecatedName - the init parameter's deprecated name.
defaultValue - the default value to return in case the parameter was not set
Returns:
the init parameter value as an object instance
Throws:
NullPointerException - if context or name is null


Copyright © 2007-2011 The Apache Software Foundation. All Rights Reserved.