## ru.biosoft.plugins.jri.protocol
Class REXPFactory

    java.lang.Object
      ru.biosoft.plugins.jri.protocol.REXPFactory

    public class REXPFactory

extends java.lang.Object

representation of R-eXpressions in Java

Version:
  $Id: REXPFactory.java,v 1.1 2009/06/15 06:26:56 tolstyh Exp $

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
`REXPFactory()`
`REXPFactory(org.rosuda.REngine.REXP r)`

Method Summary
`org.rosuda.REngine.REXPList` | `getAttr()`
`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.
`org.rosuda.REngine.REXP` | `getREXP()`
`static int` | `getStringBinaryRepresentation(byte[] buf, int off, java.lang.String s)`
`int` | `parseREXP(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` | `xtName(int xt)` returns human-readable name of the xpression type as string.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### XT_NULL

    public static final int XT_NULL

  xpression type: NULL

  See Also:
    Constant Field Values

### XT_INT

    public static final int XT_INT

  xpression type: integer

  See Also:
    Constant Field Values

### XT_DOUBLE

    public static final int XT_DOUBLE

  xpression type: double

  See Also:
    Constant Field Values

### XT_STR

    public static final int XT_STR

  xpression type: String

  See Also:
    Constant Field Values

### XT_LANG

    public static final int XT_LANG

  xpression type: language construct (currently content is same as list)

  See Also:
    Constant Field Values

### XT_SYM

    public static final int XT_SYM

  xpression type: symbol (content is symbol name: String)

  See Also:
    Constant Field Values

### XT_BOOL

    public static final int XT_BOOL

  xpression type: RBool

  See Also:
    Constant Field Values

### XT_S4

    public static final int XT_S4

  xpression type: S4 object

  Since:
    Rserve 0.5
  See Also:
    Constant Field Values

### XT_VECTOR

    public static final int XT_VECTOR

  xpression type: generic vector (RList)

  See Also:
    Constant Field Values

### XT_LIST

    public static final int XT_LIST

  xpression type: dotted-pair list (RList)

  See Also:
    Constant Field Values

### XT_CLOS

    public static final int XT_CLOS

  xpression type: closure (there is no java class for that type (yet?). currently the body of the closure is stored in the content part of the REXP. Please note that this may change in the future!)

  See Also:
    Constant Field Values

### XT_SYMNAME

    public static final int XT_SYMNAME

  xpression type: symbol name

  Since:
    Rserve 0.5
  See Also:
    Constant Field Values

### XT_LIST_NOTAG

    public static final int XT_LIST_NOTAG

  xpression type: dotted-pair list (w/o tags)

  Since:
    Rserve 0.5
  See Also:
    Constant Field Values

### XT_LIST_TAG

    public static final int XT_LIST_TAG

  xpression type: dotted-pair list (w tags)

  Since:
    Rserve 0.5
  See Also:
    Constant Field Values

### XT_LANG_NOTAG

    public static final int XT_LANG_NOTAG

  xpression type: language list (w/o tags)

  Since:
    Rserve 0.5
  See Also:
    Constant Field Values

### XT_LANG_TAG

    public static final int XT_LANG_TAG

  xpression type: language list (w tags)

  Since:
    Rserve 0.5
  See Also:
    Constant Field Values

### XT_VECTOR_EXP

    public static final int XT_VECTOR_EXP

  xpression type: expression vector

  See Also:
    Constant Field Values

### XT_VECTOR_STR

    public static final int XT_VECTOR_STR

  xpression type: string vector

  See Also:
    Constant Field Values

### XT_ARRAY_INT

    public static final int XT_ARRAY_INT

  xpression type: int[]

  See Also:
    Constant Field Values

### XT_ARRAY_DOUBLE

    public static final int XT_ARRAY_DOUBLE

  xpression type: double[]

  See Also:
    Constant Field Values

### XT_ARRAY_STR

    public static final int XT_ARRAY_STR

  xpression type: String[] (currently not used, Vector is used instead)

  See Also:
    Constant Field Values

### XT_ARRAY_BOOL_UA

    public static final int XT_ARRAY_BOOL_UA

  internal use only! this constant should never appear in a REXP

  See Also:
    Constant Field Values

### XT_ARRAY_BOOL

    public static final int XT_ARRAY_BOOL

  xpression type: RBool[]

  See Also:
    Constant Field Values

### XT_RAW

    public static final int XT_RAW

  xpression type: raw (byte[])

  Since:
    Rserve 0.4-?
  See Also:
    Constant Field Values

### XT_ARRAY_CPLX

    public static final int XT_ARRAY_CPLX

  xpression type: Complex[]

  Since:
    Rserve 0.5
  See Also:
    Constant Field Values

### XT_UNKNOWN

    public static final int XT_UNKNOWN

  xpression type: unknown; no assumptions can be made about the content

  See Also:
    Constant Field Values

### XT_FACTOR

    public static final 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

  See Also:
    Constant Field Values

Constructor Detail

### REXPFactory

    public REXPFactory()

### REXPFactory

    public REXPFactory(org.rosuda.REngine.REXP r)
                throws org.rosuda.REngine.REXPMismatchException

Throws:
  `org.rosuda.REngine.REXPMismatchException`

Method Detail

### getREXP

    public org.rosuda.REngine.REXP getREXP()

### getAttr

    public org.rosuda.REngine.REXPList getAttr()

### parseREXP

    public int parseREXP(byte[] buf,
                         int o)
                  throws org.rosuda.REngine.REXPMismatchException

  parses byte buffer for binary representation of xpressions - read one xpression slot (descends recursively for aggregated xpressions such as lists, vectors etc.)

  Parameters:
    `buf` - buffer containing the binary representation
    `o` - offset in the buffer to start at
  Returns:
    position just behind the parsed xpression. Can be use for successive calls to `parseREXP(byte[], int)` if more than one expression is stored in the binary array.
  Throws:
    `org.rosuda.REngine.REXPMismatchException`

### getBinaryLength

    public int getBinaryLength()
                        throws org.rosuda.REngine.REXPMismatchException

  Calculates the length of the binary representation of the REXP including all headers. This is the amount of memory necessary to store the REXP via `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.

  Returns:
    length of the REXP including headers (4 or 8 bytes)
  Throws:
    `org.rosuda.REngine.REXPMismatchException`

### getBinaryRepresentation

    public int getBinaryRepresentation(byte[] buf,
                                       int off)
                                throws org.rosuda.REngine.REXPMismatchException

  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.

  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.

  Parameters:
    `buf` - buffer to store the REXP binary into
    `off` - offset of the first byte where to store the REXP
  Returns:
    the offset of the first byte behind the stored REXP
  Throws:
    `org.rosuda.REngine.REXPMismatchException`

### getStringBinaryRepresentation

    public static int getStringBinaryRepresentation(byte[] buf,
                                                    int off,
                                                    java.lang.String s)

### xtName

    public static java.lang.String xtName(int xt)

  returns human-readable name of the xpression type as string. Arrays are denoted by a trailing asterisk (*).

  Parameters:
    `xt` - xpression type
  Returns:
    name of the xpression type

Copyright © 2001-2009 Biosof.Ru. All Rights Reserved.