Using Java objects
751
In this example, the constructor takes four arguments: the first two are strings, the third is a float,
and the fourth is an integer.
Java and ColdFusion data type conversions
ColdFusion does not use explicit types for variables, while Java is strongly typed. However,
ColdFusion data does use a number of underlying types to represent data.
Under most situations, when the method names are not ambiguous, ColdFusion can determine
the data types that are required by a Java object, and often it can convert ColdFusion data to the
required types. For example, ColdFusion text strings are implicitly converted to the Java String
type. Similarly, if a Java object contains a doIt method that expects a parameter of type int, and
CFML is issuing a doIt call with a CFML variable x that contains an integer value, ColdFusion
converts the variable x to Java int type. However, ambiguous situations can result from Java
method overloading, where a class has multiple implementations of the same method that differ
only in their parameter types.
The following sections describe how ColdFusion handles the unambiguous situations, and how it
provides you with the tools to handle ambiguous ones.
Default data type conversion
Whenever possible, ColdFusion automatically matches Java types to ColdFusion types.
The following table lists how ColdFusion converts ColdFusion data values to Java data types
when passing arguments. The left column represents the underlying ColdFusion representation of
its data. The right column indicates the Java data types into which ColdFusion can automatically
convert the data:
CFML
Java
Integer
short, int, long (short and int might result in a loss of precision).
Real number
float double (float might result in a loss of precision.
Boolean
boolean
Date-time
java.util.Date
String, including lists
String
short, int, long, float, double, java.util.Date, when a CFML string represents
a number or date.
boolean, for strings with the value Yes, No, True, and False (case-
insensitive).
Array
java.util.Vector (ColdFusion Arrays are internally represented using an
instance of a java.util.Vector object.)
ColdFusion can also map a CFML array to any of the following when the
CFML array contains consistent data of a type that can be converted to
the Java array’s data type: byte[], char[], boolean[], int[], long[], float[],
double[], String[], or Object[]. When a CFML array contains data of
different of types, the conversion to a simple array type might fail.
Structure
java.util.Map
Query object
java.util.Map
Содержание ColdFusion MX
Страница 1: ...Developing ColdFusion MX Applications...
Страница 22: ...22 Contents...
Страница 38: ......
Страница 52: ...52 Chapter 2 Elements of CFML...
Страница 162: ......
Страница 218: ...218 Chapter 10 Writing and Calling User Defined Functions...
Страница 250: ...250 Chapter 11 Building and Using ColdFusion Components...
Страница 264: ...264 Chapter 12 Building Custom CFXAPI Tags...
Страница 266: ......
Страница 314: ...314 Chapter 14 Handling Errors...
Страница 344: ...344 Chapter 15 Using Persistent Data and Locking...
Страница 349: ...About user security 349...
Страница 357: ...Security scenarios 357...
Страница 370: ...370 Chapter 16 Securing Applications...
Страница 388: ...388 Chapter 17 Developing Globalized Applications...
Страница 408: ...408 Chapter 18 Debugging and Troubleshooting Applications...
Страница 410: ......
Страница 426: ...426 Chapter 19 Introduction to Databases and SQL...
Страница 476: ...476 Chapter 22 Using Query of Queries...
Страница 534: ...534 Chapter 24 Building a Search Interface...
Страница 556: ...556 Chapter 25 Using Verity Search Expressions...
Страница 558: ......
Страница 582: ...582 Chapter 26 Retrieving and Formatting Data...
Страница 668: ......
Страница 734: ...734 Chapter 32 Using Web Services...
Страница 760: ...760 Chapter 33 Integrating J2EE and Java Elements in CFML Applications...
Страница 786: ...786 Chapter 34 Integrating COM and CORBA Objects in CFML Applications...
Страница 788: ......
Страница 806: ...806 Chapter 35 Sending and Receiving E Mail...