\name{typeInfo2Java} \alias{typeInfo2Java} \alias{typeInfo2Java,function-method} \alias{typeInfo2Java,genericFunction-method} \alias{typeInfo2Java,standardGeneric-method} \alias{typeInfo2Java,SimultaneousTypeSpecification-method} \alias{typeInfo2Java,IndependentTypeSpecification-method} \alias{typeInfo2Java,TypedSignature-method} \alias{typeInfo2Java,InheritsTypeTest-method} \alias{typeInfo2Java,StrictIsTypeTest-method} \alias{typeInfo2Java,DynamicTypeTest-method} \alias{typeInfo2Java,ANY-method} \alias{typeInfo2Java,character-method} \alias{typeInfo2Java,list-method} \title{Create Java-like function signatures from R functions} \description{ The \code{typeInfo2Java} methods convert functions or TypeInfo structures to a Java-like signature, without coercion to Java types. See \code{\link{createMap}} to convert functions and coerce arguments. These functions are primarily for internal use. } \usage{ typeInfo2Java(x, ...) } \arguments{ \item{x}{function with typeInfo already applied, S4 function, or any TypeInfo class.} \item{\dots}{Additional arguments specific to different methods. These are usually \code{funcName} (the name of the function) or \code{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 \code{DynamicTypeTest}, and treats \code{StrictIsTypeTest} as \code{InheritsTypeTest} (issuing a warning in the process). See \code{\link[TypeInfo]{NamedTypeTest-class}} of TypeInfo for more information. } \value{ An object of \code{\link{RJavaSignature-class}}, containing return type, function name, and argument type/name as slots with named character vectors. } \author{MT Morgan} \examples{ 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) } \keyword{programming} \keyword{documentation}