com.jbbres.lib.actions.tools.elements
Class AbstractVariableService<C>

java.lang.Object
  extended by com.jbbres.lib.actions.tools.elements.AbstractElementService
      extended by com.jbbres.lib.actions.tools.elements.AbstractVariableService<C>
Type Parameters:
C - - Class of the object that the variable can store.
All Implemented Interfaces:
ElementService, VariableService

public abstract class AbstractVariableService<C>
extends AbstractElementService
implements VariableService

This abstract class provides default implementations for most of the methods in the VariableService interface.

You need to create a sub-class of AbstractVariableService if you are implementing a variable based on AbstractVariable. However, it is recommended to create your own variables as subclasses of RuntimeVariable or StorageVariable instead.

Since:
1.0.0
Version:
1.0.0
Author:
Jean-Baptiste Bres

Constructor Summary
AbstractVariableService(AbstractVariable variable)
          Instantiates a new abstract variable service.
 
Method Summary
 void addVariableServiceListener(VariableServiceListener l)
          Adds a listener to this variable.
 void fireVariableInstanceNameChanges(java.lang.String oldInstanceName)
          Calls the variableInstanceNameChanges method of all the listener.
 void fireVariableValueChanges(java.lang.Object oldValue)
          Calls the variableValueChanges method of all the listener.
 java.lang.String getInstanceName()
          Returns the variable instance name.
abstract  Parameters getParameters()
          Returns the current value of the variable, using Parameters format.
 C getValue()
          Returns the current value of the variable.
 VariableServiceListener[] getVariableListeners()
          Returns the variables listeners.
 boolean isValidValueClass(java.lang.Class<? extends java.lang.Object> clazz)
          Returns true if an instance of the given class is an acceptable value for the variable.
 void removeVariableServiceListener(VariableServiceListener l)
          Removes a listener to this variable.
 void setInstanceName(java.lang.String name)
          Sets the variable instance name.
abstract  void setParameters(Parameters parameters)
          Sets the value of the variable.
 java.lang.Object setValue(java.lang.Object newValue)
          Sets the current value of the variable.
 java.lang.Class<? extends java.lang.Object> valueClass()
          Returns the type of the object returned by the getValue method.
 
Methods inherited from class com.jbbres.lib.actions.tools.elements.AbstractElementService
getDescription, getParent, getWorkflow
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.jbbres.lib.actions.elements.VariableService
isEditable
 

Constructor Detail

AbstractVariableService

public AbstractVariableService(AbstractVariable variable)
Instantiates a new abstract variable service.

Parameters:
variable - - the parent variable
Method Detail

setValue

public java.lang.Object setValue(java.lang.Object newValue)
                          throws InvalidVariableValueException
Description copied from interface: VariableService
Sets the current value of the variable.

Specified by:
setValue in interface VariableService
Parameters:
newValue - - the new value of the variable.
Returns:
the previous value of the variable, or null if the variable had no value before the call of this method.
Throws:
InvalidVariableValueException - if an invalid value is trying to be assigned to the variable
See Also:
VariableService.getValue(), VariableService.isValidValueClass(Class)

valueClass

public java.lang.Class<? extends java.lang.Object> valueClass()
Description copied from interface: VariableService
Returns the type of the object returned by the getValue method.

Specified by:
valueClass in interface VariableService
Returns:
the type of the object returned by the getValue method
See Also:
VariableService.getValue()

isValidValueClass

public boolean isValidValueClass(java.lang.Class<? extends java.lang.Object> clazz)
Description copied from interface: VariableService
Returns true if an instance of the given class is an acceptable value for the variable.

Specified by:
isValidValueClass in interface VariableService
Parameters:
clazz - - the clazz
Returns:
true if an instance of the given class is an acceptable value for the variable. false otherwise.
See Also:
VariableService.setValue(Object)

getValue

public C getValue()
Description copied from interface: VariableService
Returns the current value of the variable.

Specified by:
getValue in interface VariableService
Returns:
the current value of the variable
See Also:
VariableService.setValue(Object), VariableService.valueClass()

getInstanceName

public java.lang.String getInstanceName()
Description copied from interface: VariableService
Returns the variable instance name. This name is assigned by the user when adding the variable into the workflow.

Specified by:
getInstanceName in interface VariableService
Returns:
the variable instance name.
See Also:
VariableService.setInstanceName(String)

setInstanceName

public void setInstanceName(java.lang.String name)
                     throws InvalidVariableInstanceNameException
Description copied from interface: VariableService
Sets the variable instance name.

Specified by:
setInstanceName in interface VariableService
Parameters:
name - - new instance name
Throws:
InvalidVariableInstanceNameException - if the instance name is not valid, for example if another variable in the workflow has a similar instance name.
See Also:
VariableService.getInstanceName()

getParameters

public abstract Parameters getParameters()
Returns the current value of the variable, using Parameters format. The value can be stored in a file and restore calling the setParameters method. This method can return null.

Returns:
the current value of the variable.
See Also:
setParameters(Parameters)

setParameters

public abstract void setParameters(Parameters parameters)
                            throws InvalidParametersException
Sets the value of the variable.

Parameters:
parameters - - the parameters. Can be null
Throws:
InvalidParametersException - Raised when the paramters received are incorrect and cannot be mapped in the element.
See Also:
getParameters()

addVariableServiceListener

public void addVariableServiceListener(VariableServiceListener l)
Description copied from interface: VariableService
Adds a listener to this variable.

Specified by:
addVariableServiceListener in interface VariableService
Parameters:
l - - the new listener
See Also:
VariableService.removeVariableServiceListener(VariableServiceListener)

removeVariableServiceListener

public void removeVariableServiceListener(VariableServiceListener l)
Description copied from interface: VariableService
Removes a listener to this variable.

Specified by:
removeVariableServiceListener in interface VariableService
Parameters:
l - - the listener to remove
See Also:
VariableService.addVariableServiceListener(VariableServiceListener)

getVariableListeners

public VariableServiceListener[] getVariableListeners()
Returns the variables listeners.

Returns:
the variables listeners

fireVariableValueChanges

public void fireVariableValueChanges(java.lang.Object oldValue)
Calls the variableValueChanges method of all the listener.

Parameters:
oldValue - - previous value of the variable

fireVariableInstanceNameChanges

public void fireVariableInstanceNameChanges(java.lang.String oldInstanceName)
Calls the variableInstanceNameChanges method of all the listener.

Parameters:
oldInstanceName - - previous instanceName


To file bugs or suggest feature enhancements, visit the app.jbbres.com Bug Reporter website.

Additional documentation available online at http://app.jbbres.com/actions/developers.

Copyright � 2009-2011 app.jbbres.com. All Rights Reserved.