cdm/src/main/java/ucar/nc2/Attribute.java
public Number getNumericValue(int index) {
    if ((index < 0) || (index >= nelems))
      return null;

    // LOOK can attributes be enum valued? for now, no
    switch (dataType) {
      case STRING:
        try {
          return new Double(getStringValue(index));
        } catch (NumberFormatException e) {
          return null;
        }
      case BYTE:
      case UBYTE:
        return values.getByte(index);
      case SHORT:
      case USHORT:
        return values.getShort(index);
      case INT:
      case UINT:
        return values.getInt(index);
      case FLOAT:
        return values.getFloat(index);
      case DOUBLE:
        return values.getDouble(index);
      case LONG:
      case ULONG:
        return values.getLong(index);
    }
    return null;
  }
public Number getNumericValue(int index) {
    if ((index < 0) || (index >= nelems))
      return null;

    // LOOK can attributes be enum valued? for now, no
    switch (dataType) {
      case STRING:
        try {
          return new Double(getStringValue(index));
        } catch (NumberFormatException e) {
          return null;
        }
      case BYTE:
      case UBYTE:
        return values.getByte(index);
      case SHORT:
      case USHORT:
        return values.getShort(index);
      case INT:
      case UINT:
        return values.getInt(index);
      case FLOAT:
        return values.getFloat(index);
      case DOUBLE:
        return values.getDouble(index);
      case LONG:
      case ULONG:
        return values.getLong(index);
    }
    return null;
  }
public Number getNumericValue ( int index ) { if ( ( index < 0 ) || ( index >= nelems ) ) return null ; // LOOK can attributes be enum valued? for now, no switch ( dataType ) { case STRING : try { return new Double ( getStringValue ( index ) ) ; } catch ( NumberFormatException e ) { return null ; } case BYTE : case UBYTE : return values . getByte ( index ) ; case SHORT : case USHORT : return values . getShort ( index ) ; case INT : case UINT : return values . getInt ( index ) ; case FLOAT : return values . getFloat ( index ) ; case DOUBLE : return values . getDouble ( index ) ; case LONG : case ULONG : return values . getLong ( index ) ; } return null ; }
Retrieve a numeric value by index. If it's a String, it will try to parse it as a double.

@param index the index into the value array.
@return Number <code>value[index]</code>, or null if its a non-parseable String or
the index is out of range.
Retrieve a numeric value by index . If it s a String it will try to parse it as a double .