public class REXP extends Object
xp reference and RNI methods.| Modifier and Type | Field and Description |
|---|---|
static int |
ANYSXP |
static int |
BCODESXP |
static int |
BUILTINSXP |
static int |
CHARSXP |
static int |
CLOSXP |
static int |
CPLXSXP |
static int |
DOTSXP |
static int |
ENVSXP |
static int |
EXPRSXP |
static int |
EXTPTRSXP |
static int |
FUNSXP |
static int |
INTSXP |
static int |
LANGSXP |
static int |
LGLSXP |
static int |
LISTSXP |
static int |
NILSXP |
static int |
PROMSXP |
static int |
RAWSXP |
static int |
REALSXP |
int |
rtype
native type of the represented expression (see ...SXP constants in R).
|
static int |
S4SXP |
static int |
SPECIALSXP |
static int |
STRSXP |
static int |
SYMSXP |
static int |
VECSXP |
static int |
WEAKREFSXP |
long |
xp
native reference to the SEXP represented in R.
|
static int |
XT_ARRAY_BOOL
xpression type: RBool[]
|
static int |
XT_ARRAY_BOOL_INT
xpression type: int[] to be interpreted as boolean
|
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_NONE
xpression type: pure reference, no internal type conversion performed
|
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 and Description |
|---|
REXP()
construct a new, empty (NULL) expression w/o attribute
|
REXP(boolean[] val)
construct new expression with the contents of a boolean vector
|
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,
Object o)
construct a new xpression of type t and content o, but no attribute
|
REXP(int t,
Object o,
REXP at)
construct a new xpression of type t, content o and attribute at
|
REXP(Rengine re,
long exp)
create a REXP directly from a R SEXP reference.
|
REXP(Rengine re,
long exp,
boolean convert) |
REXP(String[] val)
construct a new xpression of type XT_ARRAY_INT and content val
|
| Modifier and Type | Method and Description |
|---|---|
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 the contents is a list or a generic vector |
double[][] |
asMatrix()
this is just an alias for
asDoubleMatrix(). |
String |
asString()
return the first element of a character vector if this REXP is a character vector of length 1 or more, return
null otherwise |
String[] |
asStringArray()
return the contents of this REXP as an array of strings if this REXP is a character vector, return
null otherwise |
String |
asSymbolName()
return the name of the symbol represented by this REXP if is it a symbol or
null otherwise |
RVector |
asVector()
get content of the REXP as
Vector (if it is one) |
protected void |
finalize() |
REXP |
getAttribute(String name)
retrieve a specific attribute.
|
REXP |
getAttributes()
get attributes of the REXP.
|
Object |
getContent()
get raw content.
|
int |
getType()
get xpression type (see XT_.. constants) of the content.
|
static String |
quoteString(String s) |
String |
toString()
displayable contents of the expression.
|
static String |
xtName(int xt)
returns human-readable name of the xpression type as string.
|
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_ARRAY_BOOL_INT
public static final int XT_UNKNOWN
public static final int XT_NONE
public static final int XT_FACTOR
public static final int NILSXP
public static final int SYMSXP
public static final int LISTSXP
public static final int CLOSXP
public static final int ENVSXP
public static final int PROMSXP
public static final int LANGSXP
public static final int SPECIALSXP
public static final int BUILTINSXP
public static final int CHARSXP
public static final int LGLSXP
public static final int INTSXP
public static final int REALSXP
public static final int CPLXSXP
public static final int STRSXP
public static final int DOTSXP
public static final int ANYSXP
public static final int VECSXP
public static final int EXPRSXP
public static final int BCODESXP
public static final int EXTPTRSXP
public static final int WEAKREFSXP
public static final int RAWSXP
public static final int S4SXP
public static final int FUNSXP
public long xp
public int rtype
public REXP(Rengine re, long exp)
public REXP(Rengine re, long exp, boolean convert)
public REXP()
public REXP(int t,
Object o)
t - xpression type (XT_...)o - contentpublic REXP(int t,
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(String[] val)
val - array of integers to store in the REXPpublic REXP(boolean[] val)
val - contentsprotected void finalize()
throws Throwable
public REXP getAttributes()
null if there is none associatedgetAttribute() but should be avoided if possible - use getAttribute(String) instead.public REXP getAttribute(String name)
name - name of the attributenull if the attribute doesn't exist. The conversion flag is inherited from this REXP.public Object getContent()
public int getType()
public String asString()
null otherwisepublic String asSymbolName()
null otherwisepublic String[] asStringArray()
null otherwisepublic int asInt()
public double asDouble()
public RVector 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 the contents is a list or a generic vectorRList content or null if the REXP is neither a list nor a generic vectorpublic 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. This method can be also used
to access a logical array in its integer form (0=FALSE, 1=TRUE, 2=NA).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 String toString()
public static String xtName(int xt)
xt - xpression typeCopyright © 2017. All rights reserved.