converters: Convert between R objects and their Java representation.

Description Usage Arguments Details Value Author(s) References See Also

Description

These functions are not intended for the end user. They are used to match objects being translated between R and Java to functions that perform the conversion. They are useful for understanding the overall conversion process, and as examples for writing custom conversions.

Usage

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# 'robject' converters
cvtCharacterFromJava(x, thisClassName)
cvtCharacterToJava(x, ...)
matchCharacterToJava(x, ...)

cvtIntegerFromJava(x, thisClassName)
cvtIntegerToJava(x, ...)
matchIntegerToJava(x, ...)

cvtLogicalFromJava(x, thisClassName)
cvtLogicalToJava(x, ...)
matchLogicalToJava(x, ...)

cvtNumericFromJava(x, thisClassName)
cvtNumericToJava(x, ...)
matchNumericToJava(x, ...)

cvtRawFromJava(x, thisClassName)
cvtRawToJava(x, ...)
matchRawToJava(x, ...)

cvtComplexFromJava(x, thisClassName)
cvtComplexToJava(x, ...)
matchComplexToJava(x, ...)

cvtVectorFromJava(x, thisClassName)
cvtVectorToJava(x, ...)
matchVectorToJava(x, ...)

cvtListFromJava(x, thisClassName)
cvtListToJava(x, ...)
matchListToJava(x, ...)

cvtArrayFromJava(x, thisClassName)
cvtArrayToJava(x, ...)
matchArrayToJava(x, ...)

cvtMatrixFromJava(x, thisClassName)
cvtMatrixToJava(x, ...)
matchMatrixToJava(x, ...)

cvtFactorFromJava(x, thisClassName)
cvtFactorToJava(x, ...)
matchFactorToJava(x, ...)

cvtDataFrameFromJava(x, thisClassName)
cvtDataFrameToJava(x, ...)
matchDataFrameToJava(x, ...)

cvtEnvFromJava(x, thisClassName)
cvtEnvToJava(x, ...)
matchEnvToJava(x, ...)

cvtUnknownFromJava(x, thisClassName)
cvtUnknownToJava(x, ...)
matchUnknownToJava(x, ...)

cvtFileReferencesFromJava(x, thisClassName)
cvtFileReferencesToJava(x, ...)
matchFileReferencesToJava(x, ...)

## 'javalib' converters
cvtCharacterToJava2(x, ...)
matchCharacterToJava2(x, ...)

cvtIntegerToJava2(x, ...)
matchIntegerToJava2(x, ...)

cvtLogicalToJava2(x, ...)
matchLogicalToJava2(x, ...)

cvtNumericToJava2(x, ...)
matchNumericToJava2(x, ...)

cvtRawToJava2(x, ...)
matchRawToJava2(x, ...)

cvtComplexFromJava2(x, thisClassName)
cvtComplexToJava2(x, ...)
matchComplexToJava2(x, ...)

cvtListToJava2(x, ...)
matchListToJava2(x, ...)

cvtFactorFromJava2(x, thisClassName)
cvtFactorToJava2(x, ...)
matchFactorToJava2(x, ...)

cvtDataFrameFromJava2(x, thisClassName)
cvtDataFrameToJava2(x, ...)
matchDataFrameToJava2(x, ...)

cvtCharArrayFromJava2(x, thisClassName)
cvtCharArrayToJava2(x, ...)
matchCharArrayToJava2(x, ...)

cvtIntegerArrayFromJava2(x, thisClassName)
cvtIntegerArrayToJava2(x, ...)
matchIntegerArrayToJava2(x, ...)

cvtNumericArrayFromJava2(x, thisClassName)
cvtNumericArrayToJava2(x, ...)
matchNumericArrayToJava2(x, ...)

cvtLogicalArrayFromJava2(x, thisClassName)
cvtLogicalArrayToJava2(x, ...)
matchLogicalArrayToJava2(x, ...)

cvtRawArrayFromJava2(x, thisClassName)
cvtRawArrayToJava2(x, ...)
matchRawArrayToJava2(x, ...)

cvtComplexArrayFromJava2(x, thisClassName)
cvtComplexArrayToJava2(x, ...)
matchComplexArrayToJava2(x, ...)

cvtCharMatrixFromJava2(x, thisClassName)
cvtCharMatrixToJava2(x, ...)
matchCharMatrixToJava2(x, ...)

cvtIntegerMatrixFromJava2(x, thisClassName)
cvtIntegerMatrixToJava2(x, ...)
matchIntegerMatrixToJava2(x, ...)

cvtNumericMatrixFromJava2(x, thisClassName)
cvtNumericMatrixToJava2(x, ...)
matchNumericMatrixToJava2(x, ...)

cvtLogicalMatrixFromJava2(x, thisClassName)
cvtLogicalMatrixToJava2(x, ...)
matchLogicalMatrixToJava2(x, ...)

cvtRawMatrixFromJava2(x, thisClassName)
cvtRawMatrixToJava2(x, ...)
matchRawMatrixToJava2(x, ...)

cvtComplexMatrixFromJava2(x, thisClassName)
cvtComplexMatrixToJava2(x, ...)
matchComplexMatrixToJava2(x, ...)

cvtEnvFromJava2(x, thisClassName)
cvtEnvToJava2(x, ...)
matchEnvToJava2(x, ...)

cvtFileReferencesFromJava2(x, thisClassName)
cvtFileReferencesToJava2(x, ...)
matchFileReferencesToJava2(x, ...)

Arguments

x

Either a reference to the Java object to be converted (e.g. cvtArrayFromJava), or a R object.

...

Additional arguments passed to SJava

thisClassName

Character representation of the class of the Java object that x refers to.

Details

The cvt* functions take an instance of an object of one language (R or Java) and convert it to an instance of the other language.

The match* functions take an instance of an object, and return a logical indicating whether the match criterion is satisified.

The convention used in RWebServices is to name the functions as <RObject>ToJava or <RObject>FromJava.

RWebServices installs one of two types of converters. The the function regAddonCvt installs converters for the ‘robject’ model, where R objects are represented in a hierarchy of Java objects that attempt to capture important attributes of the R instances. The mapping is as follows:

R Java
raw RRaw
logical RLogical
character RChar
integer RInteger
numeric RNumeric
complex RComplex
list RList
factor RFactor
data.frame RDataFrame
environment REnvironment
array RArray
matrix RMatrix
‘other’ RUnknown

The ‘other’ converter is invoked when no other converter matches. cvtUnknownToJava creates an instance of the Java class rservices.RUnknown to hold the class, length, and string representation (i.e., the result of print) of the contents of the R object. cvtUnknownFromJava converts rservices.RUnknown instance to a R S4 instance if the original R object is a S4 instance, otherwise the function returns a list with the same class and length as the original R object. This is likely to be very unsatisfactory.

The function regAddonCvt2 installs converters for the ‘javalib’ model, where R objects are represented by Java primitive types where possible; NA values are not permitted. The mapping is as follows:

R Java
raw byte[]
logical boolean[]
character String[]
integer int[]
numeric double[]
complex RJComplex
list Object[]
factor RJFactor
data.frame RJDataFrame
environment java.util.HashMap
‘*’Array, RJ‘*’Array
‘*’Matrix, RJ‘*’Matrix
FileReferences RJFileReferences

The ‘*’Array and ‘*’Matrix and array entries represent instances of the ArrayAndMatrix-class, which provide strong type information about the typeof elements (raw, logical, character, integer, numeric, complex) in arrays and matricies.

Value

The cvt*ToJava functions return references to Java objects. The cvt*FromJava functions return instances of R objects. match* return TRUE when the match criterion is satisfied, FALSE otherwise.

Author(s)

Nianhua Li

References

http://www.omegahat.org/RSJava/index.html

See Also

setJavaFunctionConverter, regAddonCvt, regAddonCvt2


RWebServices documentation built on Oct. 5, 2016, 4:53 a.m.