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

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

public abstract class StorageVariable<C>
extends SimpleVariable<C>

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

Subclasses of StorageVariable must be created if you are willing to create your personalized storage variable. A storage variable is a variable that can store specific data used by your application and/or actions.

StorageVariable is a parameterized abstract class with a single type variable, representing the type of object that the variable can store. For example, if your variable is designed to store a date object ( Date), the content of your variable class file will look like the following example:

 package packageName;
 
 import java.text.*;
 import java.util.Date;
 import com.jbbres.lib.actions.elements.*;
 import com.jbbres.lib.actions.tools.elements.StorageVariable;
 import com.jbbres.lib.actions.workflow.Workflow;
 
 public class VStorage extends StorageVariable<Date> {
 
        private DateFormat dateFormat = new SimpleDateFormat("yyyymmdd");
 
        public VStorage(Workflow workflow) {
                super(workflow);
        }
 
        public Parameters getParameters() {
                Parameters parameters = new Parameters();
                String formattedValue = dateFormat.format(getValue());
                parameters.setParameter("value", formattedValue);
                return parameters;
        }
 
        public void setParameters(Parameters parameters)
                        throws InvalidParametersException {
                try {
                        Date value = dateFormat.parse(parameters.getParameter("value"));
                        this.setVariableValue(value);
                } catch (Exception e) {
                        throw new InvalidParametersException(this, parameters);
                }
        }
 }
 
 
The Element.getParameters() and setParameters(Parameters) methods are used by Action(s) to save and restore the default value of the variable when saving and opening a workflow. The default value can be defined by the user when he creates the workflow by editing the variable within the variable table at the bottom of the workflow. As a developer, you have to make sure that the getParameters() method returns the value currently stored in your variable, and that the setParameters(Parameters) replaces the current value of the variable by the one described in the Parameters argument. Action(s) makes sure that the Parameters argument received by the setParameters(Parameters) method is always similar to the one that the getParameters() method has produced.

Note: The default value setting functionality is not available in Action(s) 1.0 but will be added in an upcoming version.

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

Constructor Summary
StorageVariable(Workflow workflow)
          Instantiates a new storage variable.
 
Method Summary
 javax.swing.table.TableCellEditor getEditor()
          Returns the TableCellEditor used to edit the variable value.
 javax.swing.table.TableCellRenderer getRenderer()
          Returns the TableCellRenderer used to render the variable value.
 C getValue()
          Returns the current value of the variable.
 boolean isEditable()
          Defines if the value of the variable can be modified by using the setValue(C) method.
 void setVariableValue(C newValue)
          Sets the variable value.
 
Methods inherited from class com.jbbres.lib.actions.tools.elements.SimpleVariable
addVariableServiceListener, fireVariableInstanceNameChanges, fireVariableValueChanges, getDescription, getInstanceName, getService, getVariableListeners, isValidValueClass, removeVariableServiceListener, setInstanceName, setValue, valueClass
 
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.Element
getParameters, setParameters
 

Constructor Detail

StorageVariable

public StorageVariable(Workflow workflow)
Instantiates a new storage variable.

Parameters:
workflow - the workflow
Method Detail

setVariableValue

public void setVariableValue(C newValue)
Description copied from class: SimpleVariable
Sets the variable value.

Specified by:
setVariableValue in class SimpleVariable<C>
Parameters:
newValue - the new variable value

getValue

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

Returns:
the current value of the variable
See Also:
VariableService.setValue(Object), VariableService.valueClass()

getEditor

public javax.swing.table.TableCellEditor getEditor()
Description copied from interface: Variable
Returns the TableCellEditor used to edit the variable value.

This method is not used in Action(s) 1.0.

Returns:
the editor

getRenderer

public javax.swing.table.TableCellRenderer getRenderer()
Description copied from interface: Variable
Returns the TableCellRenderer used to render the variable value.

This method is not used in Action(s) 1.0.

Returns:
the renderer

isEditable

public boolean isEditable()
Description copied from interface: VariableService
Defines if the value of the variable can be modified by using the setValue(C) method.

If this methods returns true, calling the setValue(C) method should have no effect.

Returns:
true if the value of the variable can be modified by using the setValue(C) method. false otherwise.


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.