Yea, but I would have thought you would need to create an object first to
access those methods, I didn't realise you should us ethem as though they
are native CFML functions.
But I guess this is considered undocumented and unsupported right just like
calling the java runtime or service factory.
 
Russ
-----Original Message-----
From: Barney Boisvert [mailto:[EMAIL PROTECTED] 
Sent: 28 December 2005 01:44
To: CF-Talk
Subject: Re: Java substring

Every CF "thing" is a Java object.  Strings are java.lang.String, numbers
are java.lang.Double, structs are java.util.Map, arrays are java.util.List,
queries are some weird-ass CF-specific object that I believe is a
javax.sql.ResultSet, but could be mistaken.

There's an enormous amount of power lurking just under CF's hood.  But do
remember that every time you use it, you stop writing a pure-CFML app and
start writing a Java/CFML hybrid app.  Not that that's necessarily a bad
thing, just something to be careful for.

One place to watch out is in automatic type conversions.  Since CF is
*mostly* typeless, you can call mid() and pass in a number, and CF will
magically convert it to a string representation.  Won't work with
number.substring(), because a Double isn't a String.  Most people consider
this a feature of CFML, and it's a good example of a place where CFML !=
alternate Java syntax.  In code:

x = 45.6
y = mid(x, 1, 2); // yields "45"
y = x.substring(0, 2); // MethodNotFoundException

The other place to watch out is that CF uses one-based indexing (the first
char in a string is char 1), while Java uses zero-based indexing (the first
char in a string is char 0).  JavaScript also uses zero-based indexing, so
it should be familiar, but I know it's bit me a few times using Java methods
in my CFML, because it's not obviously Java.

Which brings me back to my "be careful" point.  Readability suffers when
your CFML has a lot of Java in it directly, because the person doing the
reading has to continually evaluate whether they're looking at a Java
statement or a CFML statement, as the rules are different.

cheers,
barneyb

On 12/27/05, Snake <[EMAIL PROTECTED]> wrote:
> Well there u go, learn something new every day, I didn't know you 
> could directly access java functions like that.
>

--
Barney Boisvert
[EMAIL PROTECTED]
360.319.6145
http://www.barneyb.com/

Got Gmail? I have 100 invites.



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:227743
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to