ucar.unidata.data
Class DerivedDataChoice

java.lang.Object
  extended by ucar.unidata.data.DataChoice
      extended by ucar.unidata.data.ListDataChoice
          extended by ucar.unidata.data.DerivedDataChoice

public class DerivedDataChoice
extends ListDataChoice

A subclass of DataChoice for derived quantities.

Version:
$Revision: 1.118 $
Author:
IDV Development Team

Field Summary
static String PROP_FROMDERIVED
          Property indicating this is a derived quantity
 
Fields inherited from class ucar.unidata.data.DataChoice
description, id, name, NULL_DATASELECTION, NULL_PROPERTIES, NULL_REQUESTPROPERTIES, parent, PROP_ICON, PROP_REQUESTER, properties
 
Constructor Summary
DerivedDataChoice()
          Dummy param-less constructor so we can be recreated thru reflection.
DerivedDataChoice(DataContext dataContext, DerivedDataDescriptor ddd)
          This is the constructor used when creating a DDC as an end user formula.
DerivedDataChoice(DataContext dataContext, List dataChoices, String desc, DerivedDataDescriptor ddd)
          The regular constructor from a DerivedDataDescriptor TODO: Right now the children of a DerivedDataChoice do not refererence their parent.
DerivedDataChoice(DataContext dataContext, List dataChoices, String name, String description, String categories, String method, String formula, String code)
          Used when not creating it from a DerivedDataDescriptor.
DerivedDataChoice(DataContext dataContext, String formula)
          Used when not creating it from a DerivedDataDescriptor.
DerivedDataChoice(DerivedDataChoice that)
          The copy ctor.
 
Method Summary
static String cleanupJythonCode(String code)
          Clean up any JythonCode that the user inputs
 DataChoice cloneMe()
          Create a new instance of this object.
 boolean equals(Object o)
          Override the equals method.
 String getCode()
          Get the code.
protected  Data getData(DataCategory category, DataSelection incomingDataSelection, Hashtable requestProperties)
          Apply the derived operation.
 DataContext getDataContext()
          Get the DataContext.
 DerivedDataDescriptor getDataDescriptor()
          Get the DerivedDataDescriptor.
 String getFormula()
          Get the formula.
 String getFullDescription()
          Get the full Description for this DataChoice.
 String getMethodName()
          Get the method name.
 Hashtable getUserSelectedChoices()
          Get the user selected choices.
 int hashCode()
          Override the hasCode method.
 boolean isEndUserFormula()
          Is this an (editable) end user formula.
static void main(String[] args)
          Method for testing.
static List parseOperands(String jythonCode)
          Parse out the operands in the given Jython code.
static List parseOperands(String jythonCode, List operands, Hashtable seen)
          parse the operands in the given jython code
 void setClassName(String m)
          Stub method to keep around so persistence won't flag a warning.
 void setCode(String m)
          Set the code.
 void setDataContext(DataContext c)
          Set the DataContext.
 void setDescriptor(DerivedDataDescriptor value)
          Set the descriptor.
 void setExtraArgs(String foo)
          Dummy for persistence.
 void setFormula(String formula)
          Set the formula.
 void setMethodName(String methodName)
          Set the method name.
 void setUserSelectedChoices(Hashtable value)
          Set the user selected choices.
 
Methods inherited from class ucar.unidata.data.ListDataChoice
addDataChangeListener, addDataChangeListeners, basicallyEquals, checkCategories, convertLabel, findDataCategories, flushCache, getAllDateTimes, getAllLevels, getChoices, getDataList, getDataSources, getFinalDataChoices, getIndexedName, getSelectedDateTimes, inherit, initAfterUnPersistence, removeDataChangeListener, setChildrenDataChoices, setChoices
 
Methods inherited from class ucar.unidata.data.DataChoice
addCategory, addCurrentName, addParamNameToCategories, cloneDataChoices, createClone, getAllLevels, getCategories, getCurrentNames, getData, getData, getDataCategories, getDataCategories, getDataSelection, getDescription, getDisplayCategory, getFixedRequestProperties, getForUser, getId, getName, getParent, getProperties, getProperty, getProperty, getProperty, getStringId, mergeRequestProperties, setCategories, setDataCategories, setDataSelection, setDescription, setFixedRequestProperties, setId, setLevelSelection, setName, setObjectProperty, setParent, setProperties, setProperty, setProperty, setTimeSelection, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

PROP_FROMDERIVED

public static String PROP_FROMDERIVED
Property indicating this is a derived quantity

Constructor Detail

DerivedDataChoice

public DerivedDataChoice()
Dummy param-less constructor so we can be recreated thru reflection.


DerivedDataChoice

public DerivedDataChoice(DerivedDataChoice that)
The copy ctor.

Parameters:
that - The object to instantiate from.

DerivedDataChoice

public DerivedDataChoice(DataContext dataContext,
                         List dataChoices,
                         String desc,
                         DerivedDataDescriptor ddd)
The regular constructor from a DerivedDataDescriptor TODO: Right now the children of a DerivedDataChoice do not refererence their parent. If they do we will need to clone the children here so a DataChoice only has one parent.

Parameters:
dataContext - The context in which this DataChoice exists (typically the IntegratedDataViewer).
dataChoices - The list of initial children data choices (the operands).
desc - The long description of this choice.
ddd - The DerivedDataDescriptor that holds the information to instantiate this choice.

DerivedDataChoice

public DerivedDataChoice(DataContext dataContext,
                         DerivedDataDescriptor ddd)
This is the constructor used when creating a DDC as an end user formula.

Parameters:
dataContext - The context in which this DataChoice exists (typically the IntegratedDataViewer).
ddd - The DerivedDataDescriptor that holds the information to instantiate this choice.

DerivedDataChoice

public DerivedDataChoice(DataContext dataContext,
                         List dataChoices,
                         String name,
                         String description,
                         String categories,
                         String method,
                         String formula,
                         String code)
Used when not creating it from a DerivedDataDescriptor.

Parameters:
dataContext - The context in which this DataChoice exists (typically the IntegratedDataViewer).
dataChoices - The list of initial children data choices (the operands).
name - The name of this DataChoice.
description - The description of this DataChoice.
categories - The list if DataCategorys.
method - The method name used as the operator (may be null).
formula - The formula body used as the operator (may be null).
code - The code body used as the operator (may be null). (Note: having different code and formula attributes is just a hangover from the initial development. They are acted upon in the same way.

DerivedDataChoice

public DerivedDataChoice(DataContext dataContext,
                         String formula)
Used when not creating it from a DerivedDataDescriptor.

Parameters:
dataContext - The context in which this DataChoice exists (typically the IntegratedDataViewer).
formula - The formula body used as the operator
Method Detail

cloneMe

public DataChoice cloneMe()
Create a new instance of this object.

Overrides:
cloneMe in class ListDataChoice
Returns:
The new instance.

getFullDescription

public String getFullDescription()
Get the full Description for this DataChoice.

Overrides:
getFullDescription in class ListDataChoice
Returns:
full description

getData

protected Data getData(DataCategory category,
                       DataSelection incomingDataSelection,
                       Hashtable requestProperties)
                throws VisADException,
                       RemoteException,
                       DataCancelException
Apply the derived operation. If any of the getData of the sub-dataChoices returns null or if on a user select we get null back then this returns null.

Overrides:
getData in class ListDataChoice
Parameters:
category - Ignore this for now.
incomingDataSelection - Allows one to subset the getData call (e.g., selecting times).
requestProperties - extra request properties
Returns:
The Data object that is the result of applying the operator held by this choice to its set of operands.
Throws:
DataCancelException - if the request was canelled
RemoteException - Java RMI problem
VisADException - VisAD problem

setFormula

public void setFormula(String formula)
Set the formula. Mostly used for xml encoding.

Parameters:
formula - The new value.

getFormula

public String getFormula()
Get the formula. Mostly used for xml encoding.

Returns:
The formula.

getMethodName

public String getMethodName()
Get the method name. Mostly used for xml encoding.

Returns:
The method name.

setMethodName

public void setMethodName(String methodName)
Set the method name. Mostly used for xml encoding.

Parameters:
methodName - The new value.

setClassName

public void setClassName(String m)
Stub method to keep around so persistence won't flag a warning.

Parameters:
m - class name

getCode

public String getCode()
Get the code. Mostly used for xml encoding.

Returns:
The code.

setCode

public void setCode(String m)
Set the code. Mostly used for xml encoding.

Parameters:
m - The new value.

setUserSelectedChoices

public void setUserSelectedChoices(Hashtable value)
Set the user selected choices. Mostly used for xml encoding.

Parameters:
value - a hashtable of choices

getUserSelectedChoices

public Hashtable getUserSelectedChoices()
Get the user selected choices. Mostly used for xml encoding.

Returns:
The user selected choices.

setDescriptor

public void setDescriptor(DerivedDataDescriptor value)
Set the descriptor. Mostly used for xml encoding.

Parameters:
value - the new DerivedDataDescriptor

getDataDescriptor

public DerivedDataDescriptor getDataDescriptor()
Get the DerivedDataDescriptor. Mostly used for xml encoding.

Returns:
The DerivedDataDescriptor.

setExtraArgs

public void setExtraArgs(String foo)
Dummy for persistence.

Parameters:
foo - extra args

hashCode

public int hashCode()
Override the hasCode method.

Overrides:
hashCode in class ListDataChoice
Returns:
The object's hashcode.

equals

public boolean equals(Object o)
Override the equals method.

Overrides:
equals in class ListDataChoice
Parameters:
o - Obejct to compare to.
Returns:
Is equals?

isEndUserFormula

public boolean isEndUserFormula()
Is this an (editable) end user formula.

Overrides:
isEndUserFormula in class DataChoice
Returns:
true if no descriptor

parseOperands

public static List parseOperands(String jythonCode)
Parse out the operands in the given Jython code. Return a list of DataOperands

Parameters:
jythonCode - The code.
Returns:
List of operands.

parseOperands

public static List parseOperands(String jythonCode,
                                 List operands,
                                 Hashtable seen)
parse the operands in the given jython code

Parameters:
jythonCode - jython code to parse
operands - ???
seen - operands we have seen so far
Returns:
the operands

cleanupJythonCode

public static String cleanupJythonCode(String code)
Clean up any JythonCode that the user inputs

Parameters:
code - code to clean up
Returns:
cleaned up code

getDataContext

public DataContext getDataContext()
Get the DataContext. Mostly used for xml encoding.

Returns:
The DataContext.

setDataContext

public void setDataContext(DataContext c)
Set the DataContext. Mostly used for xml encoding.

Parameters:
c - The new value.

main

public static void main(String[] args)
Method for testing.

Parameters:
args - operands