org.rosuda.JRI
Class RList

java.lang.Object
  extended by org.rosuda.JRI.RList

public class RList
extends java.lang.Object

implementation of R-lists
This is rather preliminary and may change in future since it's not really proper. The point is that the parser tries to interpret lists to be of the form entry=value, where entry is stored in the "head" part, and value is stored in the "body" part. Then using at(String) it is possible to fetch "body" for a specific "head". The terminology used is partly from hash fields - "keys" are the elements in "head" and values are in "body" (see keys).

On the other hand, R uses lists to store complex internal structures, which are not parsed according to the structure - in that case "head" and "body" have to be evaluated separately according to their meaning in that context.

Version:
$Id: RList.java 2720 2007-03-15 17:35:42Z urbanek $

Field Summary
 REXP body
          xpressions containing head, body and tag.
 REXP head
          xpressions containing head, body and tag.
 REXP tag
          xpressions containing head, body and tag.
 
Constructor Summary
RList()
          constructs an empty list
RList(REXP h, REXP b)
          constructs an initialized list
RList(REXP h, REXP t, REXP b)
          constructs an initialized list
RList(RVector v)
          fake constructor to keep compatibility with Rserve (for now, will be gone soon)
 
Method Summary
 REXP at(int i)
          get element at the specified position
 REXP at(java.lang.String v)
          get xpression given a key
 REXP getBody()
          get body xpression (CDR)
 REXP getHead()
          get head xpression (CAR)
 REXP getTag()
          get tag xpression
 java.lang.String[] keys()
          returns all keys of the list
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

head

public REXP head
xpressions containing head, body and tag. The terminology is a bit misleading (for historical reasons) - head corresponds to CAR, body to CDR and finally tag is TAG.


body

public REXP body
xpressions containing head, body and tag. The terminology is a bit misleading (for historical reasons) - head corresponds to CAR, body to CDR and finally tag is TAG.


tag

public REXP tag
xpressions containing head, body and tag. The terminology is a bit misleading (for historical reasons) - head corresponds to CAR, body to CDR and finally tag is TAG.

Constructor Detail

RList

public RList()
constructs an empty list


RList

public RList(RVector v)
fake constructor to keep compatibility with Rserve (for now, will be gone soon)


RList

public RList(REXP h,
             REXP b)
constructs an initialized list

Parameters:
h - head xpression
b - body xpression

RList

public RList(REXP h,
             REXP t,
             REXP b)
constructs an initialized list

Parameters:
h - head xpression (CAR)
t - tag xpression (TAG)
b - body/tail xpression (CDR)
Method Detail

getHead

public REXP getHead()
get head xpression (CAR)

Returns:
head xpression

getBody

public REXP getBody()
get body xpression (CDR)

Returns:
body xpression

getTag

public REXP getTag()
get tag xpression

Returns:
tag xpression

at

public REXP at(java.lang.String v)
get xpression given a key

Parameters:
v - key
Returns:
xpression which corresponds to the given key or null if list is not standartized or key not found

at

public REXP at(int i)
get element at the specified position

Parameters:
i - index
Returns:
xpression at the index or null if list is not standartized or if index out of bounds

keys

public java.lang.String[] keys()
returns all keys of the list

Returns:
array containing all keys or null if list is not standartized