Документ взят из кэша поисковой машины. Адрес оригинального документа : http://angel.cs.msu.su/projects/system/toolsdoc/netcdf_java/ucar/netcdf/Attribute.html
Дата изменения: Tue Dec 28 20:59:06 2004
Дата индексирования: Sun Apr 10 00:14:17 2016
Кодировка:
: Class Attribute

ucar.netcdf
Class Attribute

java.lang.Object
  |
  +--ucar.netcdf.Attribute
All Implemented Interfaces:
java.lang.Cloneable, ucar.netcdf.Named, java.io.Serializable

public class Attribute
extends java.lang.Object
implements ucar.netcdf.Named, java.io.Serializable, java.lang.Cloneable

Attributes are similar to "IndexedProperties" in the lingo of java beans. They have a name, type and an array of values. The array is often of length 1, degenerating into a simple property. The array should never be length 0. An Attribute object is used to contain netcdf "metadata", like units of a measurable quantity or its valid range.

These attributes have fixed values over their lifetime; no setValue() methods are provided.

Instances which have same name and same value elements are equal. We override hashCode() and equals() to be consistent with this semantic.

See Also:
Serialized Form

Constructor Summary
Attribute(java.lang.String name, double value)
          Construct simple numeric attribute.
Attribute(java.lang.String name, java.lang.Number value)
          Construct simple numeric attribute.
Attribute(java.lang.String name, java.lang.Object theValue)
          Construct an array valued Attribute.
Attribute(java.lang.String name, java.lang.String theValue)
          Construct a string valued attribute.
 
Method Summary
 boolean equals(java.lang.Object oo)
          Instances which have same name and same value elements are equal.
 java.lang.Object get(int index)
          Retrieve indexed value.
 java.lang.Class getComponentType()
          If the value represents an array type, returns the Class object representing the component type of the array; otherwise returns null.
 int getLength()
          If the value represents an array type, returns the length of the value array; otherwise return String.length of the String value.
 java.lang.String getName()
          Returns the name of this Attribute.
 java.lang.Number getNumericValue()
          Retrieve simple numeric value.
 java.lang.Number getNumericValue(int index)
          Retrieve indexed numeric value.
 java.lang.String getStringValue()
          Retrieve String value.
 java.lang.Object getValue()
          Retrieve the value in its most general form.
 int hashCode()
          Instances which have same name and same value elements are equal.
 boolean isString()
          If the value is an instance of String, return true otherwise returns false
 void toCdl(java.lang.StringBuffer buf)
          Format as CDL.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Attribute

public Attribute(java.lang.String name,
                 java.lang.Number value)
Construct simple numeric attribute.
Parameters:
name - String which is to be the name of this Attribute
value - A Number to be the Attribute value

Attribute

public Attribute(java.lang.String name,
                 double value)
Construct simple numeric attribute.
Parameters:
name - String which is to be the name of this Attribute
value - A double to be the Attribute value

Attribute

public Attribute(java.lang.String name,
                 java.lang.String theValue)
Construct a string valued attribute. This will be seen to have component type Character.TYPE
Parameters:
name - String which is to be the name of this Attribute
theValue - The value

Attribute

public Attribute(java.lang.String name,
                 java.lang.Object theValue)
Construct an array valued Attribute. Not often used.
Parameters:
name - String which is to be the name of this Attribute
theValue - The value, an array of primitives. The primitive type must be netcdf encodeable.
Method Detail

hashCode

public int hashCode()
Instances which have same name and same value elements are equal. Overrides Object.equals() to be consistent with this semantic.
Overrides:
hashCode in class java.lang.Object
Returns:
the hash code value for this Attribute

equals

public boolean equals(java.lang.Object oo)
Instances which have same name and same value elements are equal. Overrides Object.equals() to be consistent with this semantic. TODO: test me.
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
a string representation of this

getName

public final java.lang.String getName()
Returns the name of this Attribute.
Specified by:
getName in interface ucar.netcdf.Named
Returns:
String which identifies this Attribute.

getValue

public java.lang.Object getValue()
Retrieve the value in its most general form.
Returns:
Object which is either a java.lang.String or a 1-dimensional array of primitives.
See Also:
isString()

getStringValue

public java.lang.String getStringValue()
Retrieve String value.
Returns:
String if this is a String valued attribute.
Throws:
ClassCastException - if this is not String valued.
See Also:
isString()

get

public java.lang.Object get(int index)
Retrieve indexed value.
Parameters:
index - int which is the index into the value array.
Returns:
Number value[index]

getNumericValue

public java.lang.Number getNumericValue(int index)
Retrieve indexed numeric value.
Parameters:
index - int which is the index into the value array.
Returns:
Number value[index]

getNumericValue

public java.lang.Number getNumericValue()
Retrieve simple numeric value. Equivalent to getNumericValue(0)
Returns:
Number the first element of the value array

isString

public boolean isString()
If the value is an instance of String, return true otherwise returns false
Returns:
boolean value instanceof String

getComponentType

public java.lang.Class getComponentType()
If the value represents an array type, returns the Class object representing the component type of the array; otherwise returns null.
Returns:
Class the component type
See Also:
Class.getComponentType()

getLength

public int getLength()
If the value represents an array type, returns the length of the value array; otherwise return String.length of the String value.
Returns:
int length of the value

toCdl

public void toCdl(java.lang.StringBuffer buf)
Format as CDL.
Parameters:
buf - StringBuffer into which to write