2.17.2: 2011-06-17

net.sf.basedb.core.plugin
Class ParameterValuesWrapper

java.lang.Object
  extended by net.sf.basedb.core.plugin.ParameterValuesWrapper
All Implemented Interfaces:
ParameterValues

public class ParameterValuesWrapper
extends Object
implements ParameterValues

A helper class that will wrap the parameter values from one job, one configuration and one request object. The main use is to simplify reading parameter values that may be located at different places. The getValue(String) and getValues(String) methods will first check the request, if no parameter is present the job will be checked and at last the configuration.

The setValue(String, ParameterType, Object) and setValues(String, ParameterType, List) can be configured to write through to either the job or the configuration.

Version:
2.4
Author:
nicklas
Last modified
$Date: 2008-09-11 22:09:17 +0200 (Thu, 11 Sep 2008) $

Field Summary
private  ParameterValues config
           
private  ParameterValues job
           
private  boolean preferJob
           
private  Request request
           
 
Constructor Summary
ParameterValuesWrapper(Request request, ParameterValues job, ParameterValues config, boolean preferJob)
           
 
Method Summary
 int getId()
          Get the ID of either the job or the configuration, depending in the preferJob parameter that was set when creating this object.
 Job getJob()
          Get the job that we are executing/configuring.
 PluginConfiguration getPluginConfiguration()
          Get the configuration that we are using/configuring.
 PluginDefinition getPluginDefinition()
          Get the PluginDefinition of either the job or the configuration, depending in the preferJob parameter that was set when creating this object.
 Object getValue(String name)
          Get the value of the parameter with the specified name.
 List<?> getValues(String name)
          Get the values of the parameter with the specified name.
<T> void
setValue(String name, ParameterType<T> type, T value)
          Set the value on either the job or configuration, depending in the preferJob parameter that was set when creating this object.
<T> void
setValues(String name, ParameterType<T> type, List<T> values)
          Set the value on either the job or configuration, depending in the preferJob parameter that was set when creating this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

request

private final Request request

job

private final ParameterValues job

config

private final ParameterValues config

preferJob

private final boolean preferJob
Constructor Detail

ParameterValuesWrapper

public ParameterValuesWrapper(Request request,
                              ParameterValues job,
                              ParameterValues config,
                              boolean preferJob)
Method Detail

getId

public int getId()
Get the ID of either the job or the configuration, depending in the preferJob parameter that was set when creating this object.

Specified by:
getId in interface ParameterValues
Returns:
The ID of the job or configuration or 0 if there is none

getJob

public Job getJob()
Description copied from interface: ParameterValues
Get the job that we are executing/configuring.

Specified by:
getJob in interface ParameterValues
Returns:
A Job or null if not known

getPluginConfiguration

public PluginConfiguration getPluginConfiguration()
Description copied from interface: ParameterValues
Get the configuration that we are using/configuring.

Specified by:
getPluginConfiguration in interface ParameterValues
Returns:
A PluginConfiguration or null if not known

getPluginDefinition

public PluginDefinition getPluginDefinition()
Get the PluginDefinition of either the job or the configuration, depending in the preferJob parameter that was set when creating this object.

Specified by:
getPluginDefinition in interface ParameterValues
Returns:
The PluginDefinition of the job or configuration or null if there is none

getValue

public Object getValue(String name)
                throws PermissionDeniedException,
                       BaseException
Get the value of the parameter with the specified name. This method first looks for a value in the Request object. If not found, it looks in the job object, and at last in the configuration object.

Specified by:
getValue in interface ParameterValues
Parameters:
name - the name of the parameter
Returns:
The value of the specified parameter
Throws:
PermissionDeniedException - If the logged in user doesn't have permission to read the value
BaseException - If there is another error

getValues

public List<?> getValues(String name)
                  throws PermissionDeniedException,
                         BaseException
Get the values of the parameter with the specified name. This method first looks for a value in the Request object. If not found, it looks in the job object, and at last in the configuration object.

Specified by:
getValues in interface ParameterValues
Parameters:
name - The name of the parameter
Returns:
The value of the specified parameter
Throws:
PermissionDeniedException - If the logged in user doesn't have permission to read the values
BaseException - If there is another error

setValue

public <T> void setValue(String name,
                         ParameterType<T> type,
                         T value)
              throws PermissionDeniedException,
                     InvalidDataException,
                     BaseException
Set the value on either the job or configuration, depending in the preferJob parameter that was set when creating this object.

Specified by:
setValue in interface ParameterValues
Parameters:
name - The name of the parameter
type - The type of the value
value - The value to be set
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If the value is invalid according to the settings in the type
BaseException - If there is another error

setValues

public <T> void setValues(String name,
                          ParameterType<T> type,
                          List<T> values)
               throws PermissionDeniedException,
                      InvalidDataException,
                      BaseException
Set the value on either the job or configuration, depending in the preferJob parameter that was set when creating this object.

Specified by:
setValues in interface ParameterValues
Parameters:
name - The name of the parameter
type - The type of the value
values - A list containing the values
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If any of the values is invalid according to the settings in the type
BaseException - If there is another error

2.17.2: 2011-06-17