Javacast - MACROMEDIA COLDFUSION 5 - CFML Reference

Cfml reference
Hide thumbs Also See for COLDFUSION 5 - CFML:
Table of Contents

Advertisement

480

JavaCast

Description
Indicates the data type conversion of a ColdFusion variable to pass as an argument
to an overloaded method of a Java object. It should be used only for scalar and string
arguments.
Category
String functions
JavaCast(type, variable)
Syntax
See also
CreateObject,
Parameters
Parameter
type
variable
You use
Usage
methods. If the method takes more than one overloaded argument, then you must
call
method is overloaded, because its arguments can take more than one data type, not
because the method can take a variable number of arguments.
JavaCast
The result of this function should be used only on calls to Java objects. Because there
is no one-to-one correspondence between internally stored ColdFusion types and
Java scalar types, some conversions cannot be performed.
Example
Consider that fooClass has a method fooMethod that takes a single argument, which
is overloaded as follows:
public void fooMethod(String arg);
public void fooMethod(int arg);
Within ColdFusion, you use the following code:
<cfobject type = java CLASS = fooClass name = obj>
</cfobject>
cfobject
Description
The data type to which to convert the ColdFusion variable, before
passing it to the Java method. The data types are boolean, int, long,
double, or String.
A ColdFusion variable that holds a scalar or string type.
after creating a Java object with cfobject, before calling one of its
JavaCast
for each overloaded argument.
JavaCast
cannot be used to cast between complex objects, or to cast to a super-class.
<!--- ColdFusion may treat this as a string or a real number --->
<cfset x = 33>
<!--- Perform an explicit cast to an int. --->
<cfset myInt = JavaCast("int", x)>
<cfset void = fooMethod(myInt)>
<!--- Perform an explicit cast to a string. --->
<cfset myString = javaCast("String", x)>
<cfset void = fooMethod(myString)>
Chapter 3 ColdFusion Functions
should be used only when a
JavaCast

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COLDFUSION 5 - CFML and is the answer not in the manual?

This manual is also suitable for:

Coldfusion 5

Table of Contents