|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.rosuda.JRclient.REXP
public class REXP
representation of R-eXpressions in Java
Field Summary | |
---|---|
static int |
XT_ARRAY_BOOL
xpression type: RBool[] |
static int |
XT_ARRAY_BOOL_UA
internal use only! |
static int |
XT_ARRAY_DOUBLE
xpression type: double[] |
static int |
XT_ARRAY_INT
xpression type: int[] |
static int |
XT_ARRAY_STR
xpression type: String[] (currently not used, Vector is used instead) |
static int |
XT_BOOL
xpression type: RBool |
static int |
XT_CLOS
xpression type: closure (there is no java class for that type (yet?). |
static int |
XT_DOUBLE
xpression type: double |
static int |
XT_FACTOR
xpression type: RFactor; this XT is internally generated (ergo is does not come from Rsrv.h) to support RFactor class which is built from XT_ARRAY_INT |
static int |
XT_INT
xpression type: integer |
static int |
XT_LANG
xpression type: language construct (currently content is same as list) |
static int |
XT_LIST
xpression type: RList |
static int |
XT_NULL
xpression type: NULL |
static int |
XT_STR
xpression type: String |
static int |
XT_SYM
xpression type: symbol (content is symbol name: String) |
static int |
XT_UNKNOWN
xpression type: unknown; no assumptions can be made about the content |
static int |
XT_VECTOR
xpression type: Vector |
Constructor Summary | |
---|---|
REXP()
construct a new, empty (NULL) expression w/o attribute |
|
REXP(double[] val)
construct a new xpression of type XT_ARRAY_DOUBLE and content val |
|
REXP(int[] val)
construct a new xpression of type XT_ARRAY_INT and content val |
|
REXP(int t,
java.lang.Object o)
construct a new xpression of type t and content o, but no attribute |
|
REXP(int t,
java.lang.Object o,
REXP at)
construct a new xpression of type t, content o and attribute at |
|
REXP(java.lang.String[] val)
construct a new xpression of type XT_ARRAY_INT and content val |
Method Summary | |
---|---|
RBool |
asBool()
get content of the REXP as RBool (if it is one) |
double |
asDouble()
get content of the REXP as double (if it is one) |
double[] |
asDoubleArray()
get content of the REXP as an array of doubles. |
double[][] |
asDoubleMatrix()
returns the content of the REXP as a matrix of doubles (2D-array: m[rows][cols]). |
RFactor |
asFactor()
get content of the REXP as RFactor (if it is one) |
int |
asInt()
get content of the REXP as int (if it is one) |
int[] |
asIntArray()
get content of the REXP as an array of integers. |
RList |
asList()
get content of the REXP as RList (if it is one) |
double[][] |
asMatrix()
this is just an alias for asDoubleMatrix() . |
java.lang.String |
asString()
get content of the REXP as string (if it is one) |
java.util.Vector |
asVector()
get content of the REXP as Vector (if it is one) |
REXP |
getAttribute()
get attribute of the REXP. |
int |
getBinaryLength()
Calculates the length of the binary representation of the REXP including all headers. |
int |
getBinaryRepresentation(byte[] buf,
int off)
Stores the REXP in its binary (ready-to-send) representation including header into a buffer and returns the index of the byte behind the REXP. |
java.lang.Object |
getContent()
get raw content. |
int |
getType()
get xpression type (see XT_.. constants) of the content. |
static int |
parseREXP(REXP x,
byte[] buf,
int o)
parses byte buffer for binary representation of xpressions - read one xpression slot (descends recursively for aggregated xpressions such as lists, vectors etc.) |
static java.lang.String |
quoteString(java.lang.String s)
|
java.lang.String |
toString()
displayable contents of the expression. |
static java.lang.String |
xtName(int xt)
returns human-readable name of the xpression type as string. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int XT_NULL
public static final int XT_INT
public static final int XT_DOUBLE
public static final int XT_STR
public static final int XT_LANG
public static final int XT_SYM
public static final int XT_BOOL
public static final int XT_VECTOR
public static final int XT_LIST
public static final int XT_CLOS
public static final int XT_ARRAY_INT
public static final int XT_ARRAY_DOUBLE
public static final int XT_ARRAY_STR
public static final int XT_ARRAY_BOOL_UA
public static final int XT_ARRAY_BOOL
public static final int XT_UNKNOWN
public static final int XT_FACTOR
Constructor Detail |
---|
public REXP()
public REXP(int t, java.lang.Object o)
t
- xpression type (XT_...)o
- contentpublic REXP(int t, java.lang.Object o, REXP at)
t
- xpression typeo
- contentat
- attributepublic REXP(double[] val)
val
- array of doubles to store in the REXPpublic REXP(int[] val)
val
- array of integers to store in the REXPpublic REXP(java.lang.String[] val)
val
- array of integers to store in the REXPMethod Detail |
---|
public REXP getAttribute()
null
if there is none associatedpublic java.lang.Object getContent()
public int getType()
public static int parseREXP(REXP x, byte[] buf, int o)
x
- xpression object to store the parsed xpression inbuf
- buffer containing the binary representationo
- offset in the buffer to start at
parseREXP(org.rosuda.JRclient.REXP, byte[], int)
if more than one expression is stored in the binary array.public int getBinaryLength()
getBinaryRepresentation(byte[], int)
.
Please note that currently only XT_[ARRAY_]INT, XT_[ARRAY_]DOUBLE and XT_[ARRAY_]STR are supported! All other types will return 4 which is the size of the header.
public int getBinaryRepresentation(byte[] buf, int off)
Please note that currently only XT_[ARRAY_]INT, XT_[ARRAY_]DOUBLE and XT_[ARRAY_]STR are supported! All other types will be stored as SEXP of the length 0 without any contents.
buf
- buffer to store the REXP binary intooff
- offset of the first byte where to store the REXP
public static java.lang.String xtName(int xt)
xt
- xpression type
public java.lang.String asString()
null
if the REXP is no stringpublic int asInt()
public double asDouble()
public java.util.Vector asVector()
Vector
(if it is one)
null
if the REXP is no Vectorpublic RFactor asFactor()
RFactor
(if it is one)
RFactor
content or null
if the REXP is no factorpublic RList asList()
RList
(if it is one)
RList
content or null
if the REXP is no listpublic RBool asBool()
RBool
(if it is one)
RBool
content or null
if the REXP is no logical valuepublic double[] asDoubleArray()
null
if the REXP is not a array of doubles or integerspublic int[] asIntArray()
asDoubleArray()
NO automatic conversion is done if the content is not an array of the correct type, because there is no canonical representation of doubles as integers. A single integer is returned as an array of the length 1.
null
if the REXP is not a array of integerspublic double[][] asDoubleMatrix()
Matrix m=new Matrix(c.eval("matrix(c(1,2,3,4,5,6),2,3)").asDoubleMatrix());
null
if the contents is no 2-dimensional matrix of doublespublic double[][] asMatrix()
asDoubleMatrix()
.
public java.lang.String toString()
toString
in class java.lang.Object
public static java.lang.String quoteString(java.lang.String s)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |