|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.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_CPLX
xpression type: Complex[] |
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_LANG_NOTAG
xpression type: language list (w/o tags) |
static int |
XT_LANG_TAG
xpression type: language list (w tags) |
static int |
XT_LIST
xpression type: dotted-pair list (RList) |
static int |
XT_LIST_NOTAG
xpression type: dotted-pair list (w/o tags) |
static int |
XT_LIST_TAG
xpression type: dotted-pair list (w tags) |
static int |
XT_NULL
xpression type: NULL |
static int |
XT_RAW
xpression type: raw (byte[]) |
static int |
XT_S4
xpression type: S4 object |
static int |
XT_STR
xpression type: String |
static int |
XT_SYM
xpression type: symbol (content is symbol name: String) |
static int |
XT_SYMNAME
xpression type: symbol name |
static int |
XT_UNKNOWN
xpression type: unknown; no assumptions can be made about the content |
static int |
XT_VECTOR
xpression type: generic vector (RList) |
static int |
XT_VECTOR_EXP
xpression type: expression vector |
static int |
XT_VECTOR_STR
xpression type: string 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 either a string or a symbol name). |
java.lang.String[] |
asStringArray()
get content of the REXP as an array of strings (if it is a character vector). |
RList |
asVector()
Deprecated. use asList instead |
static REXP |
createDataFrame(RList l)
|
REXP |
getAttribute(java.lang.String name)
get a certain attribute |
RList |
getAttributes()
get all attributes of the REXP in the form of a list or null if the object has no attributes. |
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()
Deprecated. please use corresponding as... accessor methods |
static int |
getStringBinaryRepresentation(byte[] buf,
int off,
java.lang.String s)
|
int |
getType()
Deprecated. please use corresponding is... test methods |
boolean |
isCharacter()
tests whether this REXP is a character vector (aka string array) |
boolean |
isComplex()
tests whether this REXP is a vector of complex numbers |
boolean |
isFactor()
tests whether this REXP is a factor |
boolean |
isFalse()
returns true if the value is boolean and false |
boolean |
isList()
tests whether this REXP is a list (any type, i.e. dotted-pair list or generic vector) |
boolean |
isLogical()
tests whether this REXP is a logical vector (aka boolean array or scalar) |
boolean |
isNull()
tests whether this REXP is NULL (either a literal nil object or the payload is null ) |
boolean |
isNumeric()
tests whether this REXP is a numeric vector (double or integer array or scalar) |
boolean |
isRaw()
tests whether this REXP is a raw vector |
boolean |
isSymbol()
tests whether this REXP is a symbol |
boolean |
isTrue()
returns true if the value is boolean and true |
int |
length()
return the length on the REXP. |
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)
|
void |
setAttribute(java.lang.String name,
REXP value)
set an attribute value. |
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_S4
public static final int XT_VECTOR
public static final int XT_LIST
public static final int XT_CLOS
public static final int XT_SYMNAME
public static final int XT_LIST_NOTAG
public static final int XT_LIST_TAG
public static final int XT_LANG_NOTAG
public static final int XT_LANG_TAG
public static final int XT_VECTOR_EXP
public static final int XT_VECTOR_STR
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_RAW
public static final int XT_ARRAY_CPLX
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 RList getAttributes()
null
if the object has no attributes.
null
if there is none associatedpublic REXP getAttribute(java.lang.String name)
name
- name of the attribute
null
if the attribute doesn't exist or the attribute.public void setAttribute(java.lang.String name, REXP value)
name
- attribute namevalue
- attribute valuepublic java.lang.Object getContent()
as...
accessor methods
public int getType()
is...
test methods
public int length()
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 int getStringBinaryRepresentation(byte[] buf, int off, java.lang.String s)
public static java.lang.String xtName(int xt)
xt
- xpression type
public java.lang.String asString()
null
if the REXP is no string or symbol namepublic boolean isCharacter()
REXP
is a character vector (aka string array)
true
if this REXP is a character vectorpublic boolean isNumeric()
REXP
is a numeric vector (double or integer array or scalar)
true
if this REXP is a numeric vectorpublic boolean isSymbol()
REXP
is a symbol
true
if this REXP is a symbolpublic boolean isNull()
REXP
is NULL (either a literal nil object or the payload is null
)
true
if this REXP is NULLpublic boolean isLogical()
REXP
is a logical vector (aka boolean array or scalar)
true
if this REXP is a logical vectorpublic boolean isComplex()
REXP
is a vector of complex numbers
true
if this REXP is a vector of complex numberspublic boolean isRaw()
REXP
is a raw vector
true
if this REXP is a raw vectorpublic java.lang.String[] asStringArray()
null
if the REXP is no string or symbol namepublic int asInt()
public double asDouble()
public RList asVector()
asList
instead
asList
null
public RFactor asFactor()
RFactor
(if it is one)
RFactor
content or null
if the REXP is no factorpublic boolean isList()
REXP
is a list (any type, i.e. dotted-pair list or generic vector)
true
if this REXP is a listpublic boolean isTrue()
true
if the value is boolean and true
true
if the value is boolean and truepublic boolean isFalse()
true
if the value is boolean and false
true
if the value is boolean and falsepublic boolean isFactor()
REXP
is a factor
true
if this REXP
is a 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)
public static REXP createDataFrame(RList l)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |