org.nuiton.j2r.types
Class RList

java.lang.Object
  extended by org.nuiton.j2r.types.REXPAbstract
      extended by org.nuiton.j2r.types.RList
All Implemented Interfaces:
REXP

public class RList
extends REXPAbstract
implements REXP

Java implementation of the R List.

Author:
couteau

Field Summary
 
Fields inherited from class org.nuiton.j2r.types.REXPAbstract
attributes, dataInconsistencyText, engine, indexExceptionText, names, noVariable, variable
 
Constructor Summary
RList(java.util.List<java.lang.String> names, java.util.List<java.lang.Object> data, REngine engine, java.lang.String variable)
          Create the RList with parameters and initialize it in R.
RList(REngine engine)
          Create a default RList linked to a R engine (the List is not initialized in R.)
RList(java.lang.String[] names, java.util.List<java.lang.Object> data, REngine engine, java.lang.String variable)
          Create the RList with parameters and initialize it in R.
 
Method Summary
 void checkX(int x)
          Method that check if the index is inside the REXP bounds.
 java.lang.Object get(int x)
          Method to get the object located at the [x] coordinate.
 java.util.List<java.lang.Object> getData()
          Method to get the elements of the R list (there is no synchronizing with R).
 void getFrom(java.lang.String variable)
          Method to get a list from a variable in R.
 void set(int x, java.lang.Object data)
          Method to set the xth object of the list to a value.
 void setData(java.util.List<java.lang.Object> data)
          Method to assign the data of the R list.
 java.lang.String toRString()
          Method to export the list in a String for evaluation in R.
 
Methods inherited from class org.nuiton.j2r.types.REXPAbstract
checkVariable, getAttribute, getAttributes, getEngine, getName, getNames, getVariable, setAttribute, setAttributes, setEngine, setName, setNames, setVariable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.nuiton.j2r.types.REXP
getAttribute, getAttributes, getVariable, setAttribute, setAttributes
 

Constructor Detail

RList

public RList(REngine engine)
Create a default RList linked to a R engine (the List is not initialized in R.)

Parameters:
engine - the R engine in which to assign the RList.

RList

public RList(java.util.List<java.lang.String> names,
             java.util.List<java.lang.Object> data,
             REngine engine,
             java.lang.String variable)
      throws RException
Create the RList with parameters and initialize it in R.

Parameters:
names - the names of each object of the list.
data - the list of the objects that compound the RList.
engine - the R engine in which to assign the RList.
variable - the variable name in R.
Throws:
RException - if an error occur while initializing the list in R.

RList

public RList(java.lang.String[] names,
             java.util.List<java.lang.Object> data,
             REngine engine,
             java.lang.String variable)
      throws RException
Create the RList with parameters and initialize it in R.

Parameters:
names - the names of each object of the list.
data - the list of the objects that compound the RList.
engine - the R engine in which to assign the RList.
variable - the variable name in R.
Throws:
RException - if an error occur while initializing the list in R.
Method Detail

toRString

public java.lang.String toRString()
                           throws RException
Method to export the list in a String for evaluation in R.

Specified by:
toRString in interface REXP
Returns:
a R string representation of the list to create it in R.
Throws:
RException - If no variable name is given

set

public void set(int x,
                java.lang.Object data)
         throws RException
Method to set the xth object of the list to a value.

Parameters:
x - x coordinate (from 0 to size-1)
data - value to set
Throws:
RException - if no variable name has been given to the list

get

public java.lang.Object get(int x)
                     throws RException
Method to get the object located at the [x] coordinate.

Parameters:
x - x coordinates (between 0 and size-1)
Returns:
the Object located at the [x] coordinate
Throws:
RException - if no variable name has been given to the list

getData

public java.util.List<java.lang.Object> getData()
Method to get the elements of the R list (there is no synchronizing with R).

Returns:
a List containing the elements of the R list.

setData

public void setData(java.util.List<java.lang.Object> data)
             throws RException
Method to assign the data of the R list.

Parameters:
data - a List of Objects, containing each element of the R list
Throws:
RException

getFrom

public void getFrom(java.lang.String variable)
             throws RException
Method to get a list from a variable in R.

Specified by:
getFrom in interface REXP
Parameters:
variable - name of the data.frame in R
engine - a REngine where the R session is located.
Throws:
RException

checkX

public void checkX(int x)
Method that check if the index is inside the REXP bounds.

Specified by:
checkX in interface REXP
Parameters:
x - index


Copyright © 2006-2009 CodeLutin. All Rights Reserved.