Exception Handling - MACROMEDIA COLDFUSION 5-DEVELOPING Develop Manual

Table of Contents

Advertisement

382
Default data type conversion
Whenever possible, ColdFusion matches Java types to ColdFusion types as listed in
the following table. ColdFusion does not support direct conversion of Date/Time
variables and structures.
CFML
Character
Numeric
Boolean
Array Of Character
Array Of Numeric
Array Of Java Objects
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 VM resolves the specific method to use based on the
parameters passed in the call and their types.
In the section "Example: the Employee class," on page 378, 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
The "1" could be interpreted as string or as number, so there is no way to know
which method implementation to use. When a ColdFusion encounters such an
ambiguity, it throws a user exception.
The ColdFusion
Java type of a variable, as in the following line:
<cfset
The
the variable whose type your are setting. You can specify the following Java data
types: bool, int, long, float, double, and String.
For more information on the

Exception Handling

Use the
the CFML
example demonstrates the
emp.SetJobGrade("1")>
JavaCast
emp.SetJobGrade(JavaCast("int", "1")>
function takes two parameters: a string representing the Java data and
JavaCast
and
cftry
cfcatch
GetException
Chapter 20 Using cfobject to Invoke Component Objects
Java type
String
Int/long/float/double (depending on JavaCast)
Bool
Array of String
Array of Java (int/long/float/double)
The conversion rule depends on the Java Method
Signature (JavaCast does not help).
Array of Java Objects
function helps you resolve such issues by specifying the
function,
JavaCast
tags to can catch exceptions thrown by Java objects. Use
function to retrieve the Java exception object. The following
function.
GetException
see CFML Reference.

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 5

Table of Contents