## ucar.netcdf
Class AbstractNetcdf

    java.lang.Object
      ucar.netcdf.AbstractNetcdf

All Implemented Interfaces:
  Netcdf

Direct Known Subclasses:
  NetcdfFile, RemoteNetcdf, VisADAdapter

public abstract class AbstractNetcdf
extends Object
implements Netcdf

This abstract class provides a skeletal implementation of the Netcdf interface.

A minimal concrete implementation would provide a concrete implementation of method `Accessor ioFactory(ProtoVariable proto)`. It would also provide a constructor which takes a Schema argument and calls super(Schema) to get this class to hook everything up.

TODO: There is a lot more to be said.

Constructor Summary
`protected` `AbstractNetcdf()` Create an empty instance.
`protected` `AbstractNetcdf(Class varClass)` Create an empty instance to be populated with instances of some subclass of Variable.
`protected` `AbstractNetcdf(Schema sc, boolean init)` Create an instance populated with instances of Variable.
`protected` `AbstractNetcdf(Schema sc, boolean init, Class varClass)` Create an instance populated with instances of some subclass of Variable.

Method Summary
`protected void` `add(ProtoVariable proto, Accessor io)` Used for incremental initialization.
`boolean` `contains(Object oo)` Tests if the argument is in this set.
`boolean` `contains(String name)` Tests if the Variable identified by `name` is in this set.
`Variable` `get(String name)` Retrieve the variable associated with the specified name.
`Attribute` `getAttribute(String name)` Convenience function; look up global Attribute by name.
`AttributeSet` `getAttributes()` Returns the set of attributes associated with this, also know as the "global" attributes.
`DimensionSet` `getDimensions()` Returns the set of dimensions associated with this, the union of those used by each of the variables.
`(package private) Schema` `getSchema()`
`(package private) int` `indexOf(Dimension dim)` Used to compute 'dimension index' needed in netcdf version 1 files.
`protected void` `initHashtable()`
`protected abstract Accessor` `ioFactory(ProtoVariable proto)` Used when creating variables to populate this.
`VariableIterator` `iterator()` Returns VariableIterator for the elements.
`protected void` `putAttribute(Attribute attr)` Used for incremental initialization.
`protected void` `putDimension(Dimension dim)` Used for incremental initialization.
`int` `size()` Returns the number of variables
`void` `toCdl(StringBuffer buf)` Format as CDL.
`String` `toString()`
`(package private) static Class[]` `varCtorParameterTypes()` These are the parameter types used for the Variable constructor in `initHashtable(Class)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### AbstractNetcdf

    protected AbstractNetcdf()

  Create an empty instance. This may be incrementally populated using the protected put methods below. Use this constructor when you don't have all the ProtoVariables, Dimensions, and global Attributes available initially, such as when constructing from a stream.

### AbstractNetcdf

    protected AbstractNetcdf(Class varClass)
                      throws NoSuchMethodException

  Create an empty instance to be populated with instances of some subclass of Variable.

Parameters:
  `varClass` - Class object for some subclass of Variable. The class must implement a constructor of the form `myVar(ProtoVariable proto, Accessor io)` or NoSuchMethodException will be thrown.

### AbstractNetcdf

    protected AbstractNetcdf(Schema sc,
                             boolean init)

  Create an instance populated with instances of Variable.

Parameters:
  `sc` - the Schema to use. N.B. Not a copy. May be empty, shouldn't be null.
  `init` - if true, call initHashtable()

### AbstractNetcdf

    protected AbstractNetcdf(Schema sc,
                             boolean init,
                             Class varClass)
                      throws NoSuchMethodException,
                             InstantiationException,
                             InvocationTargetException,
                             IllegalAccessException

  Create an instance populated with instances of some subclass of Variable.

Parameters:
  `sc` - the Schema used as a template. May be empty, shouldn't be null.
  `init` - if true, call initHashtable()
  `varClass` - Class object for some subclass of Variable. The class must implement a constructor of the form `myVar(ProtoVariable proto, Accessor io)` or NoSuchMethodException will be thrown.

Method Detail

### size

    public int size()

  Returns the number of variables

  Specified by:
    `size` in interface `Netcdf`
  Returns:
    int number of variables

### iterator

    public VariableIterator iterator()

  Returns VariableIterator for the elements.

  Specified by:
    `iterator` in interface `Netcdf`
  Returns:
    VariableIterator for the elements.
  See Also:
    `VariableIterator`

### get

    public Variable get(String name)

  Retrieve the variable associated with the specified name.

  Specified by:
    `get` in interface `Netcdf`
  Parameters:
    `name` - String which identifies the desired variable
  Returns:
    the variable, or null if not found

### contains

    public boolean contains(String name)

  Tests if the Variable identified by `name` is in this set.

  Specified by:
    `contains` in interface `Netcdf`
  Parameters:
    `name` - String which identifies the desired variable
  Returns:
    `true` if and only if this set contains the named variable.

### contains

    public boolean contains(Object oo)

  Tests if the argument is in this set.

  Specified by:
    `contains` in interface `Netcdf`
  Parameters:
    `oo` - some Object
  Returns:
    `true` if and only if this set contains `oo`

### getDimensions

    public DimensionSet getDimensions()

  Returns the set of dimensions associated with this, the union of those used by each of the variables.

  Specified by:
    `getDimensions` in interface `Netcdf`
  Returns:
    DimensionSet containing dimensions used by any of the variables. May be empty. Won't be null.

### getAttributes

    public AttributeSet getAttributes()

  Returns the set of attributes associated with this, also know as the "global" attributes.

  Specified by:
    `getAttributes` in interface `Netcdf`
  Returns:
    AttributeSet. May be empty. Won't be null.

### getAttribute

    public Attribute getAttribute(String name)

  Convenience function; look up global Attribute by name.

  Specified by:
    `getAttribute` in interface `Netcdf`
  Parameters:
    `name` - the name of the attribute
  Returns:
    the attribute, or null if not found

### toCdl

    public void toCdl(StringBuffer buf)

  Format as CDL.

  Parameters:
    `buf` - StringBuffer into which to write

### toString

    public String toString()

  Returns:
    a CDL string of this.

### indexOf

    int indexOf(Dimension dim)

  Used to compute 'dimension index' needed in netcdf version 1 files.

### ioFactory

    protected abstract Accessor ioFactory(ProtoVariable proto)
                                   throws InvocationTargetException

  Used when creating variables to populate this. Override in your implementation to provide the correct i/o functionality.

  Throws:
    `InvocationTargetException`

### putDimension

    protected void putDimension(Dimension dim)

  Used for incremental initialization. Add a Dimension to the Netcdf.

### putAttribute

    protected void putAttribute(Attribute attr)

  Used for incremental initialization. Add a (global) attribute to the Netcdf.

### add

    protected void add(ProtoVariable proto,
                       Accessor io)
                throws InstantiationException,
                       InvocationTargetException,
                       IllegalAccessException

  Used for incremental initialization. Add a variable to the Netcdf.

  Throws:
    `InstantiationException`
    `InvocationTargetException`
    `IllegalAccessException`

### varCtorParameterTypes

    static final Class[] varCtorParameterTypes()

  These are the parameter types used for the Variable constructor in `initHashtable(Class)`

### initHashtable

    protected void initHashtable()
                          throws InstantiationException,
                                 InvocationTargetException,
                                 IllegalAccessException

  Throws:
    `InstantiationException`
    `InvocationTargetException`
    `IllegalAccessException`

### getSchema

    Schema getSchema()