org.oddjob.values
Class VariablesJob

java.lang.Object
  extended by org.oddjob.framework.BaseComponent
      extended by org.oddjob.framework.BasePrimary
          extended by org.oddjob.framework.SimpleJob
              extended by org.oddjob.values.VariablesJob
All Implemented Interfaces:
Runnable, org.apache.commons.beanutils.DynaBean, ArooaContextAware, ArooaSessionAware, Forceable, PropertyChangeNotifier, Iconic, LogEnabled, Resetable, Stateful

public class VariablesJob
extends SimpleJob
implements org.apache.commons.beanutils.DynaBean

Description

This job provides a 'variables' like declaration within Oddjob.

The variables job is like a bean where any property can be set with any value.

Because names are properties, they can only be valid simple property names. 'java.version' is not valid simple property because it is interpreted as a value 'java' that has a property 'version'. To allow these type of properties to be referenced in Oddjob use PropertiesJob.

Example

A simple variable.
<oddjob>
    <job>
        <sequential>
            <jobs>
                <variables id="vars">
                    <greeting>
                        <value value="Hello World"/>
                    </greeting>
                </variables>
                <echo name="Echo a Greeting">${vars.greeting}</echo>
            </jobs>
        </sequential>
    </job>
</oddjob>
Author:
rob

Field Summary
 
Fields inherited from class org.oddjob.framework.SimpleJob
stateHandler, stop
 
Fields inherited from class org.oddjob.framework.BaseComponent
iconHelper
 
Constructor Summary
VariablesJob()
           
 
Method Summary
 boolean contains(String name, String key)
          Does the specified mapped property contain a value for the specified key value?
protected  int execute()
          Execute this job.
 Object get(String name)
          Return the value of a simple property with the specified name.
 Object get(String name, int index)
          Return the value of an indexed property with the specified name.
 Object get(String name, String key)
          Return the value of a mapped property with the specified name, or null if there is no value for the specified key.
 org.apache.commons.beanutils.DynaClass getDynaClass()
          Return the DynaClass instance that describes the set of properties available for this DynaBean.
protected  void onReset()
          Allow sub classes to do something on reset.
 void remove(String name, String key)
          Remove any existing value for the specified key on the specified mapped property.
 void set(String name, int index, Object value)
          Set the value of an indexed property with the specified name.
 void set(String name, Object value)
          Set the value of a simple property with the specified name.
 void set(String name, String key, Object value)
          Set the value of a mapped property with the specified name.
 void setValue(String name, ArooaValue value)
          Add a name value pair.
 String toString()
          Override toString.
 
Methods inherited from class org.oddjob.framework.SimpleJob
fireDestroyedState, force, getStateChanger, hardReset, onDestroy, onStop, run, sleep, softReset, stateHandler, stop
 
Methods inherited from class org.oddjob.framework.BasePrimary
configure, getName, logger, logger, loggerName, save, setName
 
Methods inherited from class org.oddjob.framework.BaseComponent
addIconListener, addPropertyChangeListener, addStateListener, configure, destroy, firePropertyChange, getArooaSession, iconForId, initialise, lastStateEvent, onConfigured, onInitialised, removeIconListener, removePropertyChangeListener, removeStateListener, save, setArooaContext, setArooaSession
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.oddjob.Stateful
addStateListener, lastStateEvent, removeStateListener
 

Constructor Detail

VariablesJob

public VariablesJob()
Method Detail

setValue

public void setValue(String name,
                     ArooaValue value)
Add a name value pair. This method will be called during parsing.

Parameters:
name - The name of the variable.
value - The runtime configurable for the value.

execute

protected int execute()
               throws Exception
Description copied from class: SimpleJob
Execute this job.

Specified by:
execute in class SimpleJob
Returns:
0 if the job is complete, anything else otherwise.
Throws:
Exception - If the unexpected occurs.

onReset

protected void onReset()
Description copied from class: SimpleJob
Allow sub classes to do something on reset.

Overrides:
onReset in class SimpleJob

contains

public boolean contains(String name,
                        String key)
Does the specified mapped property contain a value for the specified key value?

Specified by:
contains in interface org.apache.commons.beanutils.DynaBean
Parameters:
name - Name of the property to check
key - Name of the key to check
Throws:
IllegalArgumentException - if there is no property of the specified name

get

public Object get(String name)
Return the value of a simple property with the specified name.

Specified by:
get in interface org.apache.commons.beanutils.DynaBean
Parameters:
name - Name of the property whose value is to be retrieved
Throws:
IllegalArgumentException - if there is no property of the specified name

get

public Object get(String name,
                  int index)
Return the value of an indexed property with the specified name.

Specified by:
get in interface org.apache.commons.beanutils.DynaBean
Parameters:
name - Name of the property whose value is to be retrieved
index - Index of the value to be retrieved
Throws:
IllegalArgumentException - if there is no property of the specified name
IllegalArgumentException - if the specified property exists, but is not indexed
IndexOutOfBoundsException - if the specified index is outside the range of the underlying property
NullPointerException - if no array or List has been initialized for this property

get

public Object get(String name,
                  String key)
Return the value of a mapped property with the specified name, or null if there is no value for the specified key.

Specified by:
get in interface org.apache.commons.beanutils.DynaBean
Parameters:
name - Name of the property whose value is to be retrieved
key - Key of the value to be retrieved
Throws:
IllegalArgumentException - if there is no property of the specified name
IllegalArgumentException - if the specified property exists, but is not mapped

getDynaClass

public org.apache.commons.beanutils.DynaClass getDynaClass()
Return the DynaClass instance that describes the set of properties available for this DynaBean.

Specified by:
getDynaClass in interface org.apache.commons.beanutils.DynaBean

remove

public void remove(String name,
                   String key)
Remove any existing value for the specified key on the specified mapped property.

Specified by:
remove in interface org.apache.commons.beanutils.DynaBean
Parameters:
name - Name of the property for which a value is to be removed
key - Key of the value to be removed
Throws:
IllegalArgumentException - if there is no property of the specified name

set

public void set(String name,
                Object value)
Set the value of a simple property with the specified name.

Specified by:
set in interface org.apache.commons.beanutils.DynaBean
Parameters:
name - Name of the property whose value is to be set
value - Value to which this property is to be set
Throws:
org.apache.commons.beanutils.ConversionException - if the specified value cannot be converted to the type required for this property
IllegalArgumentException - if there is no property of the specified name
NullPointerException - if an attempt is made to set a primitive property to null

set

public void set(String name,
                int index,
                Object value)
Set the value of an indexed property with the specified name.

Specified by:
set in interface org.apache.commons.beanutils.DynaBean
Parameters:
name - Name of the property whose value is to be set
index - Index of the property to be set
value - Value to which this property is to be set
Throws:
org.apache.commons.beanutils.ConversionException - if the specified value cannot be converted to the type required for this property
IllegalArgumentException - if there is no property of the specified name
IllegalArgumentException - if the specified property exists, but is not indexed
IndexOutOfBoundsException - if the specified index is outside the range of the underlying property

set

public void set(String name,
                String key,
                Object value)
Set the value of a mapped property with the specified name.

Specified by:
set in interface org.apache.commons.beanutils.DynaBean
Parameters:
name - Name of the property whose value is to be set
key - Key of the property to be set
value - Value to which this property is to be set
Throws:
org.apache.commons.beanutils.ConversionException - if the specified value cannot be converted to the type required for this property
IllegalArgumentException - if there is no property of the specified name
IllegalArgumentException - if the specified property exists, but is not mapped

toString

public String toString()
Description copied from class: BasePrimary
Override toString.

Overrides:
toString in class BasePrimary