org.objectledge.parameters
Class ScopedParameters

java.lang.Object
  extended by org.objectledge.parameters.ScopedParameters
All Implemented Interfaces:
Parameters

public class ScopedParameters
extends Object
implements Parameters

An implementation of parameters decorator class to scope parameters key names.

Version:
$Id: ScopedParameters.java,v 1.7 2005/12/16 11:42:16 pablo Exp $
Author:
Pawel Potempski

Field Summary
private  Parameters parameters
          the base parameters
private  String prefix
          prefix
 
Constructor Summary
ScopedParameters(Parameters parameters, String prefix)
          Create the container scoped decorator.
 
Method Summary
 void add(Parameters parameters, boolean overwrite)
          Adds all parameters from another container to this container.
 void add(String name, boolean value)
          Add the parameter.
 void add(String name, boolean[] values)
          Add the parameter.
 void add(String name, Date value)
          Add the parameter.
 void add(String name, Date[] values)
          Add the parameter.
 void add(String name, float value)
          Add the parameter.
 void add(String name, float[] values)
          Add the parameter.
 void add(String name, int value)
          Add the parameter.
 void add(String name, int[] values)
          Add the parameter.
 void add(String name, long value)
          Add the parameter.
 void add(String name, long[] values)
          Add the parameter.
 void add(String name, String value)
          Add the parameter.
 void add(String name, String[] values)
          Add the parameter.
 String get(String name)
          Return the parameter with specified name.
 String get(String name, String defaultValue)
          Return the parameter with specified name.
 boolean getBoolean(String name)
          Return the parameter with specified name.
 boolean getBoolean(String name, boolean defaultValue)
          Return the parameter with specified name.
 boolean[] getBooleans(String name)
          Return all values of the parameter with specified name as an array.
 Parameters getChild(String prefix)
          Return a parameters object that represents a subset of parameters with specified prefix.
 Date getDate(String name)
          Return the parameter with specified name.
 Date getDate(String name, Date defaultValue)
          Return the parameter with specified name.
 Date[] getDates(String name)
          Return all values of the parameter with specified name as an array.
 float getFloat(String name)
          Return the parameter with specified name.
 float getFloat(String name, float defaultValue)
          Return the parameter with specified name.
 float[] getFloats(String name)
          Return all values of the parameter with specified name as an array.
 int getInt(String name)
          Return the parameter with specified name.
 int getInt(String name, int defaultValue)
          Return the parameter with specified name.
 int[] getInts(String name)
          Return all values of the parameter with specified name as an array.
 long getLong(String name)
          Return the parameter with specified name.
 long getLong(String name, long defaultValue)
          Return the parameter with specified name.
 long[] getLongs(String name)
          Return the parameter as array of long values.
 String[] getParameterNames()
          Return the names of all parameters.
protected  String getPrefix()
          Get the prefix.
 String[] getStrings(String name)
          Return all values of the parameter with specified name as an array.
 boolean isDefined(String name)
          Checks whether parameter is defined.
 void remove()
          Remove all parameters.
 void remove(Set<String> keys)
          Remove all parameters with a name contained in given set.
 void remove(String name)
          Remove all parameters with a specified name.
 void remove(String name, Date value)
          Remove all parameters with a specified name and value.
 void remove(String name, float value)
          Remove all parameters with a specified name and value.
 void remove(String name, int value)
          Remove all parameters with a specified name and value.
 void remove(String name, long value)
          Remove all parameters with a specified name and value.
 void remove(String name, String value)
          Remove all parameters with a specified name and string value.
 void removeExcept(Set<String> keys)
          Remove all except those with a keys specified in the set.
 void set(Parameters parameters)
          Reset state to equal with given parameters.
 void set(String name, boolean value)
          Set the parameter.
 void set(String name, boolean[] values)
          Set the parameter.
 void set(String name, Date value)
          Set the parameter.
 void set(String name, Date[] values)
          Set the parameter.
 void set(String name, float value)
          Set the parameter.
 void set(String name, float[] values)
          Set the parameter.
 void set(String name, int value)
          Set the parameter.
 void set(String name, int[] values)
          Set the parameter.
 void set(String name, long value)
          Set the parameter.
 void set(String name, long[] values)
          Set the parameter.
 void set(String name, String value)
          Set the parameter.
 void set(String name, String[] values)
          Set the parameter.
 String toString()
          Returns the contained properties as a parsable String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parameters

private Parameters parameters
the base parameters


prefix

private String prefix
prefix

Constructor Detail

ScopedParameters

public ScopedParameters(Parameters parameters,
                        String prefix)
Create the container scoped decorator.

Parameters:
parameters - the container to decorate.
prefix - the scope prefix.
Method Detail

add

public void add(Parameters parameters,
                boolean overwrite)
Adds all parameters from another container to this container. If overwrite is set to true all conflicting parameters from this container will be replaced, otherwise all parameters from another container will be added.

Specified by:
add in interface Parameters
Parameters:
parameters - the parameters object.
overwrite - the overwrite switch.

add

public void add(String name,
                boolean value)
Add the parameter.

Specified by:
add in interface Parameters
Parameters:
name - the parameter name.
value - the parameter value.

add

public void add(String name,
                boolean[] values)
Add the parameter.

Specified by:
add in interface Parameters
Parameters:
name - the parameter name.
values - the parameter values.

add

public void add(String name,
                Date value)
Add the parameter.

Specified by:
add in interface Parameters
Parameters:
name - the parameter name.
value - the parameter value.

add

public void add(String name,
                Date[] values)
Add the parameter.

Specified by:
add in interface Parameters
Parameters:
name - the parameter name.
values - the parameter values.

add

public void add(String name,
                float value)
Add the parameter.

Specified by:
add in interface Parameters
Parameters:
name - the parameter name.
value - the parameter value.

add

public void add(String name,
                float[] values)
Add the parameter.

Specified by:
add in interface Parameters
Parameters:
name - the parameter name.
values - the parameter values.

add

public void add(String name,
                int value)
Add the parameter.

Specified by:
add in interface Parameters
Parameters:
name - the parameter name.
value - the parameter value.

add

public void add(String name,
                int[] values)
Add the parameter.

Specified by:
add in interface Parameters
Parameters:
name - the parameter name.
values - the parameter values.

add

public void add(String name,
                long value)
Add the parameter.

Specified by:
add in interface Parameters
Parameters:
name - the parameter name.
value - the parameter value.

add

public void add(String name,
                long[] values)
Add the parameter.

Specified by:
add in interface Parameters
Parameters:
name - the parameter name.
values - the parameter values.

add

public void add(String name,
                String value)
Add the parameter.

Specified by:
add in interface Parameters
Parameters:
name - the parameter name.
value - the parameter value.

add

public void add(String name,
                String[] values)
Add the parameter.

Specified by:
add in interface Parameters
Parameters:
name - the parameter name.
values - the parameter values.

get

public String get(String name,
                  String defaultValue)
Return the parameter with specified name.

Specified by:
get in interface Parameters
Parameters:
name - the name of the parameter.
defaultValue - the default value of the parameter.
Returns:
the string value of the parameter.

get

public String get(String name)
Return the parameter with specified name.

Specified by:
get in interface Parameters
Parameters:
name - the name of the parameter.
Returns:
the string value of the parameter.

getBoolean

public boolean getBoolean(String name,
                          boolean defaultValue)
Return the parameter with specified name.

Specified by:
getBoolean in interface Parameters
Parameters:
name - the name of the parameter.
defaultValue - the default value of the parameter.
Returns:
the boolean value of the parameter.

getBoolean

public boolean getBoolean(String name)
Return the parameter with specified name.

Specified by:
getBoolean in interface Parameters
Parameters:
name - the name of the parameter.
Returns:
the boolean value of the parameter.

getBooleans

public boolean[] getBooleans(String name)
Return all values of the parameter with specified name as an array.

Specified by:
getBooleans in interface Parameters
Parameters:
name - the name of the parameters.
Returns:
the array of the boolean values of the parameter.

getChild

public Parameters getChild(String prefix)
Return a parameters object that represents a subset of parameters with specified prefix.

Specified by:
getChild in interface Parameters
Parameters:
prefix - the prefix.
Returns:
the nested parameters object.

getDate

public Date getDate(String name)
Return the parameter with specified name. The assumed String value of this parameter is a decimal representation of a Unix time-stamp.

Specified by:
getDate in interface Parameters
Parameters:
name - the name of the parameter.
Returns:
the date value of the parameter.

getDate

public Date getDate(String name,
                    Date defaultValue)
Return the parameter with specified name. The assumed String value of this parameter is a decimal representation of a Unix time-stamp.

Specified by:
getDate in interface Parameters
Parameters:
name - the name of the parameter.
defaultValue - the default value of the parameter.
Returns:
the date value of the parameter.

getDates

public Date[] getDates(String name)
Return all values of the parameter with specified name as an array. The assumed String values of this parameter is are decimal representations of Unix time-stamps.

Specified by:
getDates in interface Parameters
Parameters:
name - the name of the parameters.
Returns:
the array of the date values of the parameter.

getFloat

public float getFloat(String name,
                      float defaultValue)
Return the parameter with specified name.

Specified by:
getFloat in interface Parameters
Parameters:
name - the name of the parameter.
defaultValue - the default value of the parameter.
Returns:
the float value of the parameter.

getFloat

public float getFloat(String name)
               throws NumberFormatException
Return the parameter with specified name.

Specified by:
getFloat in interface Parameters
Parameters:
name - the name of the parameter.
Returns:
the float value of the parameter.
Throws:
NumberFormatException - if parameter is not a number.

getFloats

public float[] getFloats(String name)
                  throws NumberFormatException
Return all values of the parameter with specified name as an array.

Specified by:
getFloats in interface Parameters
Parameters:
name - the name of the parameters.
Returns:
the array of the float values of the parameter.
Throws:
NumberFormatException - if anyone of the values is not a number.

getInt

public int getInt(String name,
                  int defaultValue)
Return the parameter with specified name.

Specified by:
getInt in interface Parameters
Parameters:
name - the name of the parameter.
defaultValue - the default value of the parameter.
Returns:
the integer value of the parameter.

getInt

public int getInt(String name)
           throws NumberFormatException
Return the parameter with specified name.

Specified by:
getInt in interface Parameters
Parameters:
name - the name of the parameter.
Returns:
the integer value of the parameter.
Throws:
NumberFormatException - if parameter is not a number.

getInts

public int[] getInts(String name)
              throws NumberFormatException
Return all values of the parameter with specified name as an array.

Specified by:
getInts in interface Parameters
Parameters:
name - the name of the parameters.
Returns:
the array of the integer values of the parameter.
Throws:
NumberFormatException - if anyone of the values is not a number.

getLong

public long getLong(String name,
                    long defaultValue)
Return the parameter with specified name.

Specified by:
getLong in interface Parameters
Parameters:
name - the name of the parameter.
defaultValue - the default value of the parameter.
Returns:
the integer value of the parameter.

getLong

public long getLong(String name)
             throws NumberFormatException
Return the parameter with specified name.

Specified by:
getLong in interface Parameters
Parameters:
name - the name of the parameter.
Returns:
the integer value of the parameter.
Throws:
NumberFormatException - if parameter is not a number.

getLongs

public long[] getLongs(String name)
                throws NumberFormatException
Return the parameter as array of long values.

Specified by:
getLongs in interface Parameters
Parameters:
name - the name of the parameter.
Returns:
the array of parameter values.
Throws:
NumberFormatException - if parameter is not a number.

getParameterNames

public String[] getParameterNames()
Return the names of all parameters.

Specified by:
getParameterNames in interface Parameters
Returns:
the parameter names.

getStrings

public String[] getStrings(String name)
Return all values of the parameter with specified name as an array.

Specified by:
getStrings in interface Parameters
Parameters:
name - the name of the parameters.
Returns:
the array of the string values of the parameter.

isDefined

public boolean isDefined(String name)
Checks whether parameter is defined.

Specified by:
isDefined in interface Parameters
Parameters:
name - the name of the parameter.
Returns:
true if parameter is defined.

remove

public void remove()
Remove all parameters.

Specified by:
remove in interface Parameters

remove

public void remove(Set<String> keys)
Remove all parameters with a name contained in given set.

Specified by:
remove in interface Parameters
Parameters:
keys - the set of keys.

remove

public void remove(String name,
                   Date value)
Remove all parameters with a specified name and value.

Specified by:
remove in interface Parameters
Parameters:
name - the parameter name.
value - the parameter value.

remove

public void remove(String name,
                   float value)
Remove all parameters with a specified name and value.

Specified by:
remove in interface Parameters
Parameters:
name - the parameter name.
value - the parameter value.

remove

public void remove(String name,
                   int value)
Remove all parameters with a specified name and value.

Specified by:
remove in interface Parameters
Parameters:
name - the parameter name.
value - the parameter value.

remove

public void remove(String name,
                   long value)
Remove all parameters with a specified name and value.

Specified by:
remove in interface Parameters
Parameters:
name - the parameter name.
value - the parameter value.

remove

public void remove(String name,
                   String value)
Remove all parameters with a specified name and string value.

Specified by:
remove in interface Parameters
Parameters:
name - the parameter name.
value - the parameter value.

remove

public void remove(String name)
Remove all parameters with a specified name.

Specified by:
remove in interface Parameters
Parameters:
name - the parameter name.

removeExcept

public void removeExcept(Set<String> keys)
Remove all except those with a keys specified in the set.

Specified by:
removeExcept in interface Parameters
Parameters:
keys - the set of names.

set

public void set(String name,
                boolean value)
Set the parameter.

Specified by:
set in interface Parameters
Parameters:
name - the parameter name.
value - the parameter value.

set

public void set(String name,
                boolean[] values)
Set the parameter.

Specified by:
set in interface Parameters
Parameters:
name - the parameter name.
values - the parameter values.

set

public void set(String name,
                Date value)
Set the parameter.

Specified by:
set in interface Parameters
Parameters:
name - the parameter name.
value - the parameter value.

set

public void set(String name,
                Date[] values)
Set the parameter.

Specified by:
set in interface Parameters
Parameters:
name - the parameter name.
values - the parameter values.

set

public void set(String name,
                float value)
Set the parameter.

Specified by:
set in interface Parameters
Parameters:
name - the parameter name.
value - the parameter value.

set

public void set(String name,
                float[] values)
Set the parameter.

Specified by:
set in interface Parameters
Parameters:
name - the parameter name.
values - the parameter values.

set

public void set(String name,
                int value)
Set the parameter.

Specified by:
set in interface Parameters
Parameters:
name - the parameter name.
value - the parameter value.

set

public void set(String name,
                int[] values)
Set the parameter.

Specified by:
set in interface Parameters
Parameters:
name - the parameter name.
values - the parameter values.

set

public void set(String name,
                long value)
Set the parameter.

Specified by:
set in interface Parameters
Parameters:
name - the parameter name.
value - the parameter value.

set

public void set(String name,
                long[] values)
Set the parameter.

Specified by:
set in interface Parameters
Parameters:
name - the parameter name.
values - the parameter values.

set

public void set(String name,
                String value)
Set the parameter.

Specified by:
set in interface Parameters
Parameters:
name - the parameter name.
value - the parameter value.

set

public void set(String name,
                String[] values)
Set the parameter.

Specified by:
set in interface Parameters
Parameters:
name - the parameter name.
values - the parameter values.

set

public void set(Parameters parameters)
Reset state to equal with given parameters.

Specified by:
set in interface Parameters
Parameters:
parameters - the source parameters.

toString

public String toString()
Returns the contained properties as a parsable String.

Specified by:
toString in interface Parameters
Overrides:
toString in class Object
Returns:
parsable String representation of the contained properties.

getPrefix

protected String getPrefix()
Get the prefix.

Returns:
prefix.


Copyright © 2003-2006 objectledge.org. All Rights Reserved.