ucar.nc2.thredds
Class ThreddsDataFactory

java.lang.Object
  extended by ucar.nc2.thredds.ThreddsDataFactory

public class ThreddsDataFactory
extends Object

This tries to translate a THREDDS InvDataset into a data object that can be used, either as a NetcdfDataset or as a FeatureDataset.

As input, it can take

  1. An InvAccess object.
  2. An InvDataset object. If the InvDataset has more that one InvAccess, it has to try to choose which to use, based on what Service type we know how to work with.
  3. A url of the form [thredds:]catalog.xml#datasetId. In this case it opens the catalog, and looks for the InvDataset with the given datasetId.
  4. A url of the form thredds:resolve:resolveURL. In this case it expects that the URL will return a catalog with a single top level dataset, which is the "resolved" dataset.

It annotates the NetcdfDataset with info from the InvDataset.

You can reuse a ThreddsDataFactory, but only within a single thread.

Author:
caron

Nested Class Summary
static class ThreddsDataFactory.Result
          The result of trying to open a THREDDS dataset.
 
Field Summary
static String SCHEME
           
 
Constructor Summary
ThreddsDataFactory()
           
 
Method Summary
static void annotate(InvDataset ds, NetcdfDataset ncDataset)
          Add information from the InvDataset to the NetcdfDataset.
 InvAccess chooseDatasetAccess(List<InvAccess> accessList)
          Find the "best" access in case theres more than one, based on what the CDM knows how to open and use.
 NetcdfDataset openDataset(InvAccess access, boolean acquire, CancelTask task, Formatter log)
          Try to open invAccess as a NetcdfDataset.
 NetcdfDataset openDataset(InvDataset invDataset, boolean acquire, CancelTask task, Formatter log)
          Try to open as a NetcdfDataset.
 NetcdfDataset openDataset(String location, boolean acquire, CancelTask task, Formatter log)
          Open a NetcdfDataset from a URL location string.
 ThreddsDataFactory.Result openFeatureDataset(FeatureType wantFeatureType, InvDataset invDataset, CancelTask task, ThreddsDataFactory.Result result)
           
 ThreddsDataFactory.Result openFeatureDataset(FeatureType wantFeatureType, String urlString, CancelTask task)
          Open a FeatureDataset from a URL location string, and a desired type (may by NONE or null).
 ThreddsDataFactory.Result openFeatureDataset(InvAccess access, CancelTask task)
          Open a FeatureDataset from an InvAccess object.
 ThreddsDataFactory.Result openFeatureDataset(InvDataset invDataset, CancelTask task)
          Open a FeatureDataset from an InvDataset object, deciding on which InvAccess to use.
 ThreddsDataFactory.Result openFeatureDataset(String urlString, CancelTask task)
          Open a FeatureDataset from a URL location string.
static void setDebugFlags(DebugFlags debugFlag)
           
static void setPreferCdm(boolean prefer)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCHEME

public static final String SCHEME
See Also:
Constant Field Values
Constructor Detail

ThreddsDataFactory

public ThreddsDataFactory()
Method Detail

setPreferCdm

public static void setPreferCdm(boolean prefer)

setDebugFlags

public static void setDebugFlags(DebugFlags debugFlag)

openFeatureDataset

public ThreddsDataFactory.Result openFeatureDataset(String urlString,
                                                    CancelTask task)
                                             throws IOException
Open a FeatureDataset from a URL location string. Example URLS:

Parameters:
urlString - [thredds:]catalog.xml#datasetId
task - may be null
Returns:
ThreddsDataFactory.Result check fatalError for validity
Throws:
IOException - on read error

openFeatureDataset

public ThreddsDataFactory.Result openFeatureDataset(FeatureType wantFeatureType,
                                                    String urlString,
                                                    CancelTask task)
                                             throws IOException
Open a FeatureDataset from a URL location string, and a desired type (may by NONE or null).

Parameters:
wantFeatureType - desired feature type, may be NONE or null
urlString - [thredds:]catalog.xml#datasetId
task - may be null
Returns:
ThreddsDataFactory.Result check fatalError for validity
Throws:
IOException - on read error

openFeatureDataset

public ThreddsDataFactory.Result openFeatureDataset(InvDataset invDataset,
                                                    CancelTask task)
                                             throws IOException
Open a FeatureDataset from an InvDataset object, deciding on which InvAccess to use.

Parameters:
invDataset - use this to figure out what type, how to open, etc
task - allow user to cancel; may be null
Returns:
ThreddsDataFactory.Result check fatalError for validity
Throws:
IOException - on read error

openFeatureDataset

public ThreddsDataFactory.Result openFeatureDataset(FeatureType wantFeatureType,
                                                    InvDataset invDataset,
                                                    CancelTask task,
                                                    ThreddsDataFactory.Result result)
                                             throws IOException
Throws:
IOException

openFeatureDataset

public ThreddsDataFactory.Result openFeatureDataset(InvAccess access,
                                                    CancelTask task)
                                             throws IOException
Open a FeatureDataset from an InvAccess object.

Parameters:
access - use this InvAccess.
task - may be null
Returns:
ThreddsDataFactory.Result check fatalError for validity
Throws:
IOException - on read error

openDataset

public NetcdfDataset openDataset(String location,
                                 boolean acquire,
                                 CancelTask task,
                                 Formatter log)
                          throws IOException
Open a NetcdfDataset from a URL location string. Example URLS:

Parameters:
location - catalog.xml#datasetId, may optionally start with "thredds:"
task - may be null
log - error messages gp here, may be null
acquire - if true, aquire the dataset, else open it
Returns:
NetcdfDataset
Throws:
IOException - on read error

openDataset

public NetcdfDataset openDataset(InvDataset invDataset,
                                 boolean acquire,
                                 CancelTask task,
                                 Formatter log)
                          throws IOException
Try to open as a NetcdfDataset.

Parameters:
invDataset - open this
acquire - if true, aquire the dataset, else open it
task - may be null
log - error message, may be null
Returns:
NetcdfDataset or null if failure
Throws:
IOException - on read error

openDataset

public NetcdfDataset openDataset(InvAccess access,
                                 boolean acquire,
                                 CancelTask task,
                                 Formatter log)
                          throws IOException
Try to open invAccess as a NetcdfDataset.

Parameters:
access - open this InvAccess
acquire - if true, aquire the dataset, else open it
task - may be null
log - error message, may be null
Returns:
NetcdfDataset or null if failure
Throws:
IOException - on read error

chooseDatasetAccess

public InvAccess chooseDatasetAccess(List<InvAccess> accessList)
Find the "best" access in case theres more than one, based on what the CDM knows how to open and use.

Parameters:
accessList - choose from this list.
Returns:
best access method.

annotate

public static void annotate(InvDataset ds,
                            NetcdfDataset ncDataset)
Add information from the InvDataset to the NetcdfDataset.

Parameters:
ds - get info from here
ncDataset - add to here


Copyright © 1999-2011 UCAR/Unidata. All Rights Reserved.