Because there is not a one-to-one correspondence between internally stored ColdFusion types and
Java scalar types, some conversions cannot be performed.
Example
The method fooMethod in the class fooClass takes one overloaded argument. The fooClass class
is defined as follows:
public class fooClass {
public fooClass () {
}
public String fooMethod(String arg) {
return "Argument was a String";
}
public String fooMethod(int arg) {
return "Argument was an Integer";
}
}
Within ColdFusion, you use the following code:
<cfobject
action="create"
type = "java"
class = "fooClass"
name = obj>
<!--- ColdFusion can treat this as a string or a real number --->
<cfset x = 33>
Perform an explicit cast to an int and call fooMethod:<br>
<cfset myInt = JavaCast("int", x)>
<cfoutput>#obj.fooMethod(myInt)#</cfoutput>
<br><br>
Perform an explicit cast to a string and call fooMethod:<br>
<cfset myString = javaCast("String", x)>
<cfoutput>#obj.fooMethod(myString)#</cfoutput>
704
Chapter 3: ColdFusion Functions