Package ucar.unidata.data
Class DataManager
java.lang.Object
ucar.unidata.data.DataManager
A class for managing
DataSource
s- Version:
- $Revision: 1.122 $Date: 2007/08/08 16:24:11 $
- Author:
- Metapps development team
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ArrayList
A list ofTwoFacedObject
s (label, datasource_id) for all datasource descriptorsprotected ArrayList
The list ofPatternFileFilter
s that we create from the datasources.xml.static final String
The XML attribute for allowing multiple data choicesstatic final String
The XML factory attributestatic final String
The XML file selection attributestatic final String
The XML "id" attributestatic final String
The XML label attributestatic final String
The XML name attributestatic final String
xml attribute identifier for the datasource.xml filestatic final String
The XML patterns attributestatic final String
xml attribute identifier for the datasource.xml filestatic final String
The XML value attributeprotected Hashtable
Maps data source namesstatic final String
The known data type idstatic final String
The "unknown" data typeprotected ArrayList
The list ofDataSourceDescriptor
s defined by the datasource.xml resource files.protected ArrayList
A list ofTwoFacedObject
s (label, datasource_id) for those datasource descriptors that are for file selection.protected ArrayList
The list ofPatternFileFilter
s that we create from the datasources.xml for those that are specified to be for file selection (i.e., the xml tag has fileselection="true").protected Hashtable
A mapping from datasource_id (String) toDataSourceDescriptor
object.static final String
Preference for where to save the grib indexstatic final String
The cache percent propertystatic final String
The default display propertystatic final String
bbox propertystatic final String
preference idstatic final String
The show in tree propertyprotected Hashtable
This hashtable allows us to keep track of the filter strings that we have already seen so we don't create duplicates.static final String
The XML tag for a datasourcestatic final String
The XML tag for datasourcesstatic final String
The XML tag for a property -
Constructor Summary
ConstructorsConstructorDescriptionDataManager
(DataContext dataContext) Create a new DataManager with the givenDataContext
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
addDataSource
(DataSource dataSource) Add the givenDataSource
into the list of datasources if it is not in the list and if it is not in error.createDataSource
(Object definingObject) Create aDataSource
(if we know how) defined with the given definingObject.createDataSource
(Object definingObject, String dataType, Hashtable properties) Create aDataSource
(if we know how) defined with the given dataType (if non-null) or by the given definingObject and set of properties (which may be null).createDataSource
(Object definingObject, Hashtable properties) Create aDataSource
(if we know how) defined with the given definingObject and set of properties (which may be null).void
createDataSourceAndAskForType
(Object definingObject, Hashtable properties) Ask the user for the data soruce type and create the given data sourcefindDataSource
(String name) Find the data source with the given nameThis is used by theIdvChooserManager
Get the actual current descriptor with the id of the given or return the given one if one is not found.Get the data cache dirGet this DataManager'sDataContext
.get an html listing of all of the data source descriptionsThe DataManager holds a set of activeDataSource
objects.static String
getDatasourceXml
(String type, String label, Class datasourceClass, Hashtable properties) Create a snippet of the datasource xml for the given data sourcestatic String
getDatasourceXml
(String type, String label, Class datasourceClass, Hashtable properties, String[] attributes) Create a snippet of the datasource xml for the given data sourcegetDescriptor
(String dataType) Find theDataSourceDescriptor
with the given dataType id.get the data source descriptorsThis is used by theIdvChooserManager
to allow the user to create new file data chooser items.The DataManager creates a list ofPatternFileFilter
s from the datasource xml.getNewVariableName
(String varName) Get the new name for a variable namegetProperty
(String dataType, String property) Find the given property on theDataSourceDescriptor
defined by the given dataType.boolean
getProperty
(String dataType, String property, boolean dflt) Find the given property on theDataSourceDescriptor
defined by the given dataType.get the data source descriptors for those data sources that can be stand-aloneboolean
haveDataSource
(DataSource dataSource) Is the givenDataSource
currently in the list of active datasources.void
initEncoder
(XmlEncoder encoder, boolean forRead) Seed the given encoder with theDataSourceDescriptor
s and the DataManager object.void
initResources
(IdvResourceManager resourceManager) Initialize the resourcesvoid
Add in the AddeURLStreamHandlerstatic boolean
Check if an object is a data source that holds formulas.void
loadDataSourceXml
(XmlResourceCollection resources) Process the list of xml documents that define the differentDataSource
s used within the idv.protected void
loadGribResources
(IdvResourceManager resourceManager) Load the grib lookup tablesprotected void
loadIospResources
(IdvResourceManager resourceManager) Load the grib lookup tablesstatic void
test mainvoid
Reload all the data sourcesvoid
As the method name implies, remove all datasources managed by this DataManager.void
removeDataSource
(DataSource dataSource) Remove the givenDataSource
from the list of datasources.static void
setDODSCompression
(boolean compress) Set whether compression is used on DODS file transfersboolean
validDatasourceId
(Object definingObject) Is there a mapping defined from the given definingObject (which should be a String) to aDataSourceDescriptor
.boolean
validDatasourceId
(Object definingObject, Hashtable properties) Is there a mapping defined from the given definingObject (which should be a String) to aDataSourceDescriptor
or is there a DATATYPE_ID entry in the given properties Hashtable.
-
Field Details
-
DATATYPE_UNKNOWN
The "unknown" data type- See Also:
-
DATATYPE_ID
The known data type id- See Also:
-
PROP_SHOW_IN_TREE
The show in tree property- See Also:
-
PROP_CACHE_PERCENT
The cache percent property- See Also:
-
PROP_GEOSUBSET_BBOX
bbox property- See Also:
-
PROP_NETCDF_CONVENTIONHANDLERS
preference id- See Also:
-
PROP_DEFAULT_DISPLAY
The default display property- See Also:
-
TAG_DATASOURCES
The XML tag for datasources- See Also:
-
TAG_DATASOURCE
The XML tag for a datasource- See Also:
-
TAG_PROPERTY
The XML tag for a property- See Also:
-
ATTR_DOESMULTIPLES
The XML attribute for allowing multiple data choices- See Also:
-
ATTR_STANDALONE
xml attribute identifier for the datasource.xml file- See Also:
-
ATTR_NCMLTEMPLATE
xml attribute identifier for the datasource.xml file- See Also:
-
ATTR_ID
The XML "id" attribute- See Also:
-
ATTR_FACTORY
The XML factory attribute- See Also:
-
ATTR_LABEL
The XML label attribute- See Also:
-
ATTR_NAME
The XML name attribute- See Also:
-
ATTR_PATTERNS
The XML patterns attribute- See Also:
-
ATTR_FILESELECTION
The XML file selection attribute- See Also:
-
ATTR_VALUE
The XML value attribute- See Also:
-
PREF_GRIBINDEXINCACHE
Preference for where to save the grib index- See Also:
-
descriptors
The list ofDataSourceDescriptor
s defined by the datasource.xml resource files. -
idToDescriptor
A mapping from datasource_id (String) toDataSourceDescriptor
object. This is used when we load multiple datasource descriptor files so we can know whether we have already loaded a descriptor and to do a lookup of a descriptor based on its id. -
allFilters
The list ofPatternFileFilter
s that we create from the datasources.xml. We use this list when we are given a file name or a URL and are looking for the DataSourceDescriptor that handles that type of file. -
fileFilters
The list ofPatternFileFilter
s that we create from the datasources.xml for those that are specified to be for file selection (i.e., the xml tag has fileselection="true"). -
seenFilters
This hashtable allows us to keep track of the filter strings that we have already seen so we don't create duplicates. -
fileDataSourceIds
A list ofTwoFacedObject
s (label, datasource_id) for those datasource descriptors that are for file selection. -
allDataSourceIds
A list ofTwoFacedObject
s (label, datasource_id) for all datasource descriptors -
dataSourceNameMap
Maps data source names
-
-
Constructor Details
-
DataManager
Create a new DataManager with the givenDataContext
.- Parameters:
dataContext
- TheDataContext
that this DataManager exists within (this is usually an instance ofIntegratedDataViewer
).
-
-
Method Details
-
getDataCacheDirectory
Get the data cache dir- Returns:
- data cache dir
-
initResources
Initialize the resources- Parameters:
resourceManager
- resource manager
-
setDODSCompression
public static void setDODSCompression(boolean compress) Set whether compression is used on DODS file transfers- Parameters:
compress
- true to compress
-
loadGribResources
Load the grib lookup tables- Parameters:
resourceManager
- The resource manager deprecated use loadIOSPResources(IdvResourceManager) instead
-
loadIospResources
Load the grib lookup tables- Parameters:
resourceManager
- The resource manager
-
getDataContext
Get this DataManager'sDataContext
.- Returns:
- The
DataContext
of this DataManager.
-
loadDataSourceXml
Process the list of xml documents that define the differentDataSource
s used within the idv.- Parameters:
resources
- TheXmlResourceCollection
that holds the set of datasource xml documents. This may be null.
-
getDataSourceHtml
get an html listing of all of the data source descriptions- Returns:
- html listing of data sources
-
getDatasourceXml
public static String getDatasourceXml(String type, String label, Class datasourceClass, Hashtable properties) throws Exception Create a snippet of the datasource xml for the given data source- Parameters:
type
- The data source typelabel
- the labeldatasourceClass
- the classproperties
- properties- Returns:
- The xml
- Throws:
Exception
- On badness
-
getDatasourceXml
public static String getDatasourceXml(String type, String label, Class datasourceClass, Hashtable properties, String[] attributes) throws Exception Create a snippet of the datasource xml for the given data source- Parameters:
type
- The data source typelabel
- the labeldatasourceClass
- the classproperties
- propertiesattributes
- If non-null then add these are xml attributes- Returns:
- The xml
- Throws:
Exception
- On badness
-
getDescriptors
get the data source descriptors- Returns:
- the descriptors
-
getStandaloneDescriptors
get the data source descriptors for those data sources that can be stand-alone- Returns:
- stand alone descriptors
-
getFileDataSourceList
This is used by theIdvChooserManager
to allow the user to create new file data chooser items.- Returns:
- The list of
DataSourceDescriptor
s that are meant to be used for files.
-
getAllDataSourceIds
This is used by theIdvChooserManager
- Returns:
- The list of
DataSourceDescriptor
s
-
getDataSources
The DataManager holds a set of activeDataSource
objects.- Returns:
- The list of active
DataSource
s.
-
haveDataSource
Is the givenDataSource
currently in the list of active datasources.- Parameters:
dataSource
- TheDataSource
to check.- Returns:
- Is dataSource in the datasources list.
-
addDataSource
Add the givenDataSource
into the list of datasources if it is not in the list and if it is not in error.- Parameters:
dataSource
- TheDataSource
to add into the list.- Returns:
- True if we added this data source, false if we already have this data source
-
reloadAllDataSources
public void reloadAllDataSources()Reload all the data sources -
removeAllDataSources
public void removeAllDataSources()As the method name implies, remove all datasources managed by this DataManager. -
removeDataSource
Remove the givenDataSource
from the list of datasources.- Parameters:
dataSource
- TheDataSource
to remove.
-
getFileFilters
The DataManager creates a list ofPatternFileFilter
s from the datasource xml.- Returns:
- The list of
PatternFileFilter
s.
-
getCurrent
Get the actual current descriptor with the id of the given or return the given one if one is not found. We use this for data sources that are unpersisted so they can get an updated descriptor- Parameters:
dds
- Given- Returns:
- Current
-
validDatasourceId
Is there a mapping defined from the given definingObject (which should be a String) to aDataSourceDescriptor
.- Parameters:
definingObject
- This is the object passed in when we try to create aDataSource
.- Returns:
- Do we know how to handle the given definingObject.
-
validDatasourceId
Is there a mapping defined from the given definingObject (which should be a String) to aDataSourceDescriptor
or is there a DATATYPE_ID entry in the given properties Hashtable.- Parameters:
definingObject
- This is the object passed in when we try to create aDataSource
.properties
- May hold a DATATYPE_ID entry.- Returns:
- Do we know how to handle the given definingObject.
-
findDataSource
Find the data source with the given name- Parameters:
name
- The name. This is passed to DataSource.identifiedBy() method. It can be 'class:some_class' or a regexp pattern that matches on the data source name- Returns:
- the data source or null if none found
-
createDataSource
Create aDataSource
(if we know how) defined with the given definingObject.- Parameters:
definingObject
- This is the data used to create a DataSource. It may be a String (e.g., a URL, a filename) or something else (e.g., a list of URLs).- Returns:
- The list of
DataSource
s defined by the given definingObject or null.
-
createDataSource
Create aDataSource
(if we know how) defined with the given definingObject and set of properties (which may be null).- Parameters:
definingObject
- This is the data used to create a DataSource. It may be a String (e.g., a URL, a filename) or something else (e.g., a list of URLs).properties
- The properties for the new DataSource.- Returns:
- The list of
DataSource
defined by the given definingObject or null.
-
createDataSourceAndAskForType
Ask the user for the data soruce type and create the given data source- Parameters:
definingObject
- This is the data used to create a DataSource. It may be a String (e.g., a URL, a filename) or something else (e.g., a list of URLs).properties
- The properties for the new DataSource.
-
createDataSource
public DataSourceResults createDataSource(Object definingObject, String dataType, Hashtable properties) Create aDataSource
(if we know how) defined with the given dataType (if non-null) or by the given definingObject and set of properties (which may be null).- Parameters:
definingObject
- This is the data used to create a DataSource. It may be a String (e.g., a URL, a filename) or something else (e.g., a list of URLs).dataType
- The id of theDataSourceDescriptor
(or null).properties
- The properties for the new DataSource.- Returns:
- The list of
DataSource
defined by the given definingObject or null.
-
initEncoder
Seed the given encoder with theDataSourceDescriptor
s and the DataManager object.- Parameters:
encoder
- The encoder to seed.forRead
- Is this encoding for a read or a write.
-
getDescriptor
Find theDataSourceDescriptor
with the given dataType id.- Parameters:
dataType
- The dataType id to lookup.- Returns:
- The DataSourceDescriptor defined by the given dataType (or null).
-
getProperty
Find the given property on theDataSourceDescriptor
defined by the given dataType.- Parameters:
dataType
- The data source descriptor id.property
- The property name.- Returns:
- The property or null.
-
getProperty
Find the given property on theDataSourceDescriptor
defined by the given dataType. If not found then return the given dflt.- Parameters:
dataType
- The data source descriptor id.property
- The property name.dflt
- The default value.- Returns:
- The property or the dflt parameter.
-
getNewVariableName
Get the new name for a variable name- Parameters:
varName
- _more_- Returns:
- new name
-
initURLStreamHandlers
public void initURLStreamHandlers()Add in the AddeURLStreamHandler -
isFormulaDataSource
Check if an object is a data source that holds formulas.- Parameters:
s
- object to check- Returns:
- true if it is
-
main
test main- Parameters:
args
- cmd line args- Throws:
Exception
- On error
-