Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://angel.cs.msu.su/projects/system/toolsdoc/netcdf_java/ucar/netcdf/Variable.html
Дата изменения: Tue Dec 28 20:59:06 2004 Дата индексирования: Sun Apr 10 00:13:33 2016 Кодировка: |
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ucar.netcdf.Variable
Variable is a (potentially large) multi-dimensional array of primitives. The dimensions are named, allowing relationships between Variables to be expressed. Variables have names and may have descriptive attributes.
Objects which implement this interface exist in the context of a particular Netcdf data set. If you factor out the data access methods of this interface, leaving the descriptive "meta" information, what remains is a ProtoVariable.
Although there is no explicit relationship between this interface and class ProtoVariable, they share common method signatures and semantics where appropriate.
ProtoVariable
,
MultiArray
Constructor Summary | |
Variable(ProtoVariable proto,
Accessor io)
The usual constructor. |
Method Summary | |
void |
copyin(int[] origin,
MultiArray data)
Aggregate write access. |
MultiArray |
copyout(int[] origin,
int[] shape)
Aggregate read access. |
java.lang.Object |
get(int[] index)
Get (read) the array element at index. |
Attribute |
getAttribute(java.lang.String name)
Convenience function; look up Attribute by name. |
AttributeSet |
getAttributes()
Returns the set of attributes associated with this. |
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. |
java.lang.Class |
getComponentType()
Returns the Class object representing the component type of the array. |
DimensionIterator |
getDimensionIterator()
Returns a DimensionIterator of the dimensions used by this variable. |
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. |
int[] |
getLengths()
Discover the dimensions of this MultiArray. |
long |
getLong(int[] index)
Get the array element at index, as a long. |
java.lang.String |
getName()
Returns the name of this Variable. |
int |
getRank()
Returns the number of dimensions. |
short |
getShort(int[] index)
Get the array element at index, as a short. |
boolean |
isScalar()
Convenience interface; return true
if and only if the rank is zero. |
boolean |
isUnlimited()
Returns true if and only if the this variable can grow. |
void |
set(int[] index,
java.lang.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. |
java.lang.Object |
toArray()
Returns a new array containing all of the elements in this MultiArray. |
java.lang.Object |
toArray(java.lang.Object dst,
int[] origin,
int[] shape)
Returns an array containing elements of this MultiArray specified by origin and shape, possibly converting the component type. |
void |
toCdl(java.lang.StringBuffer buf)
Format as CDL. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Variable(ProtoVariable proto, Accessor io)
proto
- the ProtoVariable used as metadata storage.
Shouldn't be null.
It should be immutable over the lifetime of this object.
(If in doubt, hand this its own private copy.)Method Detail |
public java.lang.Class getComponentType()
getComponentType
in interface MultiArrayInfo
MultiArrayInfo.getComponentType()
public int getRank()
getRank
in interface MultiArrayInfo
MultiArrayInfo.getRank()
public int[] getLengths()
MultiArrayInfo
getLengths
in interface MultiArrayInfo
MultiArrayInfo.getLengths()
public boolean isUnlimited()
true
if and only if the this variable can grow.
This is equivalent to saying
at least one of its dimensions is unlimited.
In the current implementation, exactly one dimension, the most
slowly varying (leftmost), can be unlimited.isUnlimited
in interface MultiArrayInfo
true
iff this can growpublic boolean isScalar()
true
if and only if the rank is zero.isScalar
in interface MultiArrayInfo
true
iff rank == 0public java.lang.String getName()
getName
in interface ucar.netcdf.Named
public DimensionIterator getDimensionIterator()
DimensionIterator
public AttributeSet getAttributes()
public Attribute getAttribute(java.lang.String name)
name
- the name of the attributepublic java.lang.Object get(int[] index) throws java.io.IOException
Accessor
get
in interface Accessor
ucar.multiarray.Accessor
index
- MultiArray indexindex
NullPointerException
- If the argument is null.java.lang.IllegalArgumentException
- If the array length of index is
too smalljava.lang.ArrayIndexOutOfBoundsException
- If an index component
argument is negative, or if it is greater than or equal to the
corresponding dimension length.public boolean getBoolean(int[] index) throws java.io.IOException
Accessor
getBoolean
in interface Accessor
ucar.multiarray.Accessor
Accessor.get(int[])
public char getChar(int[] index) throws java.io.IOException
Accessor
getChar
in interface Accessor
ucar.multiarray.Accessor
Accessor.get(int[])
public byte getByte(int[] index) throws java.io.IOException
Accessor
getByte
in interface Accessor
ucar.multiarray.Accessor
Accessor.get(int[])
public short getShort(int[] index) throws java.io.IOException
Accessor
getShort
in interface Accessor
ucar.multiarray.Accessor
Accessor.get(int[])
public int getInt(int[] index) throws java.io.IOException
Accessor
getInt
in interface Accessor
ucar.multiarray.Accessor
Accessor.get(int[])
public long getLong(int[] index) throws java.io.IOException
Accessor
getLong
in interface Accessor
ucar.multiarray.Accessor
Accessor.get(int[])
public float getFloat(int[] index) throws java.io.IOException
Accessor
getFloat
in interface Accessor
ucar.multiarray.Accessor
Accessor.get(int[])
public double getDouble(int[] index) throws java.io.IOException
Accessor
getDouble
in interface Accessor
ucar.multiarray.Accessor
Accessor.get(int[])
public void set(int[] index, java.lang.Object value) throws java.io.IOException
Accessor
set
in interface Accessor
ucar.multiarray.Accessor
index
- MultiArray indexvalue
- the new value.NullPointerException
- If the index argument is null, or
if the array has a primitive component type and the value argument is
nulljava.lang.IllegalArgumentException
- If the array length of index is
too smalljava.lang.ArrayIndexOutOfBoundsException
- If an index component
argument is negative, or if it is greater than or equal to the
corresponding dimension length.public void setBoolean(int[] index, boolean value) throws java.io.IOException
Accessor
setBoolean
in interface Accessor
ucar.multiarray.Accessor
Accessor.set(int[], java.lang.Object)
public void setChar(int[] index, char value) throws java.io.IOException
Accessor
setChar
in interface Accessor
ucar.multiarray.Accessor
Accessor.set(int[], java.lang.Object)
public void setByte(int[] index, byte value) throws java.io.IOException
Accessor
setByte
in interface Accessor
ucar.multiarray.Accessor
Accessor.set(int[], java.lang.Object)
public void setShort(int[] index, short value) throws java.io.IOException
Accessor
setShort
in interface Accessor
ucar.multiarray.Accessor
Accessor.set(int[], java.lang.Object)
public void setInt(int[] index, int value) throws java.io.IOException
Accessor
setInt
in interface Accessor
ucar.multiarray.Accessor
Accessor.set(int[], java.lang.Object)
public void setLong(int[] index, long value) throws java.io.IOException
Accessor
setLong
in interface Accessor
ucar.multiarray.Accessor
Accessor.set(int[], java.lang.Object)
public void setFloat(int[] index, float value) throws java.io.IOException
Accessor
setFloat
in interface Accessor
ucar.multiarray.Accessor
Accessor.set(int[], java.lang.Object)
public void setDouble(int[] index, double value) throws java.io.IOException
Accessor
setDouble
in interface Accessor
ucar.multiarray.Accessor
Accessor.set(int[], java.lang.Object)
public MultiArray copyout(int[] origin, int[] shape) throws java.io.IOException
Accessor
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]);
copyout
in interface Accessor
ucar.multiarray.Accessor
origin
- int array specifying the starting index.shape
- int array specifying the extents in each
dimension. This becomes the shape of the return.public void copyin(int[] origin, MultiArray data) throws java.io.IOException
Accessor
Hopefully this member can be optimized in various situations.
assert(origin[ii] + (source.getLengths())[ii]
<= (getLengths())[ii]);
copyin
in interface Accessor
ucar.multiarray.Accessor
origin
- int array specifying the starting index.source
- MultiArray with the same componentType as
this and shape smaller than
this.getLengths() - origin
public java.lang.Object toArray() throws java.io.IOException
Accessor
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);
toArray
in interface Accessor
ucar.multiarray.Accessor
public java.lang.Object toArray(java.lang.Object dst, int[] origin, int[] shape) throws java.io.IOException
Accessor
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
toArray
in interface Accessor
ucar.multiarray.Accessor
public void toCdl(java.lang.StringBuffer buf)
buf
- StringBuffer into which to writepublic java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |