org.nuiton.j2r.types
Class REXPAbstract

java.lang.Object
  extended by org.nuiton.j2r.types.REXPAbstract
All Implemented Interfaces:
REXP
Direct Known Subclasses:
RDataFrame, RList

public abstract class REXPAbstract
extends Object
implements REXP

Abstract class for REXP interface, in order to avoid duplicate code for attributes related methods.

Author:
couteau

Field Summary
protected  Map<String,Object> attributes
           
protected  String dataInconsistencyText
           
protected  REngine engine
           
protected  String indexExceptionText
           
protected  List<String> names
           
protected  String noVariable
           
protected  String variable
           
 
Constructor Summary
REXPAbstract()
           
 
Method Summary
protected  void checkVariable()
          Test that the variable name has been set so that the REXP can be sent to R.
 Object getAttribute(String attribute)
          Method to get the value of an attribute (there is no synchronizing with R, use the update() method to synchronize data with R before using this method if you think data may have changed.
 Map<String,Object> getAttributes()
          Method to get all the attributes of the data.frame (there is no synchronizing with R, use the update() method to synchronize data with R before using this method if you think data may have changed.
 REngine getEngine()
          Method to get the engine used by the REXP
 String getName(int x)
          Method to get the name of the ArrayList that is at this x index of the R data.frame.
 List<String> getNames()
          Method to get the names of the ArrayLists of the R data.frame.
 String getVariable()
          Method to get the variable name of the REXP
 void setAttribute(String attribute, Object value)
          Method to set the value of an attribute (there is no synchronizing with R, use the commit() method to send data to R.
 void setAttributes(Map<String,Object> attributes)
          Method to set all the attributes of the data.frame (there is no synchronizing with R, use the commit() method to send data to R.
 void setEngine(REngine engine)
          Method to set the engine used by the REXP.
 void setName(int x, String name)
          Method to assign the name of the Object at the index x.
 void setNames(List<String> names)
          Method to assign names of the complex REXP objects.
 void setVariable(String variable)
          Method to set the R expression variable name
 
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
checkX, getFrom, toRString
 

Field Detail

variable

protected String variable

attributes

protected Map<String,Object> attributes

engine

protected REngine engine

names

protected List<String> names

indexExceptionText

protected String indexExceptionText

dataInconsistencyText

protected String dataInconsistencyText

noVariable

protected String noVariable
Constructor Detail

REXPAbstract

public REXPAbstract()
Method Detail

setAttributes

public void setAttributes(Map<String,Object> attributes)
                   throws RException
Method to set all the attributes of the data.frame (there is no synchronizing with R, use the commit() method to send data to R.

Specified by:
setAttributes in interface REXP
Parameters:
attributes - a Map containing the attributes (key) and values (value) (values are a R expression, String may be rounded with escaped quote like : \"this is a R string\" ).
Throws:
RException

getAttributes

public Map<String,Object> getAttributes()
                                 throws RException
Method to get all the attributes of the data.frame (there is no synchronizing with R, use the update() method to synchronize data with R before using this method if you think data may have changed.

Specified by:
getAttributes in interface REXP
Returns:
a Map containing the attributes (key) and values (value)
Throws:
RException

getAttribute

public Object getAttribute(String attribute)
                    throws RException
Method to get the value of an attribute (there is no synchronizing with R, use the update() method to synchronize data with R before using this method if you think data may have changed.

Specified by:
getAttribute in interface REXP
Parameters:
attribute - name of the attribute
Returns:
the attribute value
Throws:
RException

setAttribute

public void setAttribute(String attribute,
                         Object value)
                  throws RException
Method to set the value of an attribute (there is no synchronizing with R, use the commit() method to send data to R.

Specified by:
setAttribute in interface REXP
Parameters:
attribute - name of the attribute
value - the value to be set (this is a R expression, String may be rounded with escaped quote like : \"this is a R string\" ).
Throws:
RException

getVariable

public String getVariable()
Method to get the variable name of the REXP

Specified by:
getVariable in interface REXP
Returns:
the variable name of the REXP in R

setVariable

public void setVariable(String variable)
                 throws RException
Method to set the R expression variable name

Parameters:
variable - the new variable name
Throws:
RException - if something wrong happen while assigning the R expression to the new variable in R.

getNames

public List<String> getNames()
                      throws RException
Method to get the names of the ArrayLists of the R data.frame.

Returns:
a ArrayList of strings containing the names of each ArrayList of the R data.frame
Throws:
RException - if an error occurs while getting back the names from R.
IndexOutOfBoundsException - when the row.names size get from R is bigger than the local data size.

getName

public String getName(int x)
               throws RException
Method to get the name of the ArrayList that is at this x index of the R data.frame.

Parameters:
x - index of the ArrayList (0 to n-1)
Returns:
the name of the ArrayList
Throws:
RException - if an error occurs while getting back the name from R.
IndexOutOfBoundsException - if the x index is out of bounds.

checkVariable

protected void checkVariable()
                      throws RException
Test that the variable name has been set so that the REXP can be sent to R.

Throws:
RException - if the variable name have not been set.

setEngine

public void setEngine(REngine engine)
               throws RException
Method to set the engine used by the REXP. The REXP is also sent to the engine.

Parameters:
engine - Engine to be set
Throws:
RException - If an error occur while assigning the list to the new REngine.

getEngine

public REngine getEngine()
Method to get the engine used by the REXP

Returns:
the engine used.

setNames

public void setNames(List<String> names)
              throws RException
Method to assign names of the complex REXP objects.

Parameters:
names - a ArrayList containing the names of the REXP.
Throws:
RException - when the names list is longer than the REXP length.

setName

public void setName(int x,
                    String name)
             throws RException
Method to assign the name of the Object at the index x.

Parameters:
x - index of the object (0 to n-1)
name - Name of the object.
Throws:
RException - if an error occur while in R


Copyright © 2006-2010 CodeLutin. All Rights Reserved.