visad.data.netcdf.in
Class NetcdfAdapter

java.lang.Object
  extended by visad.data.netcdf.in.NetcdfAdapter

public class NetcdfAdapter
extends Object

A class for importing a netCDF dataset.

This implementation uses a Strategy for importing netCDF datasets. The initial strategy is determined from the Java (not JavaBean) property visad.data.netcdf.in.Strategy. If that property is set, then its values is used as the name of the initial Strategy class to use. If that property is not set, then the initial strategy is Strategy.DEFAULT. See, however, setDefaultStrategy(Strategy).

Author:
Steven R. Emmerson

Field Summary
static String IMPORT_STRATEGY_PROPERTY
          The name of the import-strategy Java property.
 
Constructor Summary
NetcdfAdapter(ucar.netcdf.Netcdf netcdf, QuantityDB quantityDB)
          Constructs from a netCDF dataset.
NetcdfAdapter(ucar.netcdf.Netcdf netcdf, QuantityDB quantityDB, boolean charToText)
          Constructs from a netCDF dataset.
NetcdfAdapter(View view)
          Constructs from a view of a netCDF dataset.
 
Method Summary
 DataImpl getData()
          Gets the VisAD data object corresponding to the netCDF dataset.
 DataImpl getData(Strategy strategy)
          Gets the VisAD data object corresponding to the netCDF dataset using a given strategy.
static Strategy getDefaultStrategy()
          Returns the default strategy used to import a netCDF dataset.
 DataImpl getProxy()
          Returns a proxy for the VisAD data object corresponding to the netCDF dataset.
protected  View getView()
          Gets the view of the netCDF dataset.
protected static DataImpl importData(View view, Merger merger, DataFactory dataFactory)
          Returns the VisAD data object corresponding to the netCDF dataset.
static void main(String[] args)
          Tests this class.
static Strategy setDefaultStrategy(Strategy strategy)
          Sets the default strategy used to import a netCDF dataset.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IMPORT_STRATEGY_PROPERTY

public static final String IMPORT_STRATEGY_PROPERTY
The name of the import-strategy Java property. (NOTE: A Java property is not a JavaBean property.)

See Also:
Constant Field Values
Constructor Detail

NetcdfAdapter

public NetcdfAdapter(ucar.netcdf.Netcdf netcdf,
                     QuantityDB quantityDB)
              throws VisADException,
                     RemoteException,
                     IOException,
                     BadFormException
Constructs from a netCDF dataset.

Parameters:
netcdf - The netCDF dataset to be adapted.
quantityDB - A quantity database to be used to map netCDF variables to VisAD Quantitys.
Throws:
VisADException - Problem in core VisAD. Probably some VisAD object couldn't be created.
RemoteException - Remote data access failure.
IOException - Data access I/O failure.
BadFormException - Non-conforming netCDF dataset.

NetcdfAdapter

public NetcdfAdapter(ucar.netcdf.Netcdf netcdf,
                     QuantityDB quantityDB,
                     boolean charToText)
              throws VisADException,
                     RemoteException,
                     IOException,
                     BadFormException
Constructs from a netCDF dataset.

Parameters:
netcdf - The netCDF dataset to be adapted.
quantityDB - A quantity database to be used to map netCDF variables to VisAD Quantitys.
charToText - Specifies whether the NetcdfAdapter should map char variables to VisAD Text objects
Throws:
VisADException - Problem in core VisAD. Probably some VisAD object couldn't be created.
RemoteException - Remote data access failure.
IOException - Data access I/O failure.
BadFormException - Non-conforming netCDF dataset.

NetcdfAdapter

public NetcdfAdapter(View view)
Constructs from a view of a netCDF dataset.

Parameters:
view - The view of the netCDF dataset to be adapted.
Method Detail

setDefaultStrategy

public static Strategy setDefaultStrategy(Strategy strategy)
Sets the default strategy used to import a netCDF dataset. Subsequent use of the getData() method will use the given strategy.

Parameters:
strategy - The default strategy to use.
Returns:
The previous strategy.
Throws:
NullPointerException - if the strategy is null.

getDefaultStrategy

public static Strategy getDefaultStrategy()
Returns the default strategy used to import a netCDF dataset.

Returns:
The default strategy.

getData

public DataImpl getData()
                 throws IOException,
                        VisADException,
                        RemoteException,
                        BadFormException,
                        OutOfMemoryError

Gets the VisAD data object corresponding to the netCDF dataset. This is a potentially expensive method in either time or space.

This implementation invokes method getData(Strategy) with the default Strategy.

Returns:
The top-level, VisAD data object in the netCDF dataset.
Throws:
VisADException - Problem in core VisAD. Probably some VisAD object couldn't be created.
IOException - Data access I/O failure.
BadFormException - netCDF dataset doesn't conform to conventions implicit in the View that was passed to the constructor.
OutOfMemoryError - Couldn't read netCDF dataset into memory.
RemoteException - if a Java RMI failure occurs.
See Also:
getData(Strategy)

getData

public DataImpl getData(Strategy strategy)
                 throws IOException,
                        VisADException,
                        RemoteException,
                        BadFormException,
                        OutOfMemoryError
Gets the VisAD data object corresponding to the netCDF dataset using a given strategy. This is a potentially expensive method in either time or space.

Parameters:
strategy - The strategy to use for importing the data.
Returns:
The top-level, VisAD data object in the netCDF dataset.
Throws:
VisADException - Problem in core VisAD. Probably some VisAD object couldn't be created.
IOException - Data access I/O failure.
BadFormException - netCDF dataset doesn't conform to conventions implicit in the View that was passed to the constructor.
OutOfMemoryError - Couldn't read netCDF dataset into memory.
RemoteException - if a Java RMI failure occurs.

getProxy

public DataImpl getProxy()
                  throws IOException,
                         VisADException,
                         RemoteException,
                         BadFormException,
                         OutOfMemoryError
Returns a proxy for the VisAD data object corresponding to the netCDF dataset. Because of the way import strategies are used, this just invokes the getData() method.

Returns:
A proxy for the top-level, VisAD data object in the netCDF dataset.
Throws:
VisADException - Problem in core VisAD. Probably some VisAD object couldn't be created.
IOException - Data access I/O failure.
BadFormException - netCDF dataset doesn't conform to conventions implicit in constructing View.
OutOfMemoryError - Couldn't read netCDF dataset into memory.
RemoteException - if a Java RMI failure occurs.
See Also:
Strategy.getData(visad.data.netcdf.in.NetcdfAdapter)

importData

protected static DataImpl importData(View view,
                                     Merger merger,
                                     DataFactory dataFactory)
                              throws IOException,
                                     VisADException,
                                     RemoteException,
                                     BadFormException,
                                     OutOfMemoryError
Returns the VisAD data object corresponding to the netCDF dataset. This is a potentially expensive method in either time or space. This method is designed to be used by a Strategy.

Parameters:
view - The view of the netCDF dataset.
merger - The object that merges the data objects in the netCDF dataset.
dataFactory - The factory that creates VisAD data objects from virtual data objects.
Returns:
The VisAD data object corresponding to the netCDF dataset.
Throws:
VisADException - Problem in core VisAD. Probably some VisAD object couldn't be created.
IOException - Data access I/O failure.
BadFormException - netCDF dataset doesn't conform to conventions implicit in constructing View.
OutOfMemoryError - Couldn't read netCDF dataset into memory.
RemoteException - if a Java RMI failure occurs.
See Also:
Strategy

getView

protected View getView()
Gets the view of the netCDF dataset.

Returns:
The view of the netCDF dataset.

main

public static void main(String[] args)
                 throws Exception
Tests this class.

Parameters:
args - File pathnames.
Throws:
Exception - Something went wrong.