Package ucar.unidata.data
Class DataManager
java.lang.Object
ucar.unidata.data.DataManager
A class for managing
DataSources- Version:
- $Revision: 1.122 $Date: 2007/08/08 16:24:11 $
- Author:
- Metapps development team
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ArrayListA list ofTwoFacedObjects (label, datasource_id) for all datasource descriptorsprotected ArrayListThe list ofPatternFileFilters that we create from the datasources.xml.static final StringThe XML attribute for allowing multiple data choicesstatic final StringThe XML factory attributestatic final StringThe XML file selection attributestatic final StringThe XML "id" attributestatic final StringThe XML label attributestatic final StringThe XML name attributestatic final Stringxml attribute identifier for the datasource.xml filestatic final StringThe XML patterns attributestatic final Stringxml attribute identifier for the datasource.xml filestatic final StringThe XML value attributeprotected HashtableMaps data source namesstatic final StringThe known data type idstatic final StringThe "unknown" data typeprotected ArrayListThe list ofDataSourceDescriptors defined by the datasource.xml resource files.protected ArrayListA list ofTwoFacedObjects (label, datasource_id) for those datasource descriptors that are for file selection.protected ArrayListThe list ofPatternFileFilters 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 HashtableA mapping from datasource_id (String) toDataSourceDescriptorobject.static final StringPreference for where to save the grib indexstatic final StringThe cache percent propertystatic final StringThe default display propertystatic final Stringbbox propertystatic final Stringpreference idstatic final StringThe show in tree propertyprotected HashtableThis hashtable allows us to keep track of the filter strings that we have already seen so we don't create duplicates.static final StringThe XML tag for a datasourcestatic final StringThe XML tag for datasourcesstatic final StringThe XML tag for a property -
Constructor Summary
ConstructorsConstructorDescriptionDataManager(DataContext dataContext) Create a new DataManager with the givenDataContext. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddDataSource(DataSource dataSource) Add the givenDataSourceinto 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).voidcreateDataSourceAndAskForType(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 theIdvChooserManagerGet 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 activeDataSourceobjects.static StringgetDatasourceXml(String type, String label, Class datasourceClass, Hashtable properties) Create a snippet of the datasource xml for the given data sourcestatic StringgetDatasourceXml(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 theDataSourceDescriptorwith the given dataType id.get the data source descriptorsThis is used by theIdvChooserManagerto allow the user to create new file data chooser items.The DataManager creates a list ofPatternFileFilters from the datasource xml.getNewVariableName(String varName) Get the new name for a variable namegetProperty(String dataType, String property) Find the given property on theDataSourceDescriptordefined by the given dataType.booleangetProperty(String dataType, String property, boolean dflt) Find the given property on theDataSourceDescriptordefined by the given dataType.get the data source descriptors for those data sources that can be stand-alonebooleanhaveDataSource(DataSource dataSource) Is the givenDataSourcecurrently in the list of active datasources.voidinitEncoder(XmlEncoder encoder, boolean forRead) Seed the given encoder with theDataSourceDescriptors and the DataManager object.voidinitResources(IdvResourceManager resourceManager) Initialize the resourcesvoidAdd in the AddeURLStreamHandlerstatic booleanCheck if an object is a data source that holds formulas.voidloadDataSourceXml(XmlResourceCollection resources) Process the list of xml documents that define the differentDataSources used within the idv.protected voidloadGribResources(IdvResourceManager resourceManager) Load the grib lookup tablesprotected voidloadIospResources(IdvResourceManager resourceManager) Load the grib lookup tablesstatic voidtest mainvoidReload all the data sourcesvoidAs the method name implies, remove all datasources managed by this DataManager.voidremoveDataSource(DataSource dataSource) Remove the givenDataSourcefrom the list of datasources.static voidsetDODSCompression(boolean compress) Set whether compression is used on DODS file transfersbooleanvalidDatasourceId(Object definingObject) Is there a mapping defined from the given definingObject (which should be a String) to aDataSourceDescriptor.booleanvalidDatasourceId(Object definingObject, Hashtable properties) Is there a mapping defined from the given definingObject (which should be a String) to aDataSourceDescriptoror 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 ofDataSourceDescriptors defined by the datasource.xml resource files. -
idToDescriptor
A mapping from datasource_id (String) toDataSourceDescriptorobject. 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 ofPatternFileFilters 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 ofPatternFileFilters 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 ofTwoFacedObjects (label, datasource_id) for those datasource descriptors that are for file selection. -
allDataSourceIds
A list ofTwoFacedObjects (label, datasource_id) for all datasource descriptors -
dataSourceNameMap
Maps data source names
-
-
Constructor Details
-
DataManager
Create a new DataManager with the givenDataContext.- Parameters:
dataContext- TheDataContextthat 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
DataContextof this DataManager.
-
loadDataSourceXml
Process the list of xml documents that define the differentDataSources used within the idv.- Parameters:
resources- TheXmlResourceCollectionthat 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 theIdvChooserManagerto allow the user to create new file data chooser items.- Returns:
- The list of
DataSourceDescriptors that are meant to be used for files.
-
getAllDataSourceIds
This is used by theIdvChooserManager- Returns:
- The list of
DataSourceDescriptors
-
getDataSources
The DataManager holds a set of activeDataSourceobjects.- Returns:
- The list of active
DataSources.
-
haveDataSource
Is the givenDataSourcecurrently in the list of active datasources.- Parameters:
dataSource- TheDataSourceto check.- Returns:
- Is dataSource in the datasources list.
-
addDataSource
Add the givenDataSourceinto the list of datasources if it is not in the list and if it is not in error.- Parameters:
dataSource- TheDataSourceto 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 givenDataSourcefrom the list of datasources.- Parameters:
dataSource- TheDataSourceto remove.
-
getFileFilters
The DataManager creates a list ofPatternFileFilters from the datasource xml.- Returns:
- The list of
PatternFileFilters.
-
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 aDataSourceDescriptoror 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
DataSources 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
DataSourcedefined 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
DataSourcedefined by the given definingObject or null.
-
initEncoder
Seed the given encoder with theDataSourceDescriptors and the DataManager object.- Parameters:
encoder- The encoder to seed.forRead- Is this encoding for a read or a write.
-
getDescriptor
Find theDataSourceDescriptorwith 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 theDataSourceDescriptordefined 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 theDataSourceDescriptordefined 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
-