Package ucar.unidata.data
Class DerivedDataDescriptor
java.lang.Object
ucar.unidata.data.DerivedDataDescriptor
This class is used to hold the descriptions of possible
DerivedDataChoice
-s that are specified in the derived.xml
resource file.- Version:
- $Revision: 1.77 $
- Author:
- Jeff McWhirter
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDummy constructor for nowDerivedDataDescriptor
(ArrayList needs, String id, String description, ArrayList categories, String method, String formula, String code, Properties properties) Constructor for the descriptor.DerivedDataDescriptor
(DataContext dataContext) Constructor used for when we create an end-user formulaDerivedDataDescriptor
(DataContext dataContext, String id, String desc, String formula, List categories) ctorCopy constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addToChoicesSoFar
(Hashtable choicesSoFar, DataChoice dataChoice) Add the given data choice into the Hashtable of choicesSoFar.void
Called by the DerivedDataChoice.getDerivedDataChoices method after the search for the set of possible DerivedDataChoice-s are created.boolean
Check to see if the Object is equal to this one.Return the list ofDataCategory
sThis creates a new DerivedDataChoice whose state is defined by this DerivedDataDescriptorgetDataChoices
(Hashtable choicesSoFar) If the choicesSoFar map contains each parameter in any of the parameter groups return a NamedList holding the label to be used and the collection of dataChoices that correspond to the required parameters.Get the DataContext for this descriptorstatic List
getDerivedDataChoices
(DataContext context, List sourceChoices, List descriptors) Search through and return a list of DerivedDataChoices that can be created from the given list of sourceChoices.Get the description for this descriptorReturn the firstDataCategory
in the list of categories that is for display purposes.Get the formula for this derived quantitygetId()
Get the id for this descriptor.boolean
Get whether this is a default derived quantity.boolean
Get whether this is an end user derived quantityboolean
Get whether this is a formula the user has editedGet the Jython procedure for this derived datagetJythonProcedure
(String procname) Get the Jython procedure for the specified procedure namegetNeeds()
Get list of DerivedNeed-sGet the OperandsCategories property.protected List
get categories for operandsstatic List
init
(DataContext dataContext, XmlResourceCollection xrc) Go through each xml file defined by the given XmlResourceCollection and create the DerivedDataDescriptor-s defined in the xml.void
Called by the DerivedDataChoice.getDerivedDataChoices method before the search for the set of possible DerivedDataChoice-s are created.static void
Method to teststatic List
readClasses
(Element root) Read in the java classes defined in any class tags under the root.static List
readDescriptors
(DataContext dataContext, Element root, boolean isLocal) Create and return a list of the DDDs that are defined by the given xml root Element.void
setDataCategories
(List categories) Mostly used by the IntegratedDataViewer FormulaDialog when creating an end-user formula.void
setDataContext
(DataContext value) Set the DataContext for this descriptorvoid
setDescription
(String value) Set the description for this descriptorvoid
setFormula
(String value) Set the formula for this derived quantityvoid
Set the id for this descriptor.void
setIsDefault
(boolean value) Set whether this is a default derived quantity.void
setIsEndUser
(boolean value) Set whether this is an end user derived quantity (ie, formula).void
setIsLocalUsers
(boolean value) Set whether this is a formula the user has editedvoid
setNeeds
(List<DerivedNeed> needs) Set the needs listvoid
setOperandsCategories
(String value) Set the OperandsCategories property.toString()
Return a string representation of this DerivedDataDescriptor.static String
Create the xml representation (the derived.xml) of the given list of DerivedDataDescriptors.Return the XML Element that represents this DerivedDataDescriptorvoid
Update derived needs when the DataGroups change
-
Field Details
-
NULL_STRING
NULL string identifier -
classes
A list of String names of full class names taken from the derived.xml <class> tags. Used to init the jython interpreter
-
-
Constructor Details
-
DerivedDataDescriptor
public DerivedDataDescriptor()Dummy constructor for now -
DerivedDataDescriptor
public DerivedDataDescriptor(DataContext dataContext, String id, String desc, String formula, List categories) ctor- Parameters:
dataContext
- context for this descriptorid
- The iddesc
- descriptionformula
- formulacategories
- List of data categories
-
DerivedDataDescriptor
Constructor used for when we create an end-user formula- Parameters:
dataContext
- context for this descriptor
-
DerivedDataDescriptor
public DerivedDataDescriptor(ArrayList needs, String id, String description, ArrayList categories, String method, String formula, String code, Properties properties) Constructor for the descriptor. Pass in the operands, id, etc.- Parameters:
needs
- list of operands neededid
- identifierdescription
- long namecategories
- list of categoriesmethod
- method (may be null)formula
- formula (may be null)code
- jython code (may be null)properties
- extra properties
-
DerivedDataDescriptor
Copy constructor. Effectively clones this.- Parameters:
other
- other instance to copy.
-
-
Method Details
-
getOperandsCategoryList
get categories for operands- Returns:
- categories for operands
-
getNeeds
Get list of DerivedNeed-s- Returns:
- derived needs
-
setNeeds
Set the needs list- Parameters:
needs
- The needs
-
setDataCategories
Mostly used by the IntegratedDataViewer FormulaDialog when creating an end-user formula. Sets the dataCategories that characterize the result of the DerivedDataChoice-s defined by the DDD.- Parameters:
categories
- list of categories
-
getDataCategories
Return the list ofDataCategory
s- Returns:
- The list of
DataCategory
s defined for this descriptor.
-
initForSearch
public void initForSearch()Called by the DerivedDataChoice.getDerivedDataChoices method before the search for the set of possible DerivedDataChoice-s are created. This simply turns around and calls initForSearch on the set ofDerivedNeed
-s -
clearAfterSearch
public void clearAfterSearch()Called by the DerivedDataChoice.getDerivedDataChoices method after the search for the set of possible DerivedDataChoice-s are created. This simply turns around and calls clearAfterSearch on the set ofDerivedNeed
-s -
getDataChoice
This creates a new DerivedDataChoice whose state is defined by this DerivedDataDescriptor- Returns:
- new DDC
-
getDataChoices
If the choicesSoFar map contains each parameter in any of the parameter groups return a NamedList holding the label to be used and the collection of dataChoices that correspond to the required parameters. If no match return null.- Parameters:
choicesSoFar
- table of choices to check- Returns:
- NamedList containing the collection of DataChoices or null
-
toXml
Return the XML Element that represents this DerivedDataDescriptor- Parameters:
doc
- document- Returns:
- XML Element representing this.
-
toString
Return a string representation of this DerivedDataDescriptor. -
equals
Check to see if the Object is equal to this one. -
getDisplayCategory
Return the firstDataCategory
in the list of categories that is for display purposes.- Returns:
- The display category
-
getJythonProcedure
Get the Jython procedure for this derived data- Returns:
- the procedure or
null
-
getJythonProcedure
Get the Jython procedure for the specified procedure name- Parameters:
procname
- procedure name- Returns:
- the Jython procedure
-
setIsEndUser
public void setIsEndUser(boolean value) Set whether this is an end user derived quantity (ie, formula).- Parameters:
value
- true if end user
-
getIsEndUser
public boolean getIsEndUser()Get whether this is an end user derived quantity- Returns:
- true if end user
-
setIsLocalUsers
public void setIsLocalUsers(boolean value) Set whether this is a formula the user has edited- Parameters:
value
- true if end user edited
-
getIsLocalUsers
public boolean getIsLocalUsers()Get whether this is a formula the user has edited- Returns:
- true if end user editable
-
setIsDefault
public void setIsDefault(boolean value) Set whether this is a default derived quantity.- Parameters:
value
- true if default
-
getIsDefault
public boolean getIsDefault()Get whether this is a default derived quantity.- Returns:
- true if default
-
setFormula
Set the formula for this derived quantity- Parameters:
value
- formula
-
getFormula
Get the formula for this derived quantity- Returns:
- the formula
-
setId
Set the id for this descriptor.- Parameters:
value
- the id
-
getId
Get the id for this descriptor.- Returns:
- the id
-
setDescription
Set the description for this descriptor- Parameters:
value
- the description
-
getDescription
Get the description for this descriptor- Returns:
- the description
-
setDataContext
Set the DataContext for this descriptor- Parameters:
value
- the data context
-
getDataContext
Get the DataContext for this descriptor- Returns:
- the data context
-
readDescriptors
Create and return a list of the DDDs that are defined by the given xml root Element.- Parameters:
dataContext
- data contextroot
- root elementisLocal
- Is this one of the users local formulas- Returns:
- list of DerivedDataDescriptors
-
readClasses
Read in the java classes defined in any class tags under the root. We use this to preload the jython interpreter with the full class names so we can later (in the derived.xml) refer to them with just the class name- Parameters:
root
- root element- Returns:
- List of classes
-
toXml
Create the xml representation (the derived.xml) of the given list of DerivedDataDescriptors.- Parameters:
descriptors
- list of descriptors to write out- Returns:
- XML version of this list
-
updateDataGroups
public void updateDataGroups()Update derived needs when the DataGroups change -
init
Go through each xml file defined by the given XmlResourceCollection and create the DerivedDataDescriptor-s defined in the xml.- Parameters:
dataContext
- the data contextxrc
- the resource collection of DDDs- Returns:
- List of DerivedDataDescriptors
-
addToChoicesSoFar
Add the given data choice into the Hashtable of choicesSoFar. We really map the id of the data choice to a list of data choices (one of which is the given dataChoice)- Parameters:
choicesSoFar
- existing choicesdataChoice
- new choice
-
getDerivedDataChoices
Search through and return a list of DerivedDataChoices that can be created from the given list of sourceChoices. We use the DerivedDataDescriptor created from derived.xml to find out what new DDCs can be created. This method serves as a wrapper around the getDerivedDataChoicesInner method, synchronizing on the list- Parameters:
context
- context (the IDV)sourceChoices
- choices to searchdescriptors
- The descriptors- Returns:
- list of DDCs in sourceChoices
-
main
Method to test- Parameters:
args
- arguments (not used)
-
setOperandsCategories
Set the OperandsCategories property.- Parameters:
value
- The new value for OperandsCategories
-
getOperandsCategories
Get the OperandsCategories property.- Returns:
- The OperandsCategories
-