|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectucar.multiarray.ScalarMultiArray
public class 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 MultiArraypublic 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 valueMethod Detail |
---|
public java.lang.Class getComponentType()
MultiArrayInfo
getComponentType
in interface MultiArrayInfo
MultiArrayInfo.getComponentType()
public int getRank()
getRank
in interface MultiArrayInfo
MultiArrayInfo.getRank()
public int[] getLengths()
getLengths
in interface MultiArrayInfo
MultiArrayInfo.getLengths()
public boolean isUnlimited()
false
for members of this class.
isUnlimited
in interface MultiArrayInfo
false
MultiArrayInfo.isUnlimited()
public boolean isScalar()
true
for members of this class.
isScalar
in interface MultiArrayInfo
true
MultiArrayInfo.isUnlimited()
public java.lang.Object get(int[] index)
get
in interface Accessor
index
- ignored
Accessor.get(int[])
public char getChar(int[] index)
(((Character)this.get(index)).charValue();
were called.
getChar
in interface Accessor
Accessor.getChar(int[])
,
get(int[])
,
Character.charValue()
public boolean getBoolean(int[] index)
(((Boolean)this.get(index)).booleanValue();
were called.
getBoolean
in interface Accessor
Accessor.getBoolean(int[])
,
get(int[])
,
Boolean.booleanValue()
public byte getByte(int[] index)
(((Number)this.get(index)).byteValue();
were called.
getByte
in interface Accessor
Accessor.getByte(int[])
,
get(int[])
,
Number.byteValue()
public short getShort(int[] index)
(((Number)this.get(index)).shortValue();
were called.
getShort
in interface Accessor
Accessor.getShort(int[])
,
get(int[])
,
Number.shortValue()
public int getInt(int[] index)
(((Number)this.get(index)).intValue();
were called.
getInt
in interface Accessor
Accessor.getInt(int[])
,
get(int[])
,
Number.intValue()
public long getLong(int[] index)
(((Number)this.get(index)).longValue();
were called.
getLong
in interface Accessor
Accessor.getLong(int[])
,
get(int[])
,
Number.longValue()
public float getFloat(int[] index)
(((Number)this.get(index)).floatValue();
were called.
getFloat
in interface Accessor
Accessor.getFloat(int[])
,
get(int[])
,
Number.floatValue()
public double getDouble(int[] index)
(((Number)this.get(index)).doubleValue();
were called.
getDouble
in interface Accessor
Accessor.getDouble(int[])
,
get(int[])
,
Number.doubleValue()
public void set(int[] index, java.lang.Object value)
set
in interface Accessor
index
- ignoredvalue
- the replacement contentsAccessor.set(int[], java.lang.Object)
public void setBoolean(int[] index, boolean value)
setBoolean
in interface Accessor
index
- ignoredvalue
- the new valueAccessor.setBoolean(int[], boolean)
public void setChar(int[] index, char value)
setChar
in interface Accessor
index
- ignoredvalue
- the new valueAccessor.setChar(int[], char)
public void setByte(int[] index, byte value)
setByte
in interface Accessor
index
- ignoredvalue
- the new valueAccessor.setByte(int[], byte)
public void setShort(int[] index, short value)
setShort
in interface Accessor
index
- ignoredvalue
- the new valueAccessor.setShort(int[], short)
public void setInt(int[] index, int value)
setInt
in interface Accessor
index
- ignoredvalue
- the new valueAccessor.setInt(int[], int)
public void setLong(int[] index, long value)
setLong
in interface Accessor
index
- ignoredvalue
- the new valueAccessor.setLong(int[], long)
public void setFloat(int[] index, float value)
setFloat
in interface Accessor
index
- ignoredvalue
- the new valueAccessor.setFloat(int[], float)
public void setDouble(int[] index, double value)
setDouble
in interface Accessor
index
- ignoredvalue
- the new valueAccessor.setDouble(int[], double)
public MultiArray copyout(int[] origin, int[] shape)
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
origin
- int array specifying the starting index.shape
- int array specifying the extents in each
dimension. This becomes the shape of the return.
Accessor.copyout(int[], int[])
public void copyin(int[] origin, MultiArray src) 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
origin
- int array specifying the starting index.src
- MultiArray with the same componentType as
this and shape smaller than
this.getLengths() - origin
java.io.IOException
Accessor.copyin(int[], ucar.multiarray.MultiArray)
public java.lang.Object toArray()
toArray
in interface Accessor
Accessor.toArray()
public java.lang.Object toArray(java.lang.Object oo, int[] origin, int[] shape)
toArray
in interface Accessor
Accessor.toArray()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |