org.scilab.modules.types
Class ScilabTList

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<ScilabType>
              extended by org.scilab.modules.types.ScilabTList
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<ScilabType>, java.util.Collection<ScilabType>, java.util.List<ScilabType>, java.util.RandomAccess, ScilabType

public class ScilabTList
extends java.util.ArrayList<ScilabType>
implements ScilabType

This class provides a representation on the Scilab TList datatype

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

Example:
ScilabTList data = new ScilabTList();
data.add(new ScilabString("hello"));
data.add(new ScilabDouble(2));

See Also:
Scilab, Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
ScilabTList()
          Construct an empty tlist.
ScilabTList(java.lang.String varName)
          Construct an empty mlist.
ScilabTList(java.lang.String[] types)
          Construct a tlist with a specified header.
ScilabTList(java.lang.String[] types, java.util.Collection<? extends ScilabType> c)
          Construct a tlist containing the elements of the specified collection, in the order that they are returned by the specified collection's iterator.
ScilabTList(java.lang.String varName, int size)
           
 
Method Summary
 int getHeight()
          Return the height (number of elements) of the stored data
 java.lang.Object[] getSerializedObject()
          Get a serialized list; The format is the following: i) returned[0] is an array of integers containing the Scilab type (ScilabTypeEunm) of the different elements of the list.
 java.util.Map<java.lang.String,ScilabType> getTListFields()
          Get a map between the fields name and the associated ScilabType objects
 java.lang.String getTListType()
          Get the mlist type or null if none
 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 isReference()
          
 boolean isSwaped()
          Get the how the matrix is stored
 void readExternal(java.io.ObjectInput in)
           
 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.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.scilab.modules.types.ScilabType
equals, isEmpty
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

ScilabTList

public ScilabTList()
Construct an empty tlist. Note that the first element of this collection is the header used by Scilab to find each field type.


ScilabTList

public ScilabTList(java.lang.String varName)
Construct an empty mlist. Note that the first element of this collection is the header used by Scilab to find each field name.


ScilabTList

public ScilabTList(java.lang.String[] types)
Construct a tlist with a specified header.

Parameters:
types - type names of the fields.

ScilabTList

public ScilabTList(java.lang.String[] types,
                   java.util.Collection<? extends ScilabType> c)
Construct a tlist containing the elements of the specified collection, in the order that they are returned by the specified collection's iterator.

Parameters:
types - type names of the fields.
c - the collection whose elements are to be placed into this tlist.

ScilabTList

public ScilabTList(java.lang.String varName,
                   int size)
Parameters:
varName - the variable name
size - the initial list size
Method Detail

isReference

public boolean isReference()

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

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

getTListFields

public java.util.Map<java.lang.String,ScilabType> getTListFields()
Get a map between the fields name and the associated ScilabType objects

Returns:
the map

getTListType

public java.lang.String getTListType()
Get the mlist type or null if none

Returns:
the mlist type

getType

public ScilabTypeEnum getType()
Return the type of Scilab

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

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:
1 when there is data on the list, 0 otherwise.
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:
1 when there is data on the list, 0 otherwise.
See Also:
ScilabType.getWidth()

getSerializedObject

public java.lang.Object[] getSerializedObject()
Get a serialized list; The format is the following: i) returned[0] is an array of integers containing the Scilab type (ScilabTypeEunm) of the different elements of the list. ii) returned[i] for i>=1 contains the serialized form of each items.

Specified by:
getSerializedObject in interface ScilabType
Returns:
a serialized SiclabList/

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.util.AbstractCollection<ScilabType>
Returns:
the pretty-printed data
See Also:
AbstractCollection.toString()