org.scilab.modules.types
Class ScilabInteger

java.lang.Object
  extended by org.scilab.modules.types.ScilabInteger
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, java.lang.Cloneable, ScilabType
Direct Known Subclasses:
ScilabIntegerReference

public class ScilabInteger
extends java.lang.Object
implements ScilabType

This class provides a representation on the Scilab Integer datatype

This class is Serializable and any modification could impact load and store of data (Xcos files, Javasci saved data, etc...).

Example:
byte [][]a={{32,42,41}, {12,13,32}};
ScilabInteger aMatrix = new ScilabInteger(a, true); // true = unsigned

See Also:
Scilab, Serialized Form

Field Summary
protected  boolean byref
           
protected  byte[][] byteData
           
protected  int[][] intData
           
protected  long[][] longData
           
protected  ScilabIntegerTypeEnum precision
           
protected  short[][] shortData
           
protected  boolean swaped
           
protected  java.lang.String varName
           
 
Constructor Summary
ScilabInteger()
          Default constructor
ScilabInteger(byte value)
          Constructor with single signed value
ScilabInteger(byte[][] data, boolean bUnsigned)
          Constructor with values
ScilabInteger(byte value, boolean bUnsigned)
          Constructor with single signed value
ScilabInteger(int value)
          Constructor with single signed value
ScilabInteger(int[][] data, boolean bUnsigned)
          Constructor with values
ScilabInteger(int value, boolean bUnsigned)
          Constructor with single signed value
ScilabInteger(long value)
          Constructor with single signed value
ScilabInteger(long[][] data, boolean bUnsigned)
          Constructor with values
ScilabInteger(long value, boolean bUnsigned)
          Constructor with single signed value
ScilabInteger(short value)
          Constructor with single signed value
ScilabInteger(short[][] data, boolean bUnsigned)
          Constructor with values
ScilabInteger(short value, boolean bUnsigned)
          Constructor with single signed value
ScilabInteger(java.lang.String varName, byte[][] data, boolean bUnsigned, boolean swaped)
          Constructor with values
ScilabInteger(java.lang.String varName, int[][] data, boolean bUnsigned, boolean swaped)
          Constructor with values
ScilabInteger(java.lang.String varName, long[][] data, boolean bUnsigned, boolean swaped)
          Constructor with values
ScilabInteger(java.lang.String varName, short[][] data, boolean bUnsigned, boolean swaped)
          Constructor with values
 
Method Summary
static ScilabIntegerTypeEnum convertOldType(java.lang.String typeName, boolean unsigned)
          Manage the old representation of IntegerType
 boolean equals(java.lang.Object obj)
          Compare if obj is the same object or not
 byte getByteElement(int i, int j)
          Get the byte element at position (i, j)
 java.lang.Object getCorrectData()
          Get the data as a array of arrays
 long[][] getData()
          If the precision is not 64, all values will be converted to long (attention, the convertion can be long) if precision is 64, just return the data
 byte[][] getDataAsByte()
          Returns the value as the form of byte
 int[][] getDataAsInt()
          Returns the value as the form of int
 long[][] getDataAsLong()
          Returns the value as the form of long Only for Scilab 6.X
 short[][] getDataAsShort()
          Returns the value as the form of short
 long getElement(int i, int j)
          Get the element at position (i, j) as a long
 int getHeight()
          Return the height (number of elements) of the stored data
 int getIntElement(int i, int j)
          Get the int element at position (i, j)
 long getLongElement(int i, int j)
          Get the long element at position (i, j)
 ScilabIntegerTypeEnum getPrec()
           
 java.lang.Object getRawData()
          Get the data as they are
 java.lang.Object getSerializedObject()
          Get a single object used to easily rebuild a Scilab variable from the Java ScilabType
 short getShortElement(int i, int j)
          Get the short element at position (i, j)
 ScilabTypeEnum getType()
          Return the type of Scilab
 java.lang.String getVarName()
          Get the variable name or null if it has not a name
 int getWidth()
          Return the width (number of elements) of the stored data
 boolean isEmpty()
          Check if the current instance is empty.
 boolean isReference()
          
 boolean isSwaped()
          Get the how the matrix is stored
 boolean isUnsigned()
           
 void readExternal(java.io.ObjectInput in)
           
 void setByteElement(int i, int j, byte x)
          Set the byte element at position (i, j)
 void setData(byte[][] data, boolean bUnsigned)
          Set the current values
 void setData(int[][] data, boolean bUnsigned)
          Set the current values
 void setData(long[][] data, boolean bUnsigned)
          Set the current values
 void setData(short[][] data, boolean bUnsigned)
          Set the current values
 void setElement(int i, int j, long x)
          Set the element at position (i, j)
 void setIntElement(int i, int j, int x)
          Set the int element at position (i, j)
 void setLongElement(int i, int j, long x)
          Set the long element at position (i, j)
 void setShortElement(int i, int j, short x)
          Set the short element at position (i, j)
 java.lang.String toString()
          Display the representation in the Scilab language of the type
Note that the representation can be copied/pasted straight into Scilab
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

longData

protected long[][] longData

shortData

protected short[][] shortData

intData

protected int[][] intData

byteData

protected byte[][] byteData

precision

protected ScilabIntegerTypeEnum precision

varName

protected java.lang.String varName

swaped

protected boolean swaped

byref

protected transient boolean byref
Constructor Detail

ScilabInteger

public ScilabInteger()
Default constructor


ScilabInteger

public ScilabInteger(byte[][] data,
                     boolean bUnsigned)
Constructor with values

Parameters:
data - the values
bUnsigned - true, if the values are unsigned; false if they are signed.

ScilabInteger

public ScilabInteger(short[][] data,
                     boolean bUnsigned)
Constructor with values

Parameters:
data - the values
bUnsigned - true, if the values are unsigned; false if they are signed.

ScilabInteger

public ScilabInteger(int[][] data,
                     boolean bUnsigned)
Constructor with values

Parameters:
data - the values
bUnsigned - true, if the values are unsigned; false if they are signed.

ScilabInteger

public ScilabInteger(long[][] data,
                     boolean bUnsigned)
Constructor with values

Parameters:
data - the values
bUnsigned - true, if the values are unsigned; false if they are signed.

ScilabInteger

public ScilabInteger(java.lang.String varName,
                     byte[][] data,
                     boolean bUnsigned,
                     boolean swaped)
Constructor with values

Parameters:
data - the values
bUnsigned - true, if the values are unsigned; false if they are signed.

ScilabInteger

public ScilabInteger(java.lang.String varName,
                     short[][] data,
                     boolean bUnsigned,
                     boolean swaped)
Constructor with values

Parameters:
data - the values
bUnsigned - true, if the values are unsigned; false if they are signed.

ScilabInteger

public ScilabInteger(java.lang.String varName,
                     int[][] data,
                     boolean bUnsigned,
                     boolean swaped)
Constructor with values

Parameters:
data - the values
bUnsigned - true, if the values are unsigned; false if they are signed.

ScilabInteger

public ScilabInteger(java.lang.String varName,
                     long[][] data,
                     boolean bUnsigned,
                     boolean swaped)
Constructor with values

Parameters:
data - the values
bUnsigned - true, if the values are unsigned; false if they are signed.

ScilabInteger

public ScilabInteger(byte value)
Constructor with single signed value

Parameters:
value - the unique value

ScilabInteger

public ScilabInteger(short value)
Constructor with single signed value

Parameters:
value - the unique value

ScilabInteger

public ScilabInteger(int value)
Constructor with single signed value

Parameters:
value - the unique value

ScilabInteger

public ScilabInteger(long value)
Constructor with single signed value

Parameters:
value - the unique value

ScilabInteger

public ScilabInteger(byte value,
                     boolean bUnsigned)
Constructor with single signed value

Parameters:
value - the unique value

ScilabInteger

public ScilabInteger(short value,
                     boolean bUnsigned)
Constructor with single signed value

Parameters:
value - the unique value

ScilabInteger

public ScilabInteger(int value,
                     boolean bUnsigned)
Constructor with single signed value

Parameters:
value - the unique value

ScilabInteger

public ScilabInteger(long value,
                     boolean bUnsigned)
Constructor with single signed value

Parameters:
value - the unique value
Method Detail

setData

public void setData(byte[][] data,
                    boolean bUnsigned)
Set the current values

Parameters:
data - the values to set
bUnsigned - true, if these values are unsigned; false otherwise.

setData

public void setData(short[][] data,
                    boolean bUnsigned)
Set the current values

Parameters:
data - the values to set
bUnsigned - true, if these values are unsigned; false otherwise.

setData

public void setData(int[][] data,
                    boolean bUnsigned)
Set the current values

Parameters:
data - the values to set
bUnsigned - true, if these values are unsigned; false otherwise.

setData

public void setData(long[][] data,
                    boolean bUnsigned)
Set the current values

Parameters:
data - the values to set
bUnsigned - true, if these values are unsigned; false otherwise.

getType

public ScilabTypeEnum getType()
Return the type of Scilab

Specified by:
getType in interface ScilabType
Returns:
the type of Scilab
Since:
5.4.0

getData

public long[][] getData()
If the precision is not 64, all values will be converted to long (attention, the convertion can be long) if precision is 64, just return the data

Returns:
the values

getDataAsShort

public short[][] getDataAsShort()
Returns the value as the form of short

Returns:
the values as short

getDataAsByte

public byte[][] getDataAsByte()
Returns the value as the form of byte

Returns:
the values as byte

getDataAsInt

public int[][] getDataAsInt()
Returns the value as the form of int

Returns:
the values as int

getDataAsLong

public long[][] getDataAsLong()
Returns the value as the form of long Only for Scilab 6.X

Returns:
the values as long

getPrec

public ScilabIntegerTypeEnum getPrec()
Returns:
the precision of the values

isUnsigned

public boolean isUnsigned()
Returns:
true, if the values are signed, false otherwise.

convertOldType

public static ScilabIntegerTypeEnum convertOldType(java.lang.String typeName,
                                                   boolean unsigned)
Manage the old representation of IntegerType

Parameters:
typeName - the typeName (TYPE8, TYPE16, TYPE32, TYPE64)
unsigned - unsigned or not
Returns:
the converted type to ScilabIntegerTypeEnum. null is cannot convert

getHeight

public int getHeight()
Description copied from interface: ScilabType
Return the height (number of elements) of the stored data

Specified by:
getHeight in interface ScilabType
Returns:
the height of the value matrix
See Also:
ScilabType.getHeight()

getWidth

public int getWidth()
Description copied from interface: ScilabType
Return the width (number of elements) of the stored data

Specified by:
getWidth in interface ScilabType
Returns:
the width of the value matrix
See Also:
ScilabType.getWidth()

isReference

public boolean isReference()

Specified by:
isReference in interface ScilabType
Returns:
true if data are backed in a java.nio.Buffer

isEmpty

public boolean isEmpty()
Description copied from interface: ScilabType
Check if the current instance is empty.

Specified by:
isEmpty in interface ScilabType
Returns:
true, if there is no values; false otherwise.

getVarName

public java.lang.String getVarName()
Get the variable name or null if it has not a name

Specified by:
getVarName in interface ScilabType
Returns:
the name

isSwaped

public boolean isSwaped()
Get the how the matrix is stored

Specified by:
isSwaped in interface ScilabType
Returns:
true if the matrix is stored row by row

getByteElement

public byte getByteElement(int i,
                           int j)
Get the byte element at position (i, j)

Parameters:
i - the row index
j - the column index
Returns:
a byte

getShortElement

public short getShortElement(int i,
                             int j)
Get the short element at position (i, j)

Parameters:
i - the row index
j - the column index
Returns:
a short

getIntElement

public int getIntElement(int i,
                         int j)
Get the int element at position (i, j)

Parameters:
i - the row index
j - the column index
Returns:
a int

getLongElement

public long getLongElement(int i,
                           int j)
Get the long element at position (i, j)

Parameters:
i - the row index
j - the column index
Returns:
a long

setByteElement

public void setByteElement(int i,
                           int j,
                           byte x)
Set the byte element at position (i, j)

Parameters:
i - the row index
j - the column index
x - the byte to set

setShortElement

public void setShortElement(int i,
                            int j,
                            short x)
Set the short element at position (i, j)

Parameters:
i - the row index
j - the column index
x - the short to set

setIntElement

public void setIntElement(int i,
                          int j,
                          int x)
Set the int element at position (i, j)

Parameters:
i - the row index
j - the column index
x - the int to set

setLongElement

public void setLongElement(int i,
                           int j,
                           long x)
Set the long element at position (i, j)

Parameters:
i - the row index
j - the column index
x - the long to set

getElement

public long getElement(int i,
                       int j)
Get the element at position (i, j) as a long

Parameters:
i - the row index
j - the column index
Returns:
a long

setElement

public void setElement(int i,
                       int j,
                       long x)
Set the element at position (i, j)

Parameters:
i - the row index
j - the column index
x - a long

equals

public boolean equals(java.lang.Object obj)
Description copied from interface: ScilabType
Compare if obj is the same object or not

Specified by:
equals in interface ScilabType
Overrides:
equals in class java.lang.Object
Parameters:
obj - the object we want to compare
Returns:
true if the two objects are equals, false otherwise
See Also:
ScilabType.equals(Object)

getCorrectData

public java.lang.Object getCorrectData()
Get the data as a array of arrays

Returns:
the data

getRawData

public java.lang.Object getRawData()
Get the data as they are

Returns:
the data

getSerializedObject

public java.lang.Object getSerializedObject()
Get a single object used to easily rebuild a Scilab variable from the Java ScilabType

Specified by:
getSerializedObject in interface ScilabType
Returns:
an very simple object reflecting this ScilabType.

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

toString

public java.lang.String toString()
Display the representation in the Scilab language of the type
Note that the representation can be copied/pasted straight into Scilab

Specified by:
toString in interface ScilabType
Overrides:
toString in class java.lang.Object
Returns:
the pretty-printed values
See Also:
Object.toString()