## ucar.netcdf
Class Schema

    java.lang.Object
      ucar.netcdf.Schema

All Implemented Interfaces:
  Serializable

public class Schema
extends Object
implements Serializable

Schema collects the metadata which describes or defines a Netcdf. This is a set of ProtoVariable, the DimensionSet which is the union of the Dimensions used, and any global Attributes.

Instances are used as templates in creation of new Netcdf datasets.

Variable descriptions in form of ProtoVariable instances can be added to, overwritten, or deleted from a Schema. The associated set of global attributes may also be modified.

See Also:
  `ProtoVariable`, `DimensionSet`, `AttributeSet`, `Netcdf`, `Collection`, Serialized Form

Constructor Summary
`Schema()` Create an empty Schema
`Schema(Netcdf nc)` Create a Schema initialized by an existing Netcdf.
`Schema(ProtoVariable[] varArray, Attribute[] attrArray)` Create a Schema initialized by an array of ProtoVariable and an array of Attributes.
`Schema(Schema sc)` Copy constructor.

Method Summary
`boolean` `contains(Object oo)` Tests if the argument is in this set.
`boolean` `contains(String name)` Tests if the ProtoVariable identified by `name` is in this set.
`ProtoVariable` `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) int` `indexOf(Dimension dim)`
`ProtoVariableIterator` `iterator()` Returns ProtoVariableIterator for the elements.
`ProtoVariable` `put(ProtoVariable var)` Ensures that this set contains the specified ProtoVariable.
`Attribute` `putAttribute(Attribute attr)` Convenience function; add global attribute.
`(package private) void` `putDimension(Dimension dim)`
`boolean` `remove(Object oo)` Delete the ProtoVariable specified from this set.
`boolean` `remove(String name)` Delete the ProtoVariable specified by name from this set.
`int` `size()` Returns the number of ProtoVariable objects in this set
`ProtoVariable[]` `toArray()` Returns a new Array containing the elements of this set.
`void` `toCdl(StringBuffer buf)` Format as CDL.
`String` `toString()`

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

Constructor Detail

### Schema

    public Schema()

  Create an empty Schema

### Schema

    public Schema(Schema sc)

  Copy constructor.

Parameters:
  `sc` - Schema to copy from. May be empty, shouldn't be null.

### Schema

    public Schema(Netcdf nc)

  Create a Schema initialized by an existing Netcdf.

  This would be the first step in making a copy of a Netcdf, making a partial copy, or using and existing Netcdf basis for another.

Parameters:
  `nc` - Netcdf from which to generate the Schema.

### Schema

    public Schema(ProtoVariable[] varArray,
                  Attribute[] attrArray)

  Create a Schema initialized by an array of ProtoVariable and an array of Attributes.

Parameters:
  `varArray` - ProtoVariable [] to initialize the Schema. May be null or length 0.
  `attrArray` - ProtoVariable [] to initialize the (global) Attributes. May be null or length 0.

Method Detail

### size

    public int size()

  Returns the number of ProtoVariable objects in this set

  Returns:
    int number of elements in the set

### iterator

    public ProtoVariableIterator iterator()

  Returns ProtoVariableIterator for the elements.

  Returns:
    ProtoVariableIterator for the elements.
  See Also:
    `ProtoVariableIterator`

### toArray

    public ProtoVariable[] toArray()

  Returns a new Array containing the elements of this set.

  Returns:
    a new Array containing the elements of this set.

### get

    public ProtoVariable get(String name)

  Retrieve the variable associated with the specified name.

  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 ProtoVariable identified by `name` is in this set.

  Parameters:
    `name` - String which identifies the desired variable
  Returns:
    `true` if and only if this set contains the named ProtoVariable.

### contains

    public boolean contains(Object oo)

  Tests if the argument is in this set.

  Parameters:
    `oo` - some Object
  Returns:
    `true` if and only if this set contains `oo`

### put

    public ProtoVariable put(ProtoVariable var)

  Ensures that this set contains the specified ProtoVariable. If a different ProtoVariable with the same name, was in the set, it is returned, otherwise null is returned.

  Parameters:
    `var` - the ProtoVariable to be added to this set.
  Returns:
    ProtoVariable replaced or null if not a replacement

### remove

    public boolean remove(String name)

  Delete the ProtoVariable specified by name from this set.

  Parameters:
    `name` - String identifying the ProtoVariable to be removed.
  Returns:
    true if the Set changed as a result of this call.

### remove

    public boolean remove(Object oo)

  Delete the ProtoVariable specified from this set.

  Parameters:
    `oo` - ProtoVariable to be removed.
  Returns:
    true if the Set changed as a result of this call.

### getDimensions

    public DimensionSet getDimensions()

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

  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.

  Returns:
    AttributeSet. May be empty. Won't be null.

### getAttribute

    public Attribute getAttribute(String name)

  Convenience function; look up (global) Attribute by name.

  Parameters:
    `name` - the name of the attribute
  Returns:
    the attribute, or null if not found

### putAttribute

    public Attribute putAttribute(Attribute attr)

  Convenience function; add global attribute.

  Parameters:
    `attr` - the Attribute to be added to this set.
  Returns:
    Attribute replaced or null if not a replacement
  See Also:
    `AttributeSet.put(ucar.netcdf.Attribute)`

### 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)

### putDimension

    void putDimension(Dimension dim)