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 String
The description attribute (for XML)static final String
The name attribute (for XML)static final String
The 2D categorystatic final String
The 3D categorystatic final String
The category that matches any other categorystatic final String
The track skew-T category @deprecated use TRACK_SOUNDINGstatic final String
The display categorystatic final String
The grid ensemble categorystatic final String
The grid categorystatic final String
The grid skew-T category @deprecated use GRID_SOUNDINGstatic final String
The grid skew-T categorystatic final String
The html categorystatic final String
The image categorystatic final String
The point categorystatic final String
The stationplot categorystatic final String
The profiler 3D categorystatic final String
The multi station profiler categorystatic final String
The one station profiler categorystatic final String
The profiler plan view categorystatic final String
The RAOB categorystatic final String
The RAOB skew-T category @deprecated use RAOB_SOUNDINGstatic final String
The RAOB skew-T categorystatic final String
The Skew-T categorystatic final String
The Sounding categorystatic final String
The text categorystatic final String
The track categorystatic final String
The track skew-T category @deprecated use TRACK_SOUNDINGstatic final String
The track skew-T categorystatic final String
The track skew-T categorystatic final String
The VisAD categoryprotected DataCategory
child of thie DataCategorystatic final DataCategory
_more_static final String
Identifier for a category dividerstatic final DataCategory
grid ensemble categoriesstatic final DataCategory
Grid-derived data appropriate for a Skew-T display (DateTime
-> (EarthLocationTuple
-> (AirTemperature
,DewPoint
))).static final DataCategory
Grid-derived data appropriate for an aerological sounding display (DateTime
-> (EarthLocationTuple
-> (AirTemperature
,DewPoint
))).static final DataCategory
Category for locationsprotected String
name of this DataCategorystatic final DataCategory
Category to use for none.static final DataCategory
NULL categorystatic final DataCategory
Point Plot Categorystatic final DataCategory
Profiler data appropriate for a one station time-hgt displaystatic final DataCategory
Profiler data appropriate for multi-staiton plan view of winds at hgt;static final DataCategory
RAOB-derived data appropriate for a Skew-T display (DateTime
,EarthLocationTuple
,InSituAirTemperatureProfile
,DewPointProfile
).static final DataCategory
RAOB-derived data appropriate for a sounding display (DateTime
,EarthLocationTuple
,InSituAirTemperatureProfile
,DewPointProfile
).static final String
An id for a set of categoriesstatic final String
An id for a single categorystatic final DataCategory
Track-derived data appropriate for a Skew-T display (DateTime
-> (Pressure
,Temperature
,DewPoint
,PolarHorizontalWind
,EarthLocationTuple
)).static final DataCategory
Track-derived data appropriate for an aerological sounding display (DateTime
-> (Pressure
,Temperature
,DewPoint
,PolarHorizontalWind
,EarthLocationTuple
)).static final DataCategory
Category for the trajectory feature type data filesstatic final DataCategory
Category 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 void
Add the category into the global listboolean
applicableTo
(List dcs) Go through the list of DataCategory objects.static boolean
applicableTo
(List from, List to) Return whether any of the DataCategory's in from are applicable to the list into
.boolean
Check 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 DataCategory
createCategory
(String n1) Helper method to instantiate a single categorystatic DataCategory
createCategory
(String[] names) Create a DataCategory from the array of names.static DataCategory
createCategory
(String n1, String n2) Helper method to instantiate two categoriesstatic DataCategory
createCategory
(String n1, String n2, String n3) Helper method to instantiate a three categoriesstatic DataCategory
createCategory
(String n1, String n2, String n3, String n4) Helper method to instantiate a four categoriesboolean
See if this DataCategory is equivalent to anotherGet the appended category string (used by XML persistence)int
Get the category index (used by XML persistence)getChild()
Return the child category of this object.int
Get the child index (used by XML persistence)static List
Get all current category stringsboolean
Get 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 String
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)Get the Replace property.boolean
Check if this DataCategory has a meta category.int
hashCode()
Return the hashcode for this DataCategorystatic void
init
(XmlResourceCollection resources) Used by XML persistence initialization.boolean
See if this is an inherited categorystatic void
Method for testing this class.static boolean
matchRegexp
(String source, String pattern) See if a String is a match for a patternstatic List
Parse out a string of semi-colon delimited categories e.g.: "catname1-catname2-catnameN;othercategory1-othercategory2;..."static List
parseCategories
(String c, boolean firstOneForDisplay) Parse out a string of semi-colon delimited categories e.g.: "catname1-catname2-catnameN;othercategory1-othercategory2;..."static DataCategory
parseCategory
(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.void
Set the appended category string (used by XML persistence)void
setCategoryIndex
(int value) Set the category index (used by XML persistence)void
setChild
(DataCategory child) Sets the child member of this category.void
setChildIndex
(int value) Set the child index (used by XML persistence)void
setForDisplay
(boolean value) Set the "for display" property.void
Set the name property.void
setReplace
(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
null
if 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 thatfrom
may be applicable to.- Returns:
- true if any of the
from
list is applicable to theto
list. - 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
-