User Guide

Table Of Contents
Using Java objects 935
The following table lists how ColdFusion converts data returned by Java methods to ColdFusion
data types:
Resolving ambiguous data types with the JavaCast function
You can overload Java methods so a class can have several identically named methods. At runtime,
the JVM resolves the specific method to use based on the parameters passed in the call and their
types.
In the section “The Employee class” on page 931, the Employee class has two implementations
for the SetJobGrade method. One method takes a string variable, the other an integer. If you
write code such as the following, which implementation to use is ambiguous:
<cfset emp.SetJobGrade(“1”)>
The “1” could be interpreted as a string or as a number, so there is no way to know which method
implementation to use. When ColdFusion encounters such an ambiguity, it throws a user
exception.
The ColdFusion
JavaCast function helps you resolve such issues by specifying the Java type of a
variable, as in the following line:
<cfset emp.SetJobGrade(JavaCast(“int”, “1”))>
Java CFML
boolean/Boolean Boolean
byte/Byte String
char/Char String
short/Short Integer
int/Integer Integer
long/Long Integer
float/Float Real Number
double/Double Real Number
String String
java.util.Date Date-time
java.util.List Comma-delimited list
byte[] Array
char[] Array
boolean[] Array
String[] Array
java.util.Vector Array
java.util.Map Structure