Package ucar.nc2.thredds
Class ThreddsDataFactory
- java.lang.Object
-
- 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- An InvAccess object.
- 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.
- 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.
- 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classThreddsDataFactory.ResultThe result of trying to open a THREDDS dataset.
-
Constructor Summary
Constructors Constructor Description ThreddsDataFactory()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidannotate(InvDataset ds, ucar.nc2.dataset.NetcdfDataset ncDataset)Add information from the InvDataset to the NetcdfDataset.InvAccesschooseDatasetAccess(List<InvAccess> accessList)Find the "best" access in case theres more than one, based on what the CDM knows how to open and use.ucar.nc2.dataset.NetcdfDatasetopenDataset(String location, boolean acquire, ucar.nc2.util.CancelTask task, Formatter log)Open a NetcdfDataset from a URL location string.ucar.nc2.dataset.NetcdfDatasetopenDataset(InvAccess access, boolean acquire, ucar.nc2.util.CancelTask task, Formatter log)Try to open invAccess as a NetcdfDataset.ucar.nc2.dataset.NetcdfDatasetopenDataset(InvDataset invDataset, boolean acquire, ucar.nc2.util.CancelTask task, Formatter log)Try to open as a NetcdfDataset.ThreddsDataFactory.ResultopenFeatureDataset(String urlString, ucar.nc2.util.CancelTask task)Open a FeatureDataset from a URL location string.ThreddsDataFactory.ResultopenFeatureDataset(InvAccess access, ucar.nc2.util.CancelTask task)Open a FeatureDataset from an InvAccess object.ThreddsDataFactory.ResultopenFeatureDataset(InvDataset invDataset, ucar.nc2.util.CancelTask task)Open a FeatureDataset from an InvDataset object, deciding on which InvAccess to use.ThreddsDataFactory.ResultopenFeatureDataset(ucar.nc2.constants.FeatureType wantFeatureType, String urlString, ucar.nc2.util.CancelTask task)Open a FeatureDataset from a URL location string, and a desired type (may by NONE or null).ThreddsDataFactory.ResultopenFeatureDataset(ucar.nc2.constants.FeatureType wantFeatureType, InvDataset invDataset, ucar.nc2.util.CancelTask task, ThreddsDataFactory.Result result)static voidsetDebugFlags(ucar.nc2.util.DebugFlags debugFlag)static voidsetPreferAccess(ServiceType... prefer)static voidsetPreferCdm(boolean prefer)
-
-
-
Field Detail
-
PROTOCOL
public static final String PROTOCOL
- See Also:
- Constant Field Values
-
SCHEME
public static final String SCHEME
- See Also:
- Constant Field Values
-
-
Method Detail
-
setPreferCdm
public static void setPreferCdm(boolean prefer)
-
setPreferAccess
public static void setPreferAccess(ServiceType... prefer)
-
setDebugFlags
public static void setDebugFlags(ucar.nc2.util.DebugFlags debugFlag)
-
openFeatureDataset
public ThreddsDataFactory.Result openFeatureDataset(String urlString, ucar.nc2.util.CancelTask task) throws IOException
Open a FeatureDataset from a URL location string. Example URLS:- http://localhost:8080/test/addeStationDataset.xml#surfaceHourly
- thredds:http://localhost:8080/test/addeStationDataset.xml#surfaceHourly
- thredds://localhost:8080/test/addeStationDataset.xml#surfaceHourly
- thredds:file:c:/test/data/catalog/addeStationDataset.xml#AddeSurfaceData (absolute file)
- thredds:resolve:resolveURL
- Parameters:
urlString- [thredds:]catalog.xml#datasetIdtask- may be null- Returns:
- ThreddsDataFactory.Result check fatalError for validity
- Throws:
IOException- on read error
-
openFeatureDataset
public ThreddsDataFactory.Result openFeatureDataset(ucar.nc2.constants.FeatureType wantFeatureType, String urlString, ucar.nc2.util.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 nullurlString- [thredds:]catalog.xml#datasetIdtask- may be null- Returns:
- ThreddsDataFactory.Result check fatalError for validity
- Throws:
IOException- on read error
-
openFeatureDataset
public ThreddsDataFactory.Result openFeatureDataset(InvDataset invDataset, ucar.nc2.util.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, etctask- allow user to cancel; may be null- Returns:
- ThreddsDataFactory.Result check fatalError for validity
- Throws:
IOException- on read error
-
openFeatureDataset
public ThreddsDataFactory.Result openFeatureDataset(ucar.nc2.constants.FeatureType wantFeatureType, InvDataset invDataset, ucar.nc2.util.CancelTask task, ThreddsDataFactory.Result result) throws IOException
- Throws:
IOException
-
openFeatureDataset
public ThreddsDataFactory.Result openFeatureDataset(InvAccess access, ucar.nc2.util.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 ucar.nc2.dataset.NetcdfDataset openDataset(String location, boolean acquire, ucar.nc2.util.CancelTask task, Formatter log) throws IOException
Open a NetcdfDataset from a URL location string. Example URLS:- http://localhost:8080/test/addeStationDataset.xml#surfaceHourly
- thredds:http://localhost:8080/test/addeStationDataset.xml#surfaceHourly
- thredds://localhost:8080/test/addeStationDataset.xml#surfaceHourly
- thredds:file:c:/dev/netcdf-java-2.2/test/data/catalog/addeStationDataset.xml#AddeSurfaceData (absolute file)
- thredds:resolve:resolveURL
- Parameters:
location- catalog.xml#datasetId, may optionally start with "thredds:"task- may be nulllog- error messages gp here, may be nullacquire- if true, aquire the dataset, else open it- Returns:
- NetcdfDataset
- Throws:
IOException- on read error
-
openDataset
public ucar.nc2.dataset.NetcdfDataset openDataset(InvDataset invDataset, boolean acquire, ucar.nc2.util.CancelTask task, Formatter log) throws IOException
Try to open as a NetcdfDataset.- Parameters:
invDataset- open thisacquire- if true, aquire the dataset, else open ittask- may be nulllog- error message, may be null- Returns:
- NetcdfDataset or null if failure
- Throws:
IOException- on read error
-
openDataset
public ucar.nc2.dataset.NetcdfDataset openDataset(InvAccess access, boolean acquire, ucar.nc2.util.CancelTask task, Formatter log) throws IOException
Try to open invAccess as a NetcdfDataset.- Parameters:
access- open this InvAccessacquire- if true, aquire the dataset, else open ittask- may be nulllog- 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, ucar.nc2.dataset.NetcdfDataset ncDataset)
Add information from the InvDataset to the NetcdfDataset.- Parameters:
ds- get info from herencDataset- add to here
-
-