|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--ucar.multiarray.ScalarMultiArray
MultiArray implementation which can only contain single values, aka scalars. If you have a single object and want to wrap it in a MultiArray interface, use this class. Rank of these is always zero. The index argument to the set, setXXX, get, and getXXX is ignored.
When the component type is primitive, this class is an adapter for the appropriate java.lang primitive wrapper (Double, Float, and so on). One of the purposes of this class is to substitute for the wrappers in the MultiArray context, providing continuity of access method signature between arrays and scalars. Contrast this with the the discontinuity between java.util.reflect.Array.getDouble() and java.lang.Number.doubleValue().
MultiArray,
ArrayMultiArray| Constructor Summary | |
ScalarMultiArray(java.lang.Class theComponentType)
Construct a new ScalarMultiArray with the specified component type. |
|
ScalarMultiArray(java.lang.Class theComponentType,
java.lang.Object value)
Construct a new ScalarMultiArray with the specified component type and initialize it to the value given. |
|
ScalarMultiArray(java.lang.Object value)
Construct a new ScalarMultiArray with component type value.getClass() and initialize it to the value given. |
|
| Method Summary | |
void |
copyin(int[] origin,
MultiArray src)
Aggregate write access. |
MultiArray |
copyout(int[] origin,
int[] shape)
Aggregate read access. |
java.lang.Object |
get(int[] index)
Retrieve the object in this container. |
boolean |
getBoolean(int[] index)
As if (((Boolean)this.get(index)).booleanValue();
were called. |
byte |
getByte(int[] index)
As if (((Number)this.get(index)).byteValue();
were called. |
char |
getChar(int[] index)
As if (((Character)this.get(index)).charValue();
were called. |
java.lang.Class |
getComponentType()
Returns the Class object representing the component type of the array. |
double |
getDouble(int[] index)
As if (((Number)this.get(index)).doubleValue();
were called. |
float |
getFloat(int[] index)
As if (((Number)this.get(index)).floatValue();
were called. |
int |
getInt(int[] index)
As if (((Number)this.get(index)).intValue();
were called. |
int[] |
getLengths()
Always returns empty array for members of this class. |
long |
getLong(int[] index)
As if (((Number)this.get(index)).longValue();
were called. |
int |
getRank()
Always returns zero for members of this class. |
short |
getShort(int[] index)
As if (((Number)this.get(index)).shortValue();
were called. |
boolean |
isScalar()
Alway true for members of this class. |
boolean |
isUnlimited()
Always returns false for members of this class. |
void |
set(int[] index,
java.lang.Object value)
Set the object contained here to value. |
void |
setBoolean(int[] index,
boolean value)
Set the object contained here to a boolean value. |
void |
setByte(int[] index,
byte value)
Set the object contained here to a byte value. |
void |
setChar(int[] index,
char value)
Set the object contained here to a char value. |
void |
setDouble(int[] index,
double value)
Set the object contained here to a double value. |
void |
setFloat(int[] index,
float value)
Set the object contained here to a float value. |
void |
setInt(int[] index,
int value)
Set the object contained here to a int value. |
void |
setLong(int[] index,
long value)
Set the object contained here to a long value. |
void |
setShort(int[] index,
short value)
Set the object contained here to a short value. |
java.lang.Object |
toArray()
TODO: fishy semantics. |
java.lang.Object |
toArray(java.lang.Object oo,
int[] origin,
int[] shape)
TODO: fishy semantics. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public ScalarMultiArray(java.lang.Class theComponentType)
theComponentType - the Class object representing
the component type of the new MultiArray
public ScalarMultiArray(java.lang.Class theComponentType,
java.lang.Object value)
theComponentType - the Class object representing
the component type of the new MultiArrayvalue - the initial valuepublic ScalarMultiArray(java.lang.Object value)
value - the initial value| Method Detail |
public java.lang.Class getComponentType()
MultiArrayInfogetComponentType in interface MultiArrayInfoMultiArrayInfo.getComponentType()public int getRank()
getRank in interface MultiArrayInfoMultiArrayInfo.getRank()public int[] getLengths()
getLengths in interface MultiArrayInfoMultiArrayInfo.getLengths()public boolean isUnlimited()
false for members of this class.isUnlimited in interface MultiArrayInfofalseMultiArrayInfo.isUnlimited()public boolean isScalar()
true for members of this class.isScalar in interface MultiArrayInfotrueMultiArrayInfo.isUnlimited()public java.lang.Object get(int[] index)
get in interface Accessorindex - ignoredAccessor.get(int[])public char getChar(int[] index)
(((Character)this.get(index)).charValue();
were called.getChar in interface AccessorAccessor.getChar(int[]),
get(int[]),
java.lang.Character#charValue()public boolean getBoolean(int[] index)
(((Boolean)this.get(index)).booleanValue();
were called.getBoolean in interface AccessorAccessor.getBoolean(int[]),
get(int[]),
java.lang.Boolean#booleanValue()public byte getByte(int[] index)
(((Number)this.get(index)).byteValue();
were called.getByte in interface AccessorAccessor.getByte(int[]),
get(int[]),
Number.byteValue()public short getShort(int[] index)
(((Number)this.get(index)).shortValue();
were called.getShort in interface AccessorAccessor.getShort(int[]),
get(int[]),
Number.shortValue()public int getInt(int[] index)
(((Number)this.get(index)).intValue();
were called.getInt in interface AccessorAccessor.getInt(int[]),
get(int[]),
Number.intValue()public long getLong(int[] index)
(((Number)this.get(index)).longValue();
were called.getLong in interface AccessorAccessor.getLong(int[]),
get(int[]),
Number.longValue()public float getFloat(int[] index)
(((Number)this.get(index)).floatValue();
were called.getFloat in interface AccessorAccessor.getFloat(int[]),
get(int[]),
Number.floatValue()public double getDouble(int[] index)
(((Number)this.get(index)).doubleValue();
were called.getDouble in interface AccessorAccessor.getDouble(int[]),
get(int[]),
Number.doubleValue()
public void set(int[] index,
java.lang.Object value)
set in interface Accessorindex - ignoredvalue - the replacement contentsAccessor.set(int[], java.lang.Object)
public void setBoolean(int[] index,
boolean value)
setBoolean in interface Accessorindex - ignoredvalue - the new valueAccessor.setBoolean(int[], boolean)
public void setChar(int[] index,
char value)
setChar in interface Accessorindex - ignoredvalue - the new valueAccessor.setChar(int[], char)
public void setByte(int[] index,
byte value)
setByte in interface Accessorindex - ignoredvalue - the new valueAccessor.setByte(int[], byte)
public void setShort(int[] index,
short value)
setShort in interface Accessorindex - ignoredvalue - the new valueAccessor.setShort(int[], short)
public void setInt(int[] index,
int value)
setInt in interface Accessorindex - ignoredvalue - the new valueAccessor.setInt(int[], int)
public void setLong(int[] index,
long value)
setLong in interface Accessorindex - ignoredvalue - the new valueAccessor.setLong(int[], long)
public void setFloat(int[] index,
float value)
setFloat in interface Accessorindex - ignoredvalue - the new valueAccessor.setFloat(int[], float)
public void setDouble(int[] index,
double value)
setDouble in interface Accessorindex - ignoredvalue - the new valueAccessor.setDouble(int[], double)
public MultiArray copyout(int[] origin,
int[] shape)
AccessorIt 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 AccessorAccessor.copyout(int[], int[])
public void copyin(int[] origin,
MultiArray src)
throws java.io.IOException
AccessorHopefully this member can be optimized in various situations.
assert(origin[ii] + (source.getLengths())[ii]
<= (getLengths())[ii]);
copyin in interface AccessorAccessor.copyin(int[], ucar.multiarray.MultiArray)public java.lang.Object toArray()
toArray in interface AccessorAccessor.toArray()
public java.lang.Object toArray(java.lang.Object oo,
int[] origin,
int[] shape)
toArray in interface AccessorAccessor.toArray()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||