Package ucar.unidata.data
Class DataCategory
java.lang.Object
ucar.unidata.data.DataCategory
This represents a hierarchical category of string names
and is used to categorize different flavors of data within
DataChoice objects and for determining what displays are applicable
to what data. A DataCategory object really represents a
node in a list of DataCategory objects that define the hierarchy.
For example, the string FOO-BAR-ZOO
is represented by three DataCategory objects:
+-----+ +-----+ +-----+ | FOO |--> | BAR | --> | ZOO | +-----+ +-----+ +-----+There are static utility methods for parsing a string category name into a chain of objects. Likewise there are methods for parsing a String of semi-colon delimited category strings into a Collection of DataCategory chains.
Category names can also hold regular expressions,e.g., "*", "+" and "." that gives us alot of flexibility in creating categories that match a variety of flavors of data.
- Version:
- $Revision: 1.74 $
- Author:
- IDV development team
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe description attribute (for XML)static final StringThe name attribute (for XML)static final StringThe 2D categorystatic final StringThe 3D categorystatic final StringThe category that matches any other categorystatic final StringThe track skew-T category @deprecated use TRACK_SOUNDINGstatic final StringThe display categorystatic final StringThe grid ensemble categorystatic final StringThe grid categorystatic final StringThe grid skew-T category @deprecated use GRID_SOUNDINGstatic final StringThe grid skew-T categorystatic final StringThe html categorystatic final StringThe image categorystatic final StringThe point categorystatic final StringThe stationplot categorystatic final StringThe profiler 3D categorystatic final StringThe multi station profiler categorystatic final StringThe one station profiler categorystatic final StringThe profiler plan view categorystatic final StringThe RAOB categorystatic final StringThe RAOB skew-T category @deprecated use RAOB_SOUNDINGstatic final StringThe RAOB skew-T categorystatic final StringThe Skew-T categorystatic final StringThe Sounding categorystatic final StringThe text categorystatic final StringThe track categorystatic final StringThe track skew-T category @deprecated use TRACK_SOUNDINGstatic final StringThe track skew-T categorystatic final StringThe track skew-T categorystatic final StringThe VisAD categoryprotected DataCategorychild of thie DataCategorystatic final DataCategory_more_static final StringIdentifier for a category dividerstatic final DataCategorygrid ensemble categoriesstatic final DataCategoryGrid-derived data appropriate for a Skew-T display (DateTime-> (EarthLocationTuple-> (AirTemperature,DewPoint))).static final DataCategoryGrid-derived data appropriate for an aerological sounding display (DateTime-> (EarthLocationTuple-> (AirTemperature,DewPoint))).static final DataCategoryCategory for locationsprotected Stringname of this DataCategorystatic final DataCategoryCategory to use for none.static final DataCategoryNULL categorystatic final DataCategoryPoint Plot Categorystatic final DataCategoryProfiler data appropriate for a one station time-hgt displaystatic final DataCategoryProfiler data appropriate for multi-staiton plan view of winds at hgt;static final DataCategoryRAOB-derived data appropriate for a Skew-T display (DateTime,EarthLocationTuple,InSituAirTemperatureProfile,DewPointProfile).static final DataCategoryRAOB-derived data appropriate for a sounding display (DateTime,EarthLocationTuple,InSituAirTemperatureProfile,DewPointProfile).static final StringAn id for a set of categoriesstatic final StringAn id for a single categorystatic final DataCategoryTrack-derived data appropriate for a Skew-T display (DateTime-> (Pressure,Temperature,DewPoint,PolarHorizontalWind,EarthLocationTuple)).static final DataCategoryTrack-derived data appropriate for an aerological sounding display (DateTime-> (Pressure,Temperature,DewPoint,PolarHorizontalWind,EarthLocationTuple)).static final DataCategoryCategory for the trajectory feature type data filesstatic final DataCategoryCategory for the drawing files -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.DataCategory(boolean forDisplay) ctorDataCategory(String name) Create a parent-less category with the given name.DataCategory(String name, boolean forDisplay) Create a parent-less category with the given forDisplay stateDataCategory(String name, List metaCategories) Create a parent-less category with the given metacategories.DataCategory(String name, DataCategory metaCategory) Create a parent-less category with the given metacategory.DataCategory(DataCategory parent, String name) Create a category with given parent category and name. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidAdd the category into the global listbooleanapplicableTo(List dcs) Go through the list of DataCategory objects.static booleanapplicableTo(List from, List to) Return whether any of the DataCategory's in from are applicable to the list into.booleanCheck to see if this object is applicable to the given DataCategory argument.copyAndAppend(String append) Append the string to the data category and return a new category.static DataCategorycreateCategory(String n1) Helper method to instantiate a single categorystatic DataCategorycreateCategory(String[] names) Create a DataCategory from the array of names.static DataCategorycreateCategory(String n1, String n2) Helper method to instantiate two categoriesstatic DataCategorycreateCategory(String n1, String n2, String n3) Helper method to instantiate a three categoriesstatic DataCategorycreateCategory(String n1, String n2, String n3, String n4) Helper method to instantiate a four categoriesbooleanSee if this DataCategory is equivalent to anotherGet the appended category string (used by XML persistence)intGet the category index (used by XML persistence)getChild()Return the child category of this object.intGet the child index (used by XML persistence)static ListGet all current category stringsbooleanGet the "for display" property.Return the full path of this category with its child Use the default DIVIDER as the string divider between sub categories.getFullName(String divider) Return the full path of this category with its child Use the given argument as the string divider between sub categories.getFullName(String prefix, String suffix) Return the full path of this category with its child Use the given arguments as the string divider between sub categories.Get the list of meta categories for this DataCategorygetName()Return the name of this categoryprotected StringReturn the regular expression that this DataCategory represents It is somewhat tricky because the parent category might have been none (i.e., "*" or if this is the topmost category)Get the Replace property.booleanCheck if this DataCategory has a meta category.inthashCode()Return the hashcode for this DataCategorystatic voidinit(XmlResourceCollection resources) Used by XML persistence initialization.booleanSee if this is an inherited categorystatic voidMethod for testing this class.static booleanmatchRegexp(String source, String pattern) See if a String is a match for a patternstatic ListParse out a string of semi-colon delimited categories e.g.: "catname1-catname2-catnameN;othercategory1-othercategory2;..."static ListparseCategories(String c, boolean firstOneForDisplay) Parse out a string of semi-colon delimited categories e.g.: "catname1-catname2-catnameN;othercategory1-othercategory2;..."static DataCategoryparseCategory(String c, boolean forDisplay) Parse out a string of the form "catname1-catname2-catnameN" and return a chain of category objects representing catname1->catname2->catnameN.voidSet the appended category string (used by XML persistence)voidsetCategoryIndex(int value) Set the category index (used by XML persistence)voidsetChild(DataCategory child) Sets the child member of this category.voidsetChildIndex(int value) Set the child index (used by XML persistence)voidsetForDisplay(boolean value) Set the "for display" property.voidSet the name property.voidsetReplace(String value) Set the Replace property.toString()Return a String representation of this DataCategoryReturn a String representation of this DataCategory using the given divider
-
Field Details
-
NULL
NULL category -
DIVIDER
Identifier for a category divider- See Also:
-
name
name of this DataCategory -
child
child of thie DataCategory -
CATEGORY_ANY
The category that matches any other category- See Also:
-
CATEGORY_TEXT
The text category- See Also:
-
CATEGORY_HTML
The html category- See Also:
-
CATEGORY_DISPLAY
The display category- See Also:
-
CATEGORY_GRID
The grid category- See Also:
-
CATEGORY_POINT
The point category- See Also:
-
CATEGORY_VISAD
The VisAD category- See Also:
-
CATEGORY_IMAGE
The image category- See Also:
-
CATEGORY_3D
The 3D category- See Also:
-
CATEGORY_2D
The 2D category- See Also:
-
CATEGORY_RAOB
The RAOB category- See Also:
-
CATEGORY_SKEWT
The Skew-T category- See Also:
-
CATEGORY_SOUNDING
The Sounding category- See Also:
-
CATEGORY_POINTPLOT
The stationplot category- See Also:
-
CATEGORY_TRACK
The track category- See Also:
-
CATEGORY_GRIDSKEWT
The grid skew-T category @deprecated use GRID_SOUNDING- See Also:
-
CATEGORY_RAOBSKEWT
The RAOB skew-T category @deprecated use RAOB_SOUNDING- See Also:
-
CATEGORY_TRACKSKEWT
The track skew-T category @deprecated use TRACK_SOUNDING- See Also:
-
CATEGORY_COSMICSKEWT
The track skew-T category @deprecated use TRACK_SOUNDING- See Also:
-
CATEGORY_GRIDSOUNDING
The grid skew-T category- See Also:
-
CATEGORY_ENSEMBLE
The grid ensemble category- See Also:
-
CATEGORY_RAOBSOUNDING
The RAOB skew-T category- See Also:
-
CATEGORY_TRACKSOUNDING
The track skew-T category- See Also:
-
CATEGORY_TRAJECTORYSOUNDING
The track skew-T category- See Also:
-
CATEGORY_PROFILER_ONESTA
The one station profiler category- See Also:
-
CATEGORY_PROFILER_MULTISTA
The multi station profiler category- See Also:
-
CATEGORY_PROFILER_PLAN
The profiler plan view category- See Also:
-
CATEGORY_PROFILER_3D
The profiler 3D category- See Also:
-
NONE_CATEGORY
Category to use for none. Use this, for example, in a CompositeDataChoice that really has no data and is just used as a container. -
RAOB_SKEWT_CATEGORY
RAOB-derived data appropriate for a Skew-T display (DateTime,EarthLocationTuple,InSituAirTemperatureProfile,DewPointProfile). -
RAOB_SOUNDING_CATEGORY
RAOB-derived data appropriate for a sounding display (DateTime,EarthLocationTuple,InSituAirTemperatureProfile,DewPointProfile). -
PROFILER_ONESTA_CATEGORY
Profiler data appropriate for a one station time-hgt display -
PROFILER_PLAN_CATEGORY
Profiler data appropriate for multi-staiton plan view of winds at hgt; -
GRID_3D_SKEWT_CATEGORY
Grid-derived data appropriate for a Skew-T display (DateTime-> (EarthLocationTuple-> (AirTemperature,DewPoint))). deprecated use #GRID_3D_SOUNDING_CATEGORY -
TRACK_SKEWT_CATEGORY
Track-derived data appropriate for a Skew-T display (DateTime-> (Pressure,Temperature,DewPoint,PolarHorizontalWind,EarthLocationTuple)). deprecated use #TRACK_SOUNDING_CATEGORY -
COSMIC_SKEWT_CATEGORY
_more_ -
ENSEMBLE_CATEGORY
grid ensemble categories -
GRID_3D_SOUNDING_CATEGORY
Grid-derived data appropriate for an aerological sounding display (DateTime-> (EarthLocationTuple-> (AirTemperature,DewPoint))). -
TRACK_SOUNDING_CATEGORY
Track-derived data appropriate for an aerological sounding display (DateTime-> (Pressure,Temperature,DewPoint,PolarHorizontalWind,EarthLocationTuple)). -
TRAJECTORY_SOUNDING_CATEGORY
Category for the trajectory feature type data files -
XGRF_CATEGORY
Category for the drawing files -
LOCATIONS_CATEGORY
Category for locations -
POINT_PLOT_CATEGORY
Point Plot Category -
TAG_CATEGORIES
An id for a set of categories- See Also:
-
TAG_CATEGORY
An id for a single category- See Also:
-
ATTR_NAME
The name attribute (for XML)- See Also:
-
ATTR_DESC
The description attribute (for XML)- See Also:
-
-
Constructor Details
-
DataCategory
public DataCategory()Default constructor. -
DataCategory
public DataCategory(boolean forDisplay) ctor- Parameters:
forDisplay- Is this category a display category
-
DataCategory
Create a parent-less category with the given name.- Parameters:
name- name of this DataCategory.
-
DataCategory
Create a parent-less category with the given forDisplay state- Parameters:
name- name of this DataCategoryforDisplay- true if this should be displayed
-
DataCategory
Create a parent-less category with the given metacategories.- Parameters:
name- name of this DataCategorymetaCategories- list of meta categories
-
DataCategory
Create a parent-less category with the given metacategory.- Parameters:
name- name of this DataCategorymetaCategory- meta category
-
DataCategory
Create a category with given parent category and name. Add the new category to the parent.- Parameters:
parent- parent categoryname- name of this sub category
-
-
Method Details
-
hasCategory
public boolean hasCategory()Check if this DataCategory has a meta category.- Returns:
- true if it has a metacategory
-
getMetaCategories
Get the list of meta categories for this DataCategory- Returns:
- list of meta categories
-
init
Used by XML persistence initialization.- Parameters:
resources- collection of XML resources
-
addCurrentCategory
Add the category into the global list- Parameters:
c- category
-
getCurrentCategories
Get all current category strings- Returns:
- List of category strings
-
parseCategory
Parse out a string of the form "catname1-catname2-catnameN" and return a chain of category objects representing catname1->catname2->catnameN. The category objects will have their forDisplay flag set to the given value.- Parameters:
c- string of categoriesforDisplay- true if the first is for display only- Returns:
- new DataCategory
-
parseCategories
Parse out a string of semi-colon delimited categories e.g.: "catname1-catname2-catnameN;othercategory1-othercategory2;..."- Parameters:
c- semi-colon delimeted String of categories- Returns:
- list of categories
-
parseCategories
Parse out a string of semi-colon delimited categories e.g.: "catname1-catname2-catnameN;othercategory1-othercategory2;..."- Parameters:
c- semi-colon delimeted String of categoriesfirstOneForDisplay- true if the first one is for display only- Returns:
- list of categories
-
createCategory
Create a DataCategory from the array of names. This is a hierarchical list.- Parameters:
names- array of category names- Returns:
- associated DataCategory
-
createCategory
Helper method to instantiate a single category- Parameters:
n1- name of the category- Returns:
- DataCategory with name n1
-
createCategory
Helper method to instantiate two categories- Parameters:
n1- name of the categoryn2- name of the child of n1- Returns:
- DataCategory with one child
-
createCategory
Helper method to instantiate a three categories- Parameters:
n1- name of the categoryn2- name of the child of n1n3- name of the child of n2- Returns:
- DataCategory with a child with a child
-
createCategory
Helper method to instantiate a four categories- Parameters:
n1- name of the categoryn2- name of the child of n1n3- name of the child of n2n4- name of the child of n3- Returns:
- DataCategory with a child with a child with a child
-
getChild
Return the child category of this object. Note: this can be null.- Returns:
- child or
nullif none.
-
setChild
Sets the child member of this category. DataCategories are a single linear chain of objects, thus we only have one child (and one parent)- Parameters:
child- child category for this
-
getName
Return the name of this category- Returns:
- category name
-
setName
Set the name property. Used by XML persistence- Parameters:
n- name
-
isInherited
public boolean isInherited()See if this is an inherited category- Returns:
- true if inherited
-
getFullName
Return the full path of this category with its child Use the default DIVIDER as the string divider between sub categories.- Returns:
- the full name of this category (e.g. -foo-)
-
getFullName
Return the full path of this category with its child Use the given argument as the string divider between sub categories.- Parameters:
divider- divider character- Returns:
- full name using divider
-
getFullName
Return the full path of this category with its child Use the given arguments as the string divider between sub categories.- Parameters:
prefix- prefix dividersuffix- suffix divider- Returns:
- full name with dividers
-
getPattern
Return the regular expression that this DataCategory represents It is somewhat tricky because the parent category might have been none (i.e., "*" or if this is the topmost category)- Returns:
- regular expression pattern for this category
-
toString
Return a String representation of this DataCategory -
toString
Return a String representation of this DataCategory using the given divider- Parameters:
divider- The divider to use between sub-categories.- Returns:
- string representation of this
-
applicableTo
Go through the list of DataCategory objects. If this object is applicable to any of them return true. If the list is empty then return true.- Parameters:
dcs- list of DataCategories- Returns:
- true if this DataCategory is applicable to any of them
-
applicableTo
Check to see if this object is applicable to the given DataCategory argument. The definition of applicability is that this data category is hierarchically a "base-class" hierachy of the given argument. There is a slight twist though: A data category can have a sub-component that represents a regular expression, i.e., :"*" represents 0 or more sub-categories, "+" represents one or more sub-categories "." represents one sub-category
Here are some examples:This Argument applicableTo "FOO-BAR" "FOO-BAR" true "FOO-BAR-ZOO" "FOO-BAR" false "FOO-BAR-ZOO" "FOO-BAR" false "FOO-BAR-*" "FOO-BAR" true "FOO-BAR-+" "FOO-BAR" false "FOO-." "FOO-BAR" true "FOO-.-*" "FOO-BAR" true "*" "FOO-BAR" true ".-.-*" "FOO-BAR" true - Parameters:
d- DataCategory to check- Returns:
- true if applicable to
d
-
setForDisplay
public void setForDisplay(boolean value) Set the "for display" property. (used by XML persistence)- Parameters:
value- for display property
-
getForDisplay
public boolean getForDisplay()Get the "for display" property. (used by XML persistence)- Returns:
- the for display property
-
applicableTo
Return whether any of the DataCategory's in from are applicable to the list into.- Parameters:
from- List of DataCategories to checkto- List of categories thatfrommay be applicable to.- Returns:
- true if any of the
fromlist is applicable to thetolist. - See Also:
-
equals
See if this DataCategory is equivalent to another -
hashCode
public int hashCode()Return the hashcode for this DataCategory -
main
Method for testing this class.- Parameters:
args- category string
-
matchRegexp
See if a String is a match for a pattern- Parameters:
source- source stringpattern- regular expression pattern- Returns:
- true if there is a match deprecated use ucar.unidata.util.StringUtil.stringMatch(String, String) instead
-
setCategoryIndex
public void setCategoryIndex(int value) Set the category index (used by XML persistence)- Parameters:
value- the index
-
getCategoryIndex
public int getCategoryIndex()Get the category index (used by XML persistence)- Returns:
- the category index
-
setChildIndex
public void setChildIndex(int value) Set the child index (used by XML persistence)- Parameters:
value- the child index
-
getChildIndex
public int getChildIndex()Get the child index (used by XML persistence)- Returns:
- child index
-
setAppend
Set the appended category string (used by XML persistence)- Parameters:
value- append value
-
getAppend
Get the appended category string (used by XML persistence)- Returns:
- appended category string
-
setReplace
Set the Replace property.- Parameters:
value- The new value for Replace
-
getReplace
Get the Replace property.- Returns:
- The Replace
-
copyAndAppend
Append the string to the data category and return a new category.- Parameters:
append- category string to append (may be null)- Returns:
- The new data category
-