typeInfo2Java: Create Java-like function signatures from R functions

Description Usage Arguments Details Value Author(s) Examples

Description

The typeInfo2Java methods convert functions or TypeInfo structures to a Java-like signature, without coercion to Java types. See createMap to convert functions and coerce arguments.

These functions are primarily for internal use.

Usage

1

Arguments

x

function with typeInfo already applied, S4 function, or any TypeInfo class.

...

Additional arguments specific to different methods. These are usually funcName (the name of the function) or args (a list of argument names)

Details

TypeInfo offers greater flexibility in type specification than can easily be implemented in Java. This function fails with DynamicTypeTest, and treats StrictIsTypeTest as InheritsTypeTest (issuing a warning in the process). See NamedTypeTest-class of TypeInfo for more information.

Value

An object of RJavaSignature-class, containing return type, function name, and argument type/name as slots with named character vectors.

Author(s)

MT Morgan

Examples

 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
library(RWebServices)

func <- function( response, predictor ) {
    if ( is.character( predictor )) 
        return( oneWayAnova( response, as.factor( predictor )))
    formula <- as.formula( substitute( response ~ predictor ))
    result <- lm( formula )
    anova( result )
}

## this indirection makes it easier to apply typeInfo
oneWayAnova <- func

typeInfo(oneWayAnova) <-
  SimultaneousTypeSpecification(
    TypedSignature(
      response = "numeric",
      predictor = "factor"),
    returnType = "anova" )

typeInfo2Java(oneWayAnova)

oneWayAnova <- func

typeInfo(oneWayAnova) <-
  SimultaneousTypeSpecification(
    TypedSignature(
      response = "numeric",
      predictor = "factor"),
    TypedSignature(
      response = "numeric",
      predictor = "character"),
    returnType = "anova" )

typeInfo2Java(oneWayAnova)


oneWayAnova <- func

typeInfo(oneWayAnova) <-
  IndependentTypeSpecification(
    response = c("numeric"),
    predictor = c( "factor", "character", "numeric" ),
    returnType = "anova"
  )

typeInfo2Java(oneWayAnova)

oneWayAnova <- func

typeInfo(oneWayAnova) <-
  SimultaneousTypeSpecification(
    TypedSignature(
      response = "numeric",
      predictor = "factor",
      returnType = "matrix"),
    TypedSignature(
      response = "numeric",
      predictor = "character"),
    returnType = "anova" )

typeInfo2Java(oneWayAnova)

oneWayAnova <- func

typeInfo(oneWayAnova) <-
  IndependentTypeSpecification(
    response = c("numeric"),
    predictor = c( "factor", "character", "numeric" ),
    returnType = c("anova")
  )

typeInfo2Java(oneWayAnova)

# Warning about StrictIsTypeTest
oneWayAnova <- func
typeInfo(oneWayAnova) <-
  IndependentTypeSpecification(
    response = StrictIsTypeTest("numeric"),
    predictor = c( "factor", "character", "numeric" ),
    returnType = c("anova")
  )
typeInfo2Java(oneWayAnova)

oneWayAnova <- func
typeInfo(oneWayAnova) <-
  IndependentTypeSpecification(
    response = "numeric",
    predictor = quote( ( length(predictor) == length(response)) && is( predictor, "factor" )),
    returnType = c("anova")
  )
typeInfo2Java(oneWayAnova)

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