ucar.unidata.data
Class DerivedDataDescriptor

java.lang.Object
  extended by ucar.unidata.data.DerivedDataDescriptor

public class DerivedDataDescriptor
extends Object

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
static List classes
          A list of String names of full class names taken from the derived.xml <class> tags.
static String NULL_STRING
          NULL string identifier
 
Constructor Summary
DerivedDataDescriptor()
          Dummy constructor for now
DerivedDataDescriptor(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 formula
DerivedDataDescriptor(DataContext dataContext, String id, String desc, String formula, List categories)
          ctor
DerivedDataDescriptor(DerivedDataDescriptor other)
          Copy constructor.
 
Method Summary
static void addToChoicesSoFar(Hashtable choicesSoFar, DataChoice dataChoice)
          Add the given data choice into the Hashtable of choicesSoFar.
 void clearAfterSearch()
          Called by the DerivedDataChoice.getDerivedDataChoices method after the search for the set of possible DerivedDataChoice-s are created.
 boolean equals(Object other)
          Check to see if the Object is equal to this one.
 List getDataCategories()
          Return the list of DataCategorys
 DerivedDataChoice getDataChoice()
          This creates a new DerivedDataChoice whose state is defined by this DerivedDataDescriptor
 NamedList getDataChoices(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.
 DataContext getDataContext()
          Get the DataContext for this descriptor
static 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.
 String getDescription()
          Get the description for this descriptor
 DataCategory getDisplayCategory()
          Return the first DataCategory in the list of categories that is for display purposes.
 String getFormula()
          Get the formula for this derived quantity
 String getId()
          Get the id for this descriptor.
 boolean getIsDefault()
          Get whether this is a default derived quantity.
 boolean getIsEndUser()
          Get whether this is an end user derived quantity
 boolean getIsLocalUsers()
          Get whether this is a formula the user has edited
 String getJythonProcedure()
          Get the Jython procedure for this derived data
 String getJythonProcedure(String procname)
          Get the Jython procedure for the specified procedure name
 List getNeeds()
          Get list of DerivedNeed-s
 String getOperandsCategories()
          Get the OperandsCategories property.
protected  List getOperandsCategoryList()
          get categories for operands
static 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 initForSearch()
          Called by the DerivedDataChoice.getDerivedDataChoices method before the search for the set of possible DerivedDataChoice-s are created.
static void main(String[] args)
          Method to test
static 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 descriptor
 void setDescription(String value)
          Set the description for this descriptor
 void setFormula(String value)
          Set the formula for this derived quantity
 void setId(String value)
          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 edited
 void setNeeds(List<DerivedNeed> needs)
          Set the needs list
 void setOperandsCategories(String value)
          Set the OperandsCategories property.
 String toString()
          Return a string representation of this DerivedDataDescriptor.
 Element toXml(Document doc)
          Return the XML Element that represents this DerivedDataDescriptor
static String toXml(List descriptors)
          Create the xml representation (the derived.xml) of the given list of DerivedDataDescriptors.
 void updateDataGroups()
          Update derived needs when the DataGroups change
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NULL_STRING

public static final String NULL_STRING
NULL string identifier


classes

public static List classes
A list of String names of full class names taken from the derived.xml <class> tags. Used to init the jython interpreter

Constructor Detail

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 descriptor
id - The id
desc - description
formula - formula
categories - List of data categories

DerivedDataDescriptor

public DerivedDataDescriptor(DataContext dataContext)
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 needed
id - identifier
description - long name
categories - list of categories
method - method (may be null)
formula - formula (may be null)
code - jython code (may be null)
properties - extra properties

DerivedDataDescriptor

public DerivedDataDescriptor(DerivedDataDescriptor other)
Copy constructor. Effectively clones this.

Parameters:
other - other instance to copy.
Method Detail

getOperandsCategoryList

protected List getOperandsCategoryList()
get categories for operands

Returns:
categories for operands

getNeeds

public List getNeeds()
Get list of DerivedNeed-s

Returns:
derived needs

setNeeds

public void setNeeds(List<DerivedNeed> needs)
Set the needs list

Parameters:
needs - The needs

setDataCategories

public void setDataCategories(List categories)
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

public List getDataCategories()
Return the list of DataCategorys

Returns:
The list of DataCategorys 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 of DerivedNeed-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 of DerivedNeed-s


getDataChoice

public DerivedDataChoice getDataChoice()
This creates a new DerivedDataChoice whose state is defined by this DerivedDataDescriptor

Returns:
new DDC

getDataChoices

public NamedList getDataChoices(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. If no match return null.

Parameters:
choicesSoFar - table of choices to check
Returns:
NamedList containing the collection of DataChoices or null

toXml

public Element toXml(Document doc)
Return the XML Element that represents this DerivedDataDescriptor

Parameters:
doc - document
Returns:
XML Element representing this.

toString

public String toString()
Return a string representation of this DerivedDataDescriptor.

Overrides:
toString in class Object
Returns:
string representation of this DerivedDataDescriptor

equals

public boolean equals(Object other)
Check to see if the Object is equal to this one.

Overrides:
equals in class Object
Parameters:
other - Object in question
Returns:
true if they are equal

getDisplayCategory

public DataCategory getDisplayCategory()
Return the first DataCategory in the list of categories that is for display purposes.

Returns:
The display category

getJythonProcedure

public String getJythonProcedure()
Get the Jython procedure for this derived data

Returns:
the procedure or null

getJythonProcedure

public String getJythonProcedure(String procname)
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

public void setFormula(String value)
Set the formula for this derived quantity

Parameters:
value - formula

getFormula

public String getFormula()
Get the formula for this derived quantity

Returns:
the formula

setId

public void setId(String value)
Set the id for this descriptor.

Parameters:
value - the id

getId

public String getId()
Get the id for this descriptor.

Returns:
the id

setDescription

public void setDescription(String value)
Set the description for this descriptor

Parameters:
value - the description

getDescription

public String getDescription()
Get the description for this descriptor

Returns:
the description

setDataContext

public void setDataContext(DataContext value)
Set the DataContext for this descriptor

Parameters:
value - the data context

getDataContext

public DataContext getDataContext()
Get the DataContext for this descriptor

Returns:
the data context

readDescriptors

public 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.

Parameters:
dataContext - data context
root - root element
isLocal - Is this one of the users local formulas
Returns:
list of DerivedDataDescriptors

readClasses

public static List readClasses(Element root)
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

public static String toXml(List descriptors)
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

public static 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.

Parameters:
dataContext - the data context
xrc - the resource collection of DDDs
Returns:
List of DerivedDataDescriptors

addToChoicesSoFar

public static void addToChoicesSoFar(Hashtable choicesSoFar,
                                     DataChoice dataChoice)
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 choices
dataChoice - new choice

getDerivedDataChoices

public static 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. 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 search
descriptors - The descriptors
Returns:
list of DDCs in sourceChoices

main

public static void main(String[] args)
Method to test

Parameters:
args - arguments (not used)

setOperandsCategories

public void setOperandsCategories(String value)
Set the OperandsCategories property.

Parameters:
value - The new value for OperandsCategories

getOperandsCategories

public String getOperandsCategories()
Get the OperandsCategories property.

Returns:
The OperandsCategories