org.jdesktop.dataset
Class DataCommand

java.lang.Object
  extended by org.jdesktop.dataset.DataCommand
Direct Known Subclasses:
AbstractSqlCommand

public abstract class DataCommand
extends java.lang.Object

Represents a command that can be executed against a data store by a DataProvider, for example, commands for retrieving data, or for persisting data to the data store. For an example of how this is used, see AbstractSqlCommand. A concrete DataCommand is assigned to a DataProvider using DataProvider.setCommand(DataCommand) and retrieved using DataProvider.getCommand().

A DataCommand holds a set of named parameters, each of which is assigned a value. These parameters are then used in executing the command.

A DataCommand allows a DataProvider to provide a harness around load and save operations, without needing the specifics of interaction with a data store. For SQL databases, a DataCommand may be a SELECT for reads and an INSERT, UPDATE or DELETE for writes. The DataProvider doesn't need to know how these SQL statements are actually built for the table in question--in fact, stored procedures could be used just by substituting the DataCommand used for reads or writes. Note that this abstract DataCommand class does not define the semantics of the commands--that must be done in its subclasses.

Internal--This is a class used internally in this package and is not of general purpose use.

TODO: Appears to be a bug with getParamValues() -- it should only return the values associated with the specified param names. Futher, set/get/clear methods should only work for the specified param names. Alternatively, there should be a default implementation of getParamNames, that returns the keys used in the param map.

The struggle here is that the SQL based DataCommands have a specific set of params -- no more, no less. However, and HTTP based DataCommand can have any number of parameters. It could be a dynamic set.

Author:
rbair

Constructor Summary
DataCommand()
           
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
           
 void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
           
 void clearParameter(java.lang.String name)
          Clears the given named parameter of any associated value.
 void clearParameters()
          Clears all of the parameters; see clearParameter(String)
protected  void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
           
 java.lang.Object getParameter(java.lang.String name)
          Returns the value for the given named parameter.
abstract  java.lang.String[] getParameterNames()
          Returns an array containing all of the parameter names for this DataCommand
 java.lang.Object[] getParameterValues()
          Returns an object array containing all of the parameter values for this DataCommand.
 java.lang.String getShortDescription()
          Returns the short description of this DataCommand
 void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
           
 void setParameter(java.lang.String name, java.lang.Object value)
          Sets the given named parameter to the given value, overwriting any value already assigned.
 void setShortDescription(java.lang.String shortDescription)
          Set a short description for this Task.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataCommand

public DataCommand()
Method Detail

setShortDescription

public void setShortDescription(java.lang.String shortDescription)
Set a short description for this Task. This description is used within a GUI builder to describe what the Task does, or wherever a short description might be useful, such as within some logging statements.


getShortDescription

public java.lang.String getShortDescription()
Returns the short description of this DataCommand

Returns:
the short description

setParameter

public void setParameter(java.lang.String name,
                         java.lang.Object value)
Sets the given named parameter to the given value, overwriting any value already assigned. Passing in a value of "null" will *not* clear the parameter, but will set the parameter to the null value.

Parameters:
name - The parameter's name
value - The parameter's value

clearParameter

public void clearParameter(java.lang.String name)
Clears the given named parameter of any associated value. The parameter is still mapped, but has an undefined value.

Parameters:
name - The named parameter to clear.

clearParameters

public void clearParameters()
Clears all of the parameters; see clearParameter(String)


getParameter

public java.lang.Object getParameter(java.lang.String name)
Returns the value for the given named parameter.

Parameters:
name - The name of the parameter to look up
Returns:
the named parameter's value; null if the parameter was never assigned a value.

getParameterNames

public abstract java.lang.String[] getParameterNames()
Returns an array containing all of the parameter names for this DataCommand

Returns:
an array of the parameter names for this DataCommand

getParameterValues

public java.lang.Object[] getParameterValues()
Returns an object array containing all of the parameter values for this DataCommand.

Returns:
an object array of the parameter values for this DataCommand.

firePropertyChange

protected void firePropertyChange(java.lang.String propertyName,
                                  java.lang.Object oldValue,
                                  java.lang.Object newValue)

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Parameters:
listener -

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String propertyName,
                                      java.beans.PropertyChangeListener listener)
Parameters:
propertyName -
listener -

removePropertyChangeListener

public void removePropertyChangeListener(java.lang.String propertyName,
                                         java.beans.PropertyChangeListener listener)


Copyright © 2005 Sun Microsystems All Rights Reserved.