## ucar.multiarray
Class AbstractAccessor

    java.lang.Object
      ucar.multiarray.AbstractAccessor

All Implemented Interfaces:
  Accessor

Direct Known Subclasses:
  NetcdfFile.V1Io

public abstract class AbstractAccessor
extends Object
implements Accessor

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

A minimal concrete implementation would provide concrete implementations `Object get(int [] index)`, `Object copyout(int [] origin, int [] shape)`, `set(int [] index, Object value)`. `copyin(int [] index, MultiArray value)`.

See Also:
  `Accessor`

Constructor Summary
`AbstractAccessor()`

Method Summary
`static void` `copy(Accessor src, int[] src_limits, Accessor dst, int[] dst_pos)` Used to implement copyin.
`void` `copyin(int[] origin, MultiArray data)` You almost always want to override this
`static void` `copyO(Accessor src, int[] src_pos, Accessor dst, int[] dst_limits)` Used to implement copyout.
`abstract MultiArray` `copyout(int[] origin, int[] shape)` Aggregate read access.
`abstract Object` `get(int[] index)` Get (read) the array element at index.
`boolean` `getBoolean(int[] index)` Get the array element at index, as a boolean.
`byte` `getByte(int[] index)` Get the array element at index, as a byte.
`char` `getChar(int[] index)` Get the array element at index, as a char.
`double` `getDouble(int[] index)` Get the array element at index, as a double.
`float` `getFloat(int[] index)` Get the array element at index, as a float.
`int` `getInt(int[] index)` Get the array element at index, as an int.
`long` `getLong(int[] index)` Get the array element at index, as a long.
`short` `getShort(int[] index)` Get the array element at index, as a short.
`abstract void` `set(int[] index, Object value)` Set (modify, write) the array element at index to the specified value.
`void` `setBoolean(int[] index, boolean value)` Set the array element at index to the specified boolean value.
`void` `setByte(int[] index, byte value)` Set the array element at index to the specified byte value.
`void` `setChar(int[] index, char value)` Set the array element at index to the specified char value.
`void` `setDouble(int[] index, double value)` Set the array element at index to the specified double value.
`void` `setFloat(int[] index, float value)` Set the array element at index to the specified float value.
`void` `setInt(int[] index, int value)` Set the array element at index to the specified int value.
`void` `setLong(int[] index, long value)` Set the array element at index to the specified long value.
`void` `setShort(int[] index, short value)` Set the array element at index to the specified short value.
`abstract Object` `toArray()` Returns a new array containing all of the elements in this MultiArray.
`abstract Object` `toArray(Object dst, int[] origin, int[] shape)` Returns an array containing elements of this MultiArray specified by origin and shape, possibly converting the component type.

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

Constructor Detail

### AbstractAccessor

    public AbstractAccessor()

Method Detail

### copy

    public static void copy(Accessor src,
                            int[] src_limits,
                            Accessor dst,
                            int[] dst_pos)
                     throws IOException

  Used to implement copyin.

  Parameters:
    `src` - the data source
    `src_limits` - limits on the source IndexIterator typically < ((MultiArray)src).getLengths()
    `dst` - the destination, values here are modified
    `dst_pos` - starting position in the data source
  Throws:
    `IOException`

### copyO

    public static void copyO(Accessor src,
                             int[] src_pos,
                             Accessor dst,
                             int[] dst_limits)
                      throws IOException

  Used to implement copyout.

  Parameters:
    `src` - the data source
    `src_pos` - starting position in the data source
    `dst` - the destination, values here are modified
    `dst_limits` - limits on the source IndexIterator typically < ((MultiArray)dst).getLengths()
  Throws:
    `IOException`

### get

    public abstract Object get(int[] index)
                        throws IOException

  Description copied from interface: `Accessor`
  Get (read) the array element at index. The returned value is wrapped in an object if it has a primitive type. Length of index must be greater than or equal to the rank of this. Values of index components must be less than corresponding values from getLengths().

  Specified by:
    `get` in interface `Accessor`
  Parameters:
    `index` - MultiArray index
  Returns:
    Object value at `index`
  Throws:
    `IOException`

### getBoolean

    public boolean getBoolean(int[] index)
                       throws IOException

  Description copied from interface: `Accessor`
  Get the array element at index, as a boolean.

  Specified by:
    `getBoolean` in interface `Accessor`
  Throws:
    `IOException`
  See Also:
    `Accessor.get(int[])`

### getChar

    public char getChar(int[] index)
                 throws IOException

  Description copied from interface: `Accessor`
  Get the array element at index, as a char.

  Specified by:
    `getChar` in interface `Accessor`
  Throws:
    `IOException`
  See Also:
    `Accessor.get(int[])`

### getByte

    public byte getByte(int[] index)
                 throws IOException

  Description copied from interface: `Accessor`
  Get the array element at index, as a byte.

  Specified by:
    `getByte` in interface `Accessor`
  Throws:
    `IOException`
  See Also:
    `Accessor.get(int[])`

### getShort

    public short getShort(int[] index)
                   throws IOException

  Description copied from interface: `Accessor`
  Get the array element at index, as a short.

  Specified by:
    `getShort` in interface `Accessor`
  Throws:
    `IOException`
  See Also:
    `Accessor.get(int[])`

### getInt

    public int getInt(int[] index)
               throws IOException

  Description copied from interface: `Accessor`
  Get the array element at index, as an int.

  Specified by:
    `getInt` in interface `Accessor`
  Throws:
    `IOException`
  See Also:
    `Accessor.get(int[])`

### getLong

    public long getLong(int[] index)
                 throws IOException

  Description copied from interface: `Accessor`
  Get the array element at index, as a long.

  Specified by:
    `getLong` in interface `Accessor`
  Throws:
    `IOException`
  See Also:
    `Accessor.get(int[])`

### getFloat

    public float getFloat(int[] index)
                   throws IOException

  Description copied from interface: `Accessor`
  Get the array element at index, as a float.

  Specified by:
    `getFloat` in interface `Accessor`
  Throws:
    `IOException`
  See Also:
    `Accessor.get(int[])`

### getDouble

    public double getDouble(int[] index)
                     throws IOException

  Description copied from interface: `Accessor`
  Get the array element at index, as a double.

  Specified by:
    `getDouble` in interface `Accessor`
  Throws:
    `IOException`
  See Also:
    `Accessor.get(int[])`

### set

    public abstract void set(int[] index,
                             Object value)
                      throws IOException

  Description copied from interface: `Accessor`
  Set (modify, write) the array element at index to the specified value. If the array has a primitive component type, the value may be unwrapped. Values of index components must be less than corresponding values from getLengths().

  Specified by:
    `set` in interface `Accessor`
  Parameters:
    `index` - MultiArray index
    `value` - the new value.
  Throws:
    `IOException`

### setBoolean

    public void setBoolean(int[] index,
                           boolean value)
                    throws IOException

  Description copied from interface: `Accessor`
  Set the array element at index to the specified boolean value.

  Specified by:
    `setBoolean` in interface `Accessor`
  Throws:
    `IOException`
  See Also:
    `Accessor.set(int[], java.lang.Object)`

### setChar

    public void setChar(int[] index,
                        char value)
                 throws IOException

  Description copied from interface: `Accessor`
  Set the array element at index to the specified char value.

  Specified by:
    `setChar` in interface `Accessor`
  Throws:
    `IOException`
  See Also:
    `Accessor.set(int[], java.lang.Object)`

### setByte

    public void setByte(int[] index,
                        byte value)
                 throws IOException

  Description copied from interface: `Accessor`
  Set the array element at index to the specified byte value.

  Specified by:
    `setByte` in interface `Accessor`
  Throws:
    `IOException`
  See Also:
    `Accessor.set(int[], java.lang.Object)`

### setShort

    public void setShort(int[] index,
                         short value)
                  throws IOException

  Description copied from interface: `Accessor`
  Set the array element at index to the specified short value.

  Specified by:
    `setShort` in interface `Accessor`
  Throws:
    `IOException`
  See Also:
    `Accessor.set(int[], java.lang.Object)`

### setInt

    public void setInt(int[] index,
                       int value)
                throws IOException

  Description copied from interface: `Accessor`
  Set the array element at index to the specified int value.

  Specified by:
    `setInt` in interface `Accessor`
  Throws:
    `IOException`
  See Also:
    `Accessor.set(int[], java.lang.Object)`

### setLong

    public void setLong(int[] index,
                        long value)
                 throws IOException

  Description copied from interface: `Accessor`
  Set the array element at index to the specified long value.

  Specified by:
    `setLong` in interface `Accessor`
  Throws:
    `IOException`
  See Also:
    `Accessor.set(int[], java.lang.Object)`

### setFloat

    public void setFloat(int[] index,
                         float value)
                  throws IOException

  Description copied from interface: `Accessor`
  Set the array element at index to the specified float value.

  Specified by:
    `setFloat` in interface `Accessor`
  Throws:
    `IOException`
  See Also:
    `Accessor.set(int[], java.lang.Object)`

### setDouble

    public void setDouble(int[] index,
                          double value)
                   throws IOException

  Description copied from interface: `Accessor`
  Set the array element at index to the specified double value.

  Specified by:
    `setDouble` in interface `Accessor`
  Throws:
    `IOException`
  See Also:
    `Accessor.set(int[], java.lang.Object)`

### copyout

    public abstract MultiArray copyout(int[] origin,
                                       int[] shape)
                                throws IOException

  Description copied from interface: `Accessor`
  Aggregate read access. Return a new MultiArray of the same componentType as this, and with shape as specified, which is initialized to the values of this, as clipped to (origin, origin + shape).

  It is easier to implement than to specify :-).

  The main reason to implement this instead of using the equivalent proxy is for remote or file access.

  `assert(origin[ii] + shape[ii] <= lengths[ii]);`

  Specified by:
    `copyout` in interface `Accessor`
  Parameters:
    `origin` - int array specifying the starting index.
    `shape` - int array specifying the extents in each dimension. This becomes the shape of the return.
  Returns:
    the MultiArray with the specified shape
  Throws:
    `IOException`

### copyin

    public void copyin(int[] origin,
                       MultiArray data)
                throws IOException

  You almost always want to override this

  Specified by:
    `copyin` in interface `Accessor`
  Parameters:
    `origin` - int array specifying the starting index.
    `data` - MultiArray with the same componentType as this and shape smaller than `this.getLengths() - origin`
  Throws:
    `IOException`

### toArray

    public abstract Object toArray()
                            throws IOException

  Description copied from interface: `Accessor`
  Returns a new array containing all of the elements in this MultiArray. The returned array is one dimensional. The order of the elements in the result is natural, as if we used an IndexIterator to step through the elements of this MultiArray. The component type of the result is the same as this.

  This method acts as bridge between array-based and MultiArray-based APIs.

  This method is functionally equivalent to

                      Object anArray = Array.newInstance(getComponentType(), 1);
                      int [] origin = new int[getRank()]
                      int [] shape = getDimensions();
                      return toArray(anArray, origin, shape);

  Specified by:
    `toArray` in interface `Accessor`
  Returns:
    a one dimensional Array containing all the elements in this MultiArray
  Throws:
    `IOException`

### toArray

    public abstract Object toArray(Object dst,
                                   int[] origin,
                                   int[] shape)
                            throws IOException

  Description copied from interface: `Accessor`
  Returns an array containing elements of this MultiArray specified by origin and shape, possibly converting the component type. The returned array is one dimensional. The order of the elements in the result is natural, as if we used an IndexIterator to step through the elements of this MultiArray.

  The anArray argument should be an array. If it is large enough to contain the output, it is used and no new storage is allocated. Otherwise, new storage is allocated with the same component type as the argument, and the data is copied into it.

  This method acts as bridge between array-based and MultiArray-based APIs.

  This method is similar to copyout(origin, shape).toArray(), but avoids a copy operation and (potentially) an allocation.

  NOTE: Implementation of type conversion is deferred until JDK 1.2. Currently, the componentType of `anArray` must be the same as `this`

  Specified by:
    `toArray` in interface `Accessor`
  Returns:
    a one dimensional Array containing the specified elements
  Throws:
    `IOException`