Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Advanced Techniques / April 2007



Tip: Looking for answers? Try searching our database.

Java inner classes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Adam Cameron - 25 Apr 2007 15:38 GMT
G'day
How does one - in CF - refer to an inner class (ClassFoo.Bar) of a given
class (ClassFoo), when the constructor of ClassFoo takes an argument of
type ClassFoo.Bar?

For example the first, third,fourth and fifth constructors shown here:
http://tinyurl.com/hfg9s (org.apache.lucene.document.Field).

Any ideas?

Signature

Adam

cf_dev2 - 25 Apr 2007 17:31 GMT
<cfscript>
    bar = createObject("java", "org.apache.lucene.document.Field$Store");
    foo = createObject("java", "org.apache.lucene.document.Field");
    foo.init(name, byte, bar.COMPRESS);
</cfscript>
Adam Cameron - 26 Apr 2007 11:31 GMT
That did the trick: cheers.

Signature

Adam

insuractive - 25 Apr 2007 21:22 GMT
Just out of curiosity - what does the $ represent and is the reason you can't
use another "." because it is not a property of Field?  I've never really done
anything with Java inner classes, but this seems like a syntax I'll want to
hang on to for future reference.
cf_dev2 - 25 Apr 2007 23:53 GMT
>is the reason you can't use another "." because it is not a property of Field

Thats my understanding, yes.

> what does the $ represent

Its part of the class name. It has to do with how java compiles the classes.
It creates one file for the outer class and one for the inner class. The naming
convention for inner class files is usually
"OuterClassName$InnerClassName.class". So the class name passed to
createObject() becomes

bar = createObject("java", "OuterClassName$InnerClassName");
insuractive - 26 Apr 2007 15:48 GMT
Thanks for the illumination, cf_dev2!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.