Package ucar.unidata.data
Class DerivedDataChoice
java.lang.Object
ucar.unidata.data.DataChoice
ucar.unidata.data.ListDataChoice
ucar.unidata.data.DerivedDataChoice
A subclass of DataChoice for derived quantities.
- Version:
- $Revision: 1.118 $
- Author:
- IDV Development Team
-
Field Summary
FieldsFields inherited from class ucar.unidata.data.DataChoice
description, id, name, NULL_DATASELECTION, NULL_PROPERTIES, NULL_REQUESTPROPERTIES, parent, PROP_ICON, PROP_REQUESTER, properties
-
Constructor Summary
ConstructorsConstructorDescriptionDummy param-less constructor so we can be recreated thru reflection.DerivedDataChoice
(DataContext dataContext, String formula) Used when not creating it from a DerivedDataDescriptor.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, List dataChoices, String desc, DerivedDataDescriptor ddd) The regular constructor from aDerivedDataDescriptor
TODO: Right now the children of a DerivedDataChoice do not refererence their parent.DerivedDataChoice
(DataContext dataContext, DerivedDataDescriptor ddd) This is the constructor used when creating a DDC as an end user formula.The copy ctor. -
Method Summary
Modifier and TypeMethodDescriptionstatic String
cleanupJythonCode
(String code) Clean up any JythonCode that the user inputscloneMe()
Create a new instance of this object.boolean
Override the equals method.getCode()
Get the code.protected Data
getData
(DataCategory category, DataSelection incomingDataSelection, Hashtable requestProperties) Apply the derived operation.Get the DataContext.Get the DerivedDataDescriptor.Get the formula.Get the full Description for this DataChoice.Get the method name.Get the user selected choices.int
hashCode()
Override the hasCode method.boolean
Is this an (editable) end user formula.static void
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 codevoid
Stub method to keep around so persistence won't flag a warning.void
Set the code.void
Set the DataContext.void
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
-
Field Details
-
PROP_FROMDERIVED
Property indicating this is a derived quantity
-
-
Constructor Details
-
DerivedDataChoice
public DerivedDataChoice()Dummy param-less constructor so we can be recreated thru reflection. -
DerivedDataChoice
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 aDerivedDataDescriptor
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 theIntegratedDataViewer
).dataChoices
- The list of initial children data choices (the operands).desc
- The long description of this choice.ddd
- TheDerivedDataDescriptor
that holds the information to instantiate this choice.
-
DerivedDataChoice
This is the constructor used when creating a DDC as an end user formula.- Parameters:
dataContext
- The context in which this DataChoice exists (typically theIntegratedDataViewer
).ddd
- TheDerivedDataDescriptor
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 theIntegratedDataViewer
).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 ifDataCategory
s.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
Used when not creating it from a DerivedDataDescriptor.- Parameters:
dataContext
- The context in which this DataChoice exists (typically theIntegratedDataViewer
).formula
- The formula body used as the operator
-
-
Method Details
-
cloneMe
Create a new instance of this object.- Overrides:
cloneMe
in classListDataChoice
- Returns:
- The new instance.
-
getFullDescription
Get the full Description for this DataChoice.- Overrides:
getFullDescription
in classListDataChoice
- 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 classListDataChoice
- 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 canelledRemoteException
- Java RMI problemVisADException
- VisAD problem
-
setFormula
Set the formula. Mostly used for xml encoding.- Parameters:
formula
- The new value.
-
getFormula
Get the formula. Mostly used for xml encoding.- Returns:
- The formula.
-
getMethodName
Get the method name. Mostly used for xml encoding.- Returns:
- The method name.
-
setMethodName
Set the method name. Mostly used for xml encoding.- Parameters:
methodName
- The new value.
-
setClassName
Stub method to keep around so persistence won't flag a warning.- Parameters:
m
- class name
-
getCode
Get the code. Mostly used for xml encoding.- Returns:
- The code.
-
setCode
Set the code. Mostly used for xml encoding.- Parameters:
m
- The new value.
-
setUserSelectedChoices
Set the user selected choices. Mostly used for xml encoding.- Parameters:
value
- a hashtable of choices
-
getUserSelectedChoices
Get the user selected choices. Mostly used for xml encoding.- Returns:
- The user selected choices.
-
setDescriptor
Set the descriptor. Mostly used for xml encoding.- Parameters:
value
- the new DerivedDataDescriptor
-
getDataDescriptor
Get the DerivedDataDescriptor. Mostly used for xml encoding.- Returns:
- The DerivedDataDescriptor.
-
setExtraArgs
Dummy for persistence.- Parameters:
foo
- extra args
-
hashCode
public int hashCode()Override the hasCode method.- Overrides:
hashCode
in classListDataChoice
- Returns:
- The object's hashcode.
-
equals
Override the equals method.- Overrides:
equals
in classListDataChoice
- Parameters:
o
- Obejct to compare to.- Returns:
- Is equals?
-
isEndUserFormula
public boolean isEndUserFormula()Is this an (editable) end user formula.- Overrides:
isEndUserFormula
in classDataChoice
- Returns:
- true if no descriptor
-
parseOperands
Parse out the operands in the given Jython code. Return a list ofDataOperand
s- Parameters:
jythonCode
- The code.- Returns:
- List of operands.
-
parseOperands
parse the operands in the given jython code- Parameters:
jythonCode
- jython code to parseoperands
- ???seen
- operands we have seen so far- Returns:
- the operands
-
cleanupJythonCode
Clean up any JythonCode that the user inputs- Parameters:
code
- code to clean up- Returns:
- cleaned up code
-
getDataContext
Get the DataContext. Mostly used for xml encoding.- Returns:
- The DataContext.
-
setDataContext
Set the DataContext. Mostly used for xml encoding.- Parameters:
c
- The new value.
-
main
Method for testing.- Parameters:
args
- operands
-