• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Name

JavaCast

Synopsis

                   JavaCast(type, variable)

Casts a ColdFusion variable before being passed to an overloaded Java method. Possible entries for type include boolean, int, long, double, or string. The JavaCast( ) function can’t cast complex objects, such as query objects, arrays, and structures, nor can it cast to a super-class. The following example demonstrates how to explicitly cast a ColdFusion variable before passing it to an overloaded method within a Java object:

<cfobject type="Java" action="Create" class="MyClass" name="MyObject">
   
<cfset x=10>          
   
<!--- Cast x to a string --->
<cfset MyString = JavaCast("string",x)>
<cfset void= MyMethod(MyString)>
   
<!--- Cast x to an integer --->
<cfset MyInteger = JavaCast("int",x)>
<cfset void= MyMethod(MyInteger)>

PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint