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 SummaryFieldsModifier 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 SummaryConstructorsConstructorDescriptionDataManager(DataContext dataContext) Create a new DataManager with the givenDataContext.
- 
Method SummaryModifier 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_UNKNOWNThe "unknown" data type- See Also:
 
- 
DATATYPE_IDThe known data type id- See Also:
 
- 
PROP_SHOW_IN_TREEThe show in tree property- See Also:
 
- 
PROP_CACHE_PERCENTThe cache percent property- See Also:
 
- 
PROP_GEOSUBSET_BBOXbbox property- See Also:
 
- 
PROP_NETCDF_CONVENTIONHANDLERSpreference id- See Also:
 
- 
PROP_DEFAULT_DISPLAYThe default display property- See Also:
 
- 
TAG_DATASOURCESThe XML tag for datasources- See Also:
 
- 
TAG_DATASOURCEThe XML tag for a datasource- See Also:
 
- 
TAG_PROPERTYThe XML tag for a property- See Also:
 
- 
ATTR_DOESMULTIPLESThe XML attribute for allowing multiple data choices- See Also:
 
- 
ATTR_STANDALONExml attribute identifier for the datasource.xml file- See Also:
 
- 
ATTR_NCMLTEMPLATExml attribute identifier for the datasource.xml file- See Also:
 
- 
ATTR_IDThe XML "id" attribute- See Also:
 
- 
ATTR_FACTORYThe XML factory attribute- See Also:
 
- 
ATTR_LABELThe XML label attribute- See Also:
 
- 
ATTR_NAMEThe XML name attribute- See Also:
 
- 
ATTR_PATTERNSThe XML patterns attribute- See Also:
 
- 
ATTR_FILESELECTIONThe XML file selection attribute- See Also:
 
- 
ATTR_VALUEThe XML value attribute- See Also:
 
- 
PREF_GRIBINDEXINCACHEPreference for where to save the grib index- See Also:
 
- 
descriptorsThe list ofDataSourceDescriptors defined by the datasource.xml resource files.
- 
idToDescriptorA 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.
- 
allFiltersThe 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.
- 
fileFiltersThe 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").
- 
seenFiltersThis hashtable allows us to keep track of the filter strings that we have already seen so we don't create duplicates.
- 
fileDataSourceIdsA list ofTwoFacedObjects (label, datasource_id) for those datasource descriptors that are for file selection.
- 
allDataSourceIdsA list ofTwoFacedObjects (label, datasource_id) for all datasource descriptors
- 
dataSourceNameMapMaps data source names
 
- 
- 
Constructor Details- 
DataManagerCreate a new DataManager with the givenDataContext.- Parameters:
- dataContext- The- DataContextthat this DataManager exists within (this is usually an instance of- IntegratedDataViewer).
 
 
- 
- 
Method Details- 
getDataCacheDirectoryGet the data cache dir- Returns:
- data cache dir
 
- 
initResourcesInitialize the resources- Parameters:
- resourceManager- resource manager
 
- 
setDODSCompressionpublic static void setDODSCompression(boolean compress) Set whether compression is used on DODS file transfers- Parameters:
- compress- true to compress
 
- 
loadGribResourcesLoad the grib lookup tables- Parameters:
- resourceManager- The resource manager deprecated use loadIOSPResources(IdvResourceManager) instead
 
- 
loadIospResourcesLoad the grib lookup tables- Parameters:
- resourceManager- The resource manager
 
- 
getDataContextGet this DataManager'sDataContext.- Returns:
- The DataContextof this DataManager.
 
- 
loadDataSourceXmlProcess the list of xml documents that define the differentDataSources used within the idv.- Parameters:
- resources- The- XmlResourceCollectionthat holds the set of datasource xml documents. This may be null.
 
- 
getDataSourceHtmlget an html listing of all of the data source descriptions- Returns:
- html listing of data sources
 
- 
getDatasourceXmlpublic 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 type
- label- the label
- datasourceClass- the class
- properties- properties
- Returns:
- The xml
- Throws:
- Exception- On badness
 
- 
getDatasourceXmlpublic 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 type
- label- the label
- datasourceClass- the class
- properties- properties
- attributes- If non-null then add these are xml attributes
- Returns:
- The xml
- Throws:
- Exception- On badness
 
- 
getDescriptorsget the data source descriptors- Returns:
- the descriptors
 
- 
getStandaloneDescriptorsget the data source descriptors for those data sources that can be stand-alone- Returns:
- stand alone descriptors
 
- 
getFileDataSourceListThis 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.
 
- 
getAllDataSourceIdsThis is used by theIdvChooserManager- Returns:
- The list of DataSourceDescriptors
 
- 
getDataSourcesThe DataManager holds a set of activeDataSourceobjects.- Returns:
- The list of active DataSources.
 
- 
haveDataSourceIs the givenDataSourcecurrently in the list of active datasources.- Parameters:
- dataSource- The- DataSourceto check.
- Returns:
- Is dataSource in the datasources list.
 
- 
addDataSourceAdd the givenDataSourceinto the list of datasources if it is not in the list and if it is not in error.- Parameters:
- dataSource- The- DataSourceto add into the list.
- Returns:
- True if we added this data source, false if we already have this data source
 
- 
reloadAllDataSourcespublic void reloadAllDataSources()Reload all the data sources
- 
removeAllDataSourcespublic void removeAllDataSources()As the method name implies, remove all datasources managed by this DataManager.
- 
removeDataSourceRemove the givenDataSourcefrom the list of datasources.- Parameters:
- dataSource- The- DataSourceto remove.
 
- 
getFileFiltersThe DataManager creates a list ofPatternFileFilters from the datasource xml.- Returns:
- The list of PatternFileFilters.
 
- 
getCurrentGet 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
 
- 
validDatasourceIdIs 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 a- DataSource.
- Returns:
- Do we know how to handle the given definingObject.
 
- 
validDatasourceIdIs 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 a- DataSource.
- properties- May hold a DATATYPE_ID entry.
- Returns:
- Do we know how to handle the given definingObject.
 
- 
findDataSourceFind 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
 
- 
createDataSourceCreate 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.
 
- 
createDataSourceCreate 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.
 
- 
createDataSourceAndAskForTypeAsk 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.
 
- 
createDataSourcepublic 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 the- DataSourceDescriptor(or null).
- properties- The properties for the new DataSource.
- Returns:
- The list of DataSourcedefined by the given definingObject or null.
 
- 
initEncoderSeed 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.
 
- 
getDescriptorFind theDataSourceDescriptorwith the given dataType id.- Parameters:
- dataType- The dataType id to lookup.
- Returns:
- The DataSourceDescriptor defined by the given dataType (or null).
 
- 
getPropertyFind 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.
 
- 
getPropertyFind 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.
 
- 
getNewVariableNameGet the new name for a variable name- Parameters:
- varName- _more_
- Returns:
- new name
 
- 
initURLStreamHandlerspublic void initURLStreamHandlers()Add in the AddeURLStreamHandler
- 
isFormulaDataSourceCheck if an object is a data source that holds formulas.- Parameters:
- s- object to check
- Returns:
- true if it is
 
- 
maintest main- Parameters:
- args- cmd line args
- Throws:
- Exception- On error
 
 
-