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

java.lang.Object
  extended by com.jbbres.lib.actions.tools.elements.SimpleElement
      extended by com.jbbres.lib.actions.tools.elements.SimpleVariable<C>
All Implemented Interfaces:
Element, ElementService, Variable, VariableService
Direct Known Subclasses:
RuntimeVariable, StorageVariable

public abstract class SimpleVariable<C>
extends SimpleElement
implements Variable, VariableService

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

it is recommended to create your own variables as subclasses of RuntimeVariable or StorageVariable.


Release Notes:

v1.1.0:

  • Improved validation of valid value (isValidValueClass(Class))
  • Since:
    1.0.0
    Version:
    1.1.0
    Author:
    Jean-Baptiste Bres

    Constructor Summary
    SimpleVariable(Workflow workflow)
              Instantiates a new variable.
     
    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.
     VariableDescription getDescription()
              Returns the description of the element.
     java.lang.String getInstanceName()
              Returns the variable instance name.
     VariableService getService()
              Returns the service associated to the element.
     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.
     java.lang.Object setValue(java.lang.Object newValue)
              Overriden for internal use.
    abstract  void setVariableValue(C newValue)
              Sets the variable value.
     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.SimpleElement
    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.Variable
    getEditor, getRenderer
     
    Methods inherited from interface com.jbbres.lib.actions.elements.Element
    getParameters, setParameters
     
    Methods inherited from interface com.jbbres.lib.actions.elements.VariableService
    getValue, isEditable
     

    Constructor Detail

    SimpleVariable

    public SimpleVariable(Workflow workflow)
    Instantiates a new variable.

    Parameters:
    workflow - - the workflow
    Method Detail

    getService

    public VariableService getService()
    Description copied from interface: Element
    Returns the service associated to the element. The service describes how the element performs within the workflow. For example, if the element is an action, the service will contain the executable methods that the action is designed to perform. If the element is a variable, the service will contain methods related to data access.

    Specified by:
    getService in interface Element
    Specified by:
    getService in interface Variable
    Overrides:
    getService in class SimpleElement
    Returns:
    the service associated to the element.
    See Also:
    ElementService

    setVariableValue

    public abstract void setVariableValue(C newValue)
                                   throws InvalidVariableValueException
    Sets the variable value.

    Parameters:
    newValue - the new variable value
    Throws:
    InvalidVariableValueException - the invalid variable value exception

    setValue

    public java.lang.Object setValue(java.lang.Object newValue)
                              throws InvalidVariableValueException
    Overriden for internal use.

    Use setVariableValue(Object) instead.

    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)

    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()

    getDescription

    public VariableDescription getDescription()
    Description copied from interface: Element
    Returns the description of the element. The description is a dictionary derived from the element description, usually the information specified in the element information property list.

    Specified by:
    getDescription in interface Element
    Specified by:
    getDescription in interface Variable
    Overrides:
    getDescription in class SimpleElement
    Returns:
    the description of the element.
    See Also:
    ElementDescription

    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.