Class DataChoice

java.lang.Object
ucar.unidata.data.DataChoice
Direct Known Subclasses:
DataDataChoice, DirectDataChoice, ListDataChoice, UnboundDataChoice, UrlDataChoice, UserDataChoice

public abstract class DataChoice extends Object
An abstract base class that represents some selection of data. A DataChoice is created with an identifying Object (e.g., a date/time, a field name, etc.) a String name, a String description and a set of DataCategorys that represent the flavor or flavors of data provided by this DataChoice.
Author:
IDV development team
  • Field Details

    • NULL_DATASELECTION

      public static final DataSelection NULL_DATASELECTION
    • NULL_PROPERTIES

      public static final Hashtable NULL_PROPERTIES
      A null properties intrinsic
    • PROP_REQUESTER

      public static final String PROP_REQUESTER
      The requester property
      See Also:
    • PROP_ICON

      public static final String PROP_ICON
      The icon property
      See Also:
    • NULL_REQUESTPROPERTIES

      public static final Hashtable NULL_REQUESTPROPERTIES
      The null request properties intrinsic
    • properties

      protected Hashtable properties
      A general properties table.
    • parent

      protected DataChoice parent
      DataChoice-s can follow a composite pattern. The parent member is a (possibly null) reference to the parent DataChoice.
    • id

      protected Object id
      The identifying object.
    • name

      protected String name
      Short descriptive name (e.g., T, U, etc.).
    • description

      protected String description
      Long descriptive name (e.g, "isobaric temperature", "u component of wind", etc.)
  • Constructor Details

    • DataChoice

      public DataChoice()
      The bean constructor. We need this for xml decoding.
    • DataChoice

      public DataChoice(DataChoice other)
      Create a new DataChoice, using the state of the given DataChoice to initialize the new object.
      Parameters:
      other - The other data choice.
    • DataChoice

      public DataChoice(Object id, String name, String description, List categories)
      Create a new DataChoice.
      Parameters:
      id - The identifying object.
      name - The short name of this choice.
      description - The long description of this choice.
      categories - List of DataCategorys.
    • DataChoice

      public DataChoice(Object id, String name, String description, List categories, Hashtable properties)
      Create a new DataChoice.
      Parameters:
      id - The identifying object.
      name - The short name of this choice.
      description - The long description of this choice.
      categories - List of DataCategorys.
      properties - The properties for this data choice (may be null).
    • DataChoice

      public DataChoice(Object id, String description)
      Create a new DataChoice. Use a null list of categories.
      Parameters:
      id - The identifying object.
      description - The long description of this choice.
    • DataChoice

      public DataChoice(Object id, String description, List categories)
      Create a new DataChoice. Use the description as the name of the DataChoice.
      Parameters:
      id - The identifying object.
      description - The long description of this choice.
      categories - List of DataCategorys.
    • DataChoice

      public DataChoice(Object id, String description, DataCategory category)
      Create a new DataChoice.
      Parameters:
      id - The identifying object.
      description - The long description of this choice.
      category - The DataCategory.
  • Method Details

    • addCurrentName

      public static void addCurrentName(Object name)
      This adds into a globallist the given param name
      Parameters:
      name - param name to add
    • getCurrentNames

      public static List getCurrentNames()
      Get the list of all data choice names there ever was during the run
      Returns:
      data choice names
    • initAfterUnPersistence

      public void initAfterUnPersistence(Hashtable properties)
      This gets called after the data choice has been unpersisted
      Parameters:
      properties - Properties
    • getFinalDataChoices

      public void getFinalDataChoices(List dataChoices)
      Add to the given list all final data choices (i.e., the leafs of the datachoice tree)
      Parameters:
      dataChoices - List to put data choices into
    • getDataSources

      public void getDataSources(List dataSources)
      Add to the given list all the data sources
      Parameters:
      dataSources - List to put data sources into
    • addParamNameToCategories

      protected void addParamNameToCategories()
      Add the DataCategory "param:" and "param:" to the list of data categories.
    • setDataSelection

      public void setDataSelection(DataSelection dataSelection)
      Set the data time selection for this choice
      Parameters:
      dataSelection - The data Selection
    • getDataSelection

      public DataSelection getDataSelection()
      Get the data selection for this choice
      Returns:
      the dataselection
    • setTimeSelection

      public void setTimeSelection(List times)
      Set the time selection for this choice
      Parameters:
      times - List of times
    • setLevelSelection

      public void setLevelSelection(Real level)
      Set the level
      Parameters:
      level - The level
    • getAllLevels

      public List getAllLevels()
      Get all the levels associated with this choice
      Returns:
      List of levels
    • getAllLevels

      public List getAllLevels(DataSelection dataSelection)
      Get all the levels associated with this choice
      Parameters:
      dataSelection - data selection
      Returns:
      List of levels
    • getAllDateTimes

      public List getAllDateTimes()
      Get all the times associated with this choice
      Returns:
      List of times
    • getSelectedDateTimes

      public List getSelectedDateTimes()
      Get the List of selected times (sub selection of all times).
      Returns:
      selected times
    • cloneDataChoices

      public static List cloneDataChoices(List listOfChoices)
      Utility method to clone and return a list of DataChoice-s.
      Parameters:
      listOfChoices - The source list of choices.
      Returns:
      The list of cloned choices.
    • createClone

      public final DataChoice createClone()
      Create a new instance of this DataChoice.
      Returns:
      The new instance.
    • cloneMe

      public abstract DataChoice cloneMe()
      Create a new instance of this DataChoice.
      Returns:
      The new instance.
    • getParent

      public DataChoice getParent()
      Return the parent of this DataChoice (may be, and usually is, null). This is used for the DerivedDataChoice-s somewhat composite pattern.
      Returns:
      The parent of this data choice.
    • setParent

      public void setParent(DataChoice parent)
      Set the parent of this DataChoice. This is used by the CompositeDataChoice
      Parameters:
      parent - The new parent of this data choice.
    • getForUser

      public boolean getForUser()
      A DataChoice can be not intended to be shown to the user within a UI. For example, it may be a DerivedDataChoice that is used to calculate an intermediate value but where it doesn't make sense to show it to the user.
      Returns:
      Is this DataChoice intended for the user to see.
    • getDisplayCategory

      public DataCategory getDisplayCategory()
      Return the DataCategory that is meant to be used for displaying this DataChoice within a UI. For now just return the first category this is "forDisplay".
      Returns:
      The DataCategory used for display.
    • addCategory

      public void addCategory(DataCategory newCategory)
      Add the given DataCategory into the list of data categories.
      Parameters:
      newCategory - The new DataCategory
    • getCategories

      public List getCategories()
      Get the list of DataCategorys that this DataChoice represents.
      Returns:
      The list of data categories.
    • getDataCategories

      public List getDataCategories()
      Get the list of DataCategory-s. Note: this is now deprecated. The problem is that we had the getDataCategories and getCategories methods. These would get used in wrting to a bundle and we'd end up clobbering any display categorie. deprecated
      Returns:
      data categories
    • getDataCategories

      public List getDataCategories(boolean excludeDisplayCategories)
      Get the list of DataCategory-s but exclude any that are used for display if excludeDisplayCategories is true
      Parameters:
      excludeDisplayCategories - if true then only return the data categories that are not display categories
      Returns:
      data categories
    • setDataCategories

      public void setDataCategories(List categories)
      Note: This does not do anything anymore. It still needs to be around for old bundles but the list of categories excluded any display categories and would clobber the main categories list deprecated Does nothing now.
      Parameters:
      categories - The list of data categories.
    • setCategories

      public void setCategories(List categories)
      Set the list of DataCategorys that this DataChoice represents.
      Parameters:
      categories - The list of data categories.
    • getData

      public final Data getData(DataSelection incomingDataSelection) throws VisADException, RemoteException, DataCancelException
      Return the Data object that this DataChoice represents. Merge this object's DataSelection with the argument DataSelection (which has higher priority).
      Parameters:
      incomingDataSelection - Allows one to subset the request.
      Returns:
      The data.
      Throws:
      DataCancelException - if the request to get data is canceled
      RemoteException - problem accessing remote data
      VisADException - problem creating the Data object
    • getData

      public final Data getData(DataSelection incomingDataSelection, Hashtable requestProperties) throws VisADException, RemoteException, DataCancelException
      Return the Data object that this DataChoice represents. Merge this object's DataSelection with the argument DataSelection (which has higher priority).
      Parameters:
      incomingDataSelection - Allows one to subset the request.
      requestProperties - The object requesting this data.
      Returns:
      The data.
      Throws:
      DataCancelException - if the request to get data is canceled
      RemoteException - problem accessing remote data
      VisADException - problem creating the Data object
    • getData

      protected abstract Data getData(DataCategory category, DataSelection dataSelection, Hashtable requestProperties) throws VisADException, RemoteException, DataCancelException
      Return the Data object that this DataChoice represents.
      Parameters:
      category - The DataCategory used to subset this call (usually not used but placed in here just in case it is needed.)
      dataSelection - Allows one to subset the data request (e.g., asking for a smaller set of times, etc.)
      requestProperties - Extra selection properties
      Returns:
      The data.
      Throws:
      DataCancelException - if the request to get data is canceled
      RemoteException - problem accessing remote data
      VisADException - problem creating the Data object
    • mergeRequestProperties

      public static Hashtable mergeRequestProperties(Hashtable incoming, Hashtable fixedRequestProperties)
      Merge the given incoming request properties with the ones held by this data choice.
      Parameters:
      incoming - Incoming choices
      fixedRequestProperties - The lower priority hashtable
      Returns:
      Merged set of choices with the incomng having priority.
    • hashCode

      public int hashCode()
      Override the hashCodes method.
      Overrides:
      hashCode in class Object
      Returns:
      Object's hash code value.
    • equals

      public boolean equals(Object other)
      Check for equality of this object to another
      Overrides:
      equals in class Object
      Parameters:
      other - Object to check equality.
      Returns:
      true if equals to the other.
    • basicallyEquals

      public boolean basicallyEquals(DataChoice that)
      This just checks for basic equality. Things like id, datasource, etc.
      Parameters:
      that - The object ot check for equality
      Returns:
      Is basically equals
    • getStringId

      public String getStringId()
      Return the toString() value of the id.
      Returns:
      the toString() value of the id.
    • getIndexedName

      public String getIndexedName(int index)
      Return the indexed name, the default is to simply return the name. This method provides a hook for derived classes to return different names. For example, the DerivedDataChoice uses this to return the name of the index'th operand.
      Parameters:
      index - The (0 based) index.
      Returns:
      By default, the name of this DataChoice.
    • getName

      public String getName()
      Return the name of this DataChoice.
      Returns:
      The name of the DataChoice.
    • setName

      public void setName(String newName)
      Set the name of this DataChoice. This is mostly for the xml encoding.
      Parameters:
      newName - The new name.
    • getDescription

      public String getDescription()
      Return the human readable description. This is typically longer than the name.
      Returns:
      The description of this DataChoice.
    • setDescription

      public void setDescription(String desc)
      Set the human readable description. Usually used for xml decoding.
      Parameters:
      desc - The new description.
    • getFullDescription

      public String getFullDescription()
      This method is used to get a lengthy description of this DataChoice. This is used by the DataTree to show a tooltip. By default it just returns the name concatenated with the description but can be overwritten.
      Returns:
      The name concatenated with the description.
    • setId

      public void setId(Object theId)
      DataChoices typically have some identifying Object associated with them (e.g., a time, a field name, etc.)
      Parameters:
      theId - The identifying Object.
    • getId

      public Object getId()
      Return the identifying object.
      Returns:
      The identifying object.
    • toString

      public String toString()
      Return the description.
      Overrides:
      toString in class Object
      Returns:
      The description.
    • setProperty

      public void setProperty(String name, boolean propertyValue)
      Set the boolean property.
      Parameters:
      name - Property name.
      propertyValue - boolean property value
    • setObjectProperty

      public void setObjectProperty(String name, Object propertyValue)
      Set the String property.
      Parameters:
      name - Property name.
      propertyValue - String property value
    • setProperty

      public void setProperty(String name, String propertyValue)
      Set the property.
      Parameters:
      name - Property name.
      propertyValue - String property value
    • getProperty

      public boolean getProperty(String name, boolean dflt)
      Return the boolean property, if not found return the dflt.
      Parameters:
      name - Property name.
      dflt - The default value.
      Returns:
      The boolean property value or the dflt argument if not found.
    • getProperty

      public String getProperty(String name, String dflt)
      Return the String property, if not found return the dflt.
      Parameters:
      name - Property name.
      dflt - The default value.
      Returns:
      The String property value or the dflt argument if not found.
    • getProperty

      public Object getProperty(String name)
      Return the property, if not found return the null.
      Parameters:
      name - Property name.
      Returns:
      The property value
    • getProperties

      public Hashtable getProperties()
      Getter method for the properties hashtable. We have this here for the XmlEncoder.
      Returns:
      The properties table.
    • setProperties

      public void setProperties(Hashtable newProperties)
      Setter method for the properties hashtable. We have this here for the XmlEncoder.
      Parameters:
      newProperties - The new Properties table.
    • addDataChangeListener

      public abstract void addDataChangeListener(DataChangeListener listener)
      Add the DataChangeListener. This is the object that is notify when the data that this DataChoice represents has changed. This is an abstract method, the derived classes override it. e.g., the DerivedDataChoice tells simply passes the listener on to its set of children DataChoices.
      Parameters:
      listener - The DataChangeListener to add.
    • removeDataChangeListener

      public abstract void removeDataChangeListener(DataChangeListener listener)
      Remove the DataChangeListener.
      Parameters:
      listener - The DataChangeListener to remove.
    • isEndUserFormula

      public boolean isEndUserFormula()
      Top-level method to determine if this object is an end-user formula. Default is false.
      Returns:
      Is this object an end user formula (i.e., really means is this object a DerivedDataChoice created through the formulas framework.
    • setFixedRequestProperties

      public void setFixedRequestProperties(Hashtable value)
      Set the FixedRequestProperties property.
      Parameters:
      value - The new value for FixedRequestProperties
    • getFixedRequestProperties

      public Hashtable getFixedRequestProperties()
      Get the FixedRequestProperties property.
      Returns:
      The FixedRequestProperties