public class DataManager
extends java.lang.Object
DataSources| Modifier and Type | Field and Description |
|---|---|
protected java.util.ArrayList |
allDataSourceIds
A list of
TwoFacedObjects
(label, datasource_id) for all datasource descriptors |
protected java.util.ArrayList |
allFilters
The list of
PatternFileFilters that we create
from the datasources.xml. |
static java.lang.String |
ATTR_DOESMULTIPLES
The XML attribute for allowing multiple data choices
|
static java.lang.String |
ATTR_FACTORY
The XML factory attribute
|
static java.lang.String |
ATTR_FILESELECTION
The XML file selection attribute
|
static java.lang.String |
ATTR_ID
The XML "id" attribute
|
static java.lang.String |
ATTR_LABEL
The XML label attribute
|
static java.lang.String |
ATTR_NAME
The XML name attribute
|
static java.lang.String |
ATTR_NCMLTEMPLATE
xml attribute identifier for the datasource.xml file
|
static java.lang.String |
ATTR_PATTERNS
The XML patterns attribute
|
static java.lang.String |
ATTR_STANDALONE
xml attribute identifier for the datasource.xml file
|
static java.lang.String |
ATTR_VALUE
The XML value attribute
|
protected java.util.Hashtable |
dataSourceNameMap
Maps data source names
|
static java.lang.String |
DATATYPE_ID
The known data type id
|
static java.lang.String |
DATATYPE_UNKNOWN
The "unknown" data type
|
protected java.util.ArrayList |
descriptors
The list of
DataSourceDescriptors defined by the datasource.xml
resource files. |
protected java.util.ArrayList |
fileDataSourceIds
A list of
TwoFacedObjects
(label, datasource_id) for those datasource descriptors
that are for file selection. |
protected java.util.ArrayList |
fileFilters
The list of
PatternFileFilters 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 java.util.Hashtable |
idToDescriptor
A mapping from datasource_id (String) to
DataSourceDescriptor
object. |
static java.lang.String |
PREF_GRIBINDEXINCACHE
Preference for where to save the grib index
|
static java.lang.String |
PROP_CACHE_PERCENT
The cache percent property
|
static java.lang.String |
PROP_DEFAULT_DISPLAY
The default display property
|
static java.lang.String |
PROP_GEOSUBSET_BBOX
bbox property
|
static java.lang.String |
PROP_NETCDF_CONVENTIONHANDLERS
preference id
|
static java.lang.String |
PROP_SHOW_IN_TREE
The show in tree property
|
protected java.util.Hashtable |
seenFilters
This hashtable allows us to keep track of the filter strings that we
have already seen so we don't create duplicates.
|
static java.lang.String |
TAG_DATASOURCE
The XML tag for a datasource
|
static java.lang.String |
TAG_DATASOURCES
The XML tag for datasources
|
static java.lang.String |
TAG_PROPERTY
The XML tag for a property
|
| Constructor and Description |
|---|
DataManager(DataContext dataContext)
Create a new DataManager with the given
DataContext. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
addDataSource(DataSource dataSource)
Add the given
DataSource into the list of datasources if it
is not in the list and if it is not in error. |
DataSourceResults |
createDataSource(java.lang.Object definingObject)
Create a
DataSource (if we know how) defined with the given
definingObject. |
DataSourceResults |
createDataSource(java.lang.Object definingObject,
java.util.Hashtable properties)
Create a
DataSource (if we know how) defined with the given
definingObject and set of properties (which may be null). |
DataSourceResults |
createDataSource(java.lang.Object definingObject,
java.lang.String dataType,
java.util.Hashtable properties)
Create a
DataSource (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). |
void |
createDataSourceAndAskForType(java.lang.Object definingObject,
java.util.Hashtable properties)
Ask the user for the data soruce type and create the given data source
|
DataSource |
findDataSource(java.lang.String name)
Find the data source with the given name
|
java.util.List |
getAllDataSourceIds()
This is used by the
IdvChooserManager |
DataSourceDescriptor |
getCurrent(DataSourceDescriptor dds)
Get the actual current descriptor with the id of the given or return the given one if one is not found.
|
java.lang.String |
getDataCacheDirectory()
Get the data cache dir
|
DataContext |
getDataContext()
Get this DataManager's
DataContext. |
java.lang.StringBuffer |
getDataSourceHtml()
get an html listing of all of the data source descriptions
|
java.util.ArrayList |
getDataSources()
The DataManager holds a set of active
DataSource objects. |
static java.lang.String |
getDatasourceXml(java.lang.String type,
java.lang.String label,
java.lang.Class datasourceClass,
java.util.Hashtable properties)
Create a snippet of the datasource xml for the given data source
|
static java.lang.String |
getDatasourceXml(java.lang.String type,
java.lang.String label,
java.lang.Class datasourceClass,
java.util.Hashtable properties,
java.lang.String[] attributes)
Create a snippet of the datasource xml for the given data source
|
DataSourceDescriptor |
getDescriptor(java.lang.String dataType)
Find the
DataSourceDescriptor with the given dataType id. |
java.util.List<DataSourceDescriptor> |
getDescriptors()
get the data source descriptors
|
java.util.List |
getFileDataSourceList()
This is used by the
IdvChooserManager to allow
the user to create new file data chooser items. |
java.util.ArrayList |
getFileFilters()
The DataManager creates a list of
PatternFileFilters from the datasource xml. |
static java.util.List<java.lang.String> |
getNewVariableName(java.lang.String varName)
Get the new name for a variable name
|
java.lang.String |
getProperty(java.lang.String dataType,
java.lang.String property)
Find the given property on the
DataSourceDescriptor defined
by the given dataType. |
boolean |
getProperty(java.lang.String dataType,
java.lang.String property,
boolean dflt)
Find the given property on the
DataSourceDescriptor defined
by the given dataType. |
java.util.List<DataSourceDescriptor> |
getStandaloneDescriptors()
get the data source descriptors for those data sources that can be stand-alone
|
boolean |
haveDataSource(DataSource dataSource)
Is the given
DataSource currently in the list of active
datasources. |
void |
initEncoder(XmlEncoder encoder,
boolean forRead)
Seed the given encoder with the
DataSourceDescriptors and the
DataManager object. |
void |
initResources(IdvResourceManager resourceManager)
Initialize the resources
|
void |
initURLStreamHandlers()
Add in the AddeURLStreamHandler
|
static boolean |
isFormulaDataSource(java.lang.Object s)
Check if an object is a data source that holds formulas.
|
void |
loadDataSourceXml(XmlResourceCollection resources)
Process the list of xml documents that define the different
DataSources used within the idv. |
protected void |
loadGribResources(IdvResourceManager resourceManager)
Deprecated.
use loadIOSPResources(IdvResourceManager) instead
|
protected void |
loadIospResources(IdvResourceManager resourceManager)
Load the grib lookup tables
|
static void |
main(java.lang.String[] args)
test main
|
void |
reloadAllDataSources()
Reload all the data sources
|
void |
removeAllDataSources()
As the method name implies, remove all datasources managed by this
DataManager.
|
void |
removeDataSource(DataSource dataSource)
Remove the given
DataSource from the list of datasources. |
static void |
setDODSCompression(boolean compress)
Set whether compression is used on DODS file transfers
|
boolean |
validDatasourceId(java.lang.Object definingObject)
Is there a mapping defined from the given definingObject
(which should be a String) to a
DataSourceDescriptor. |
boolean |
validDatasourceId(java.lang.Object definingObject,
java.util.Hashtable properties)
Is there a mapping defined from the given definingObject (which
should be a String) to a
DataSourceDescriptor or is there a
DATATYPE_ID entry in the given properties Hashtable. |
public static final java.lang.String DATATYPE_UNKNOWN
public static final java.lang.String DATATYPE_ID
public static final java.lang.String PROP_SHOW_IN_TREE
public static final java.lang.String PROP_CACHE_PERCENT
public static final java.lang.String PROP_GEOSUBSET_BBOX
public static final java.lang.String PROP_NETCDF_CONVENTIONHANDLERS
public static final java.lang.String PROP_DEFAULT_DISPLAY
public static final java.lang.String TAG_DATASOURCES
public static final java.lang.String TAG_DATASOURCE
public static final java.lang.String TAG_PROPERTY
public static final java.lang.String ATTR_DOESMULTIPLES
public static final java.lang.String ATTR_STANDALONE
public static final java.lang.String ATTR_NCMLTEMPLATE
public static final java.lang.String ATTR_ID
public static final java.lang.String ATTR_FACTORY
public static final java.lang.String ATTR_LABEL
public static final java.lang.String ATTR_NAME
public static final java.lang.String ATTR_PATTERNS
public static final java.lang.String ATTR_FILESELECTION
public static final java.lang.String ATTR_VALUE
public static final java.lang.String PREF_GRIBINDEXINCACHE
protected java.util.ArrayList descriptors
DataSourceDescriptors defined by the datasource.xml
resource files.protected java.util.Hashtable idToDescriptor
DataSourceDescriptor
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.protected java.util.ArrayList allFilters
PatternFileFilters 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.protected java.util.ArrayList fileFilters
PatternFileFilters 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 java.util.Hashtable seenFilters
protected java.util.ArrayList fileDataSourceIds
TwoFacedObjects
(label, datasource_id) for those datasource descriptors
that are for file selection.protected java.util.ArrayList allDataSourceIds
TwoFacedObjects
(label, datasource_id) for all datasource descriptorsprotected java.util.Hashtable dataSourceNameMap
public DataManager(DataContext dataContext)
DataContext.dataContext - The DataContext that this DataManager
exists within (this is usually an instance of
IntegratedDataViewer).public java.lang.String getDataCacheDirectory()
public void initResources(IdvResourceManager resourceManager)
resourceManager - resource managerpublic static void setDODSCompression(boolean compress)
compress - true to compressprotected void loadGribResources(IdvResourceManager resourceManager)
resourceManager - The resource managerprotected void loadIospResources(IdvResourceManager resourceManager)
resourceManager - The resource managerpublic DataContext getDataContext()
DataContext.DataContext of this DataManager.public void loadDataSourceXml(XmlResourceCollection resources)
DataSources used within the idv.resources - The XmlResourceCollection
that holds the set of datasource xml documents.
This may be null.public java.lang.StringBuffer getDataSourceHtml()
public static java.lang.String getDatasourceXml(java.lang.String type,
java.lang.String label,
java.lang.Class datasourceClass,
java.util.Hashtable properties)
throws java.lang.Exception
type - The data source typelabel - the labeldatasourceClass - the classproperties - propertiesjava.lang.Exception - On badnesspublic static java.lang.String getDatasourceXml(java.lang.String type,
java.lang.String label,
java.lang.Class datasourceClass,
java.util.Hashtable properties,
java.lang.String[] attributes)
throws java.lang.Exception
type - The data source typelabel - the labeldatasourceClass - the classproperties - propertiesattributes - If non-null then add these are xml attributesjava.lang.Exception - On badnesspublic java.util.List<DataSourceDescriptor> getDescriptors()
public java.util.List<DataSourceDescriptor> getStandaloneDescriptors()
public java.util.List getFileDataSourceList()
IdvChooserManager to allow
the user to create new file data chooser items.DataSourceDescriptors that are meant
to be used for files.public java.util.List getAllDataSourceIds()
IdvChooserManagerDataSourceDescriptorspublic java.util.ArrayList getDataSources()
DataSource objects.DataSources.public boolean haveDataSource(DataSource dataSource)
DataSource currently in the list of active
datasources.dataSource - The DataSource to check.public boolean addDataSource(DataSource dataSource)
DataSource into the list of datasources if it
is not in the list and if it is not in error.dataSource - The DataSource to add into the list.public void reloadAllDataSources()
public void removeAllDataSources()
public void removeDataSource(DataSource dataSource)
DataSource from the list of datasources.dataSource - The DataSource to remove.public java.util.ArrayList getFileFilters()
PatternFileFilters from the datasource xml.PatternFileFilters.public DataSourceDescriptor getCurrent(DataSourceDescriptor dds)
dds - Givenpublic boolean validDatasourceId(java.lang.Object definingObject)
DataSourceDescriptor.definingObject - This is the object passed in when we
try to create a DataSource.public boolean validDatasourceId(java.lang.Object definingObject,
java.util.Hashtable properties)
DataSourceDescriptor or is there a
DATATYPE_ID entry in the given properties Hashtable.definingObject - This is the object passed in when we try to
create a DataSource.properties - May hold a DATATYPE_ID entry.public DataSource findDataSource(java.lang.String name)
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 namepublic DataSourceResults createDataSource(java.lang.Object definingObject)
DataSource (if we know how) defined with the given
definingObject.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).DataSources defined by the given
definingObject or null.public DataSourceResults createDataSource(java.lang.Object definingObject, java.util.Hashtable properties)
DataSource (if we know how) defined with the given
definingObject and set of properties (which may be null).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.DataSource defined by the given
definingObject or null.public void createDataSourceAndAskForType(java.lang.Object definingObject,
java.util.Hashtable properties)
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.public DataSourceResults createDataSource(java.lang.Object definingObject, java.lang.String dataType, java.util.Hashtable properties)
DataSource (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).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.DataSource defined by the given
definingObject or null.public void initEncoder(XmlEncoder encoder, boolean forRead)
DataSourceDescriptors and the
DataManager object.encoder - The encoder to seed.forRead - Is this encoding for a read or a write.public DataSourceDescriptor getDescriptor(java.lang.String dataType)
DataSourceDescriptor with the given dataType id.dataType - The dataType id to lookup.public java.lang.String getProperty(java.lang.String dataType,
java.lang.String property)
DataSourceDescriptor defined
by the given dataType.dataType - The data source descriptor id.property - The property name.public boolean getProperty(java.lang.String dataType,
java.lang.String property,
boolean dflt)
DataSourceDescriptor defined
by the given dataType. If not found then return the given dflt.dataType - The data source descriptor id.property - The property name.dflt - The default value.public static java.util.List<java.lang.String> getNewVariableName(java.lang.String varName)
varName - _more_public void initURLStreamHandlers()
public static boolean isFormulaDataSource(java.lang.Object s)
s - object to checkpublic static void main(java.lang.String[] args)
throws java.lang.Exception
args - cmd line argsjava.lang.Exception - On error