[cfaussie] Re: Java inner classes
Howdy, There's an old article here on inner classes; http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_19580 Also I have seen syntax something like this, but I haven't ever tried it; cfobject type=JAVA action=Create name=xxx class=OuterThing$InnerThing Also, if you're interested I can provide you with a java wrapper class to create Lucene Fields as I've already been down that road. Cheers. On 4/26/07, Grant Straker [EMAIL PROTECTED] wrote: You do it the same way you do in Java cfset createobject(component,org.apache.lucene.document.Field:Index) I pretty sure you'll still have some problems though as CF won't recognise the static value of the Field. My experience is that with Lucene 2 you need to write a complete java wrapper and not try and do it all in CF. Grant On Apr 26, 5:34 am, Andrew Scott [EMAIL PROTECTED] wrote: Hmmm, Actually a good point, but as they are not inner classes and are constructors / methods have you tried myClass.Field(arg1); myClass.Field(arg1,arg2); ?? On 4/26/07, Adam Cameron [EMAIL PROTECTED] wrote: 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? -- Adam (PS: first posted to the Adobe CF forums:http://tinyurl.com/2r3w84) -- Senior Coldfusion Developer Aegeon Pty. Ltd.www.aegeon.com.au Phone: +613 8676 4223 Mobile: 0404 998 273 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Java inner classes
yeah, sorry Adam my example earlier should have been a $ not : between the classes. On Apr 26, 8:15 pm, MrBuzzy [EMAIL PROTECTED] wrote: Howdy, There's an old article here on inner classes;http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_19580 Also I have seen syntax something like this, but I haven't ever tried it; cfobject type=JAVA action=Create name=xxx class=OuterThing$InnerThing Also, if you're interested I can provide you with a java wrapper class to create Lucene Fields as I've already been down that road. Cheers. On 4/26/07, Grant Straker [EMAIL PROTECTED] wrote: You do it the same way you do in Java cfset createobject(component,org.apache.lucene.document.Field:Index) I pretty sure you'll still have some problems though as CF won't recognise the static value of the Field. My experience is that with Lucene 2 you need to write a complete java wrapper and not try and do it all in CF. Grant On Apr 26, 5:34 am, Andrew Scott [EMAIL PROTECTED] wrote: Hmmm, Actually a good point, but as they are not inner classes and are constructors / methods have you tried myClass.Field(arg1); myClass.Field(arg1,arg2); ?? On 4/26/07, Adam Cameron [EMAIL PROTECTED] wrote: 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? -- Adam (PS: first posted to the Adobe CF forums:http://tinyurl.com/2r3w84) -- Senior Coldfusion Developer Aegeon Pty. Ltd.www.aegeon.com.au Phone: +613 8676 4223 Mobile: 0404 998 273 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Java inner classes
Cheers all. Just some notes: 1) Andrew, I think you have misread what I asked. Yes, I pointed you @ some constructors. What you were supposed to be noting was that those constructors require arguments of type Field.Index, Field.Store, Field.TermVector, which are inner classes. Make sense now? 2) Grant's example doesn't work (in case anyone else was tempted to run with it). One's never going to get very far trying to instantiate a Java object as a component (I presume that's just a brain-fart, though), but more importantly the class-reference syntax seems wrong. Or at least it is at odds with what a few other people have come up with, and indeed it just errors. 3) MrBuzzy: cheers, that's it. The Adobe article is, however, a bit misleading in saying this: You cannot call Java inner classes directly in ColdFusion. Because, as MrBuzzy demonstrates, you can. 4) Using MrBuzzy's syntax, I see what Grant is talking about: despite creating the objects just fine, the constructor code just errors with - rather unhelpfully - An exception occurred when instantiating a java object. The cause of this exception was that: . back from CF. Accessing the objects in isolation works fine, but CF is buggering something up between instantiation and using them in the constructor. EG: cfset oIndex = createobject(java,org.apache.lucene.document.Field $Index) !--- works fine --- cfset oIndexNo = oIndex.NO !--- works fine --- cfdump var=#oIndexNo# !--- works fine, and outputs what I'd expect to see --- cfset oStoreNo = createobject(java,org.apache.lucene.document.Field $Store).NO !--- works fine --- cfdump var=#oStoreNo# !--- works fine --- cfset oDoc.add(oField.init(id, 1, oStoreNo, oIndexNo)) !--- errors as per above--- NB: using the Field(String name, Reader reader) constructor works fine, but I don't want to do that. I've yet to finish exploring this, though, and if I nut it out, I'll pass it on. I am leaning towards Grant's / MrBuzzy's suggestions of wrapping this stuff in a quick Java class, written in such a way that the methods only expect data types CF is comfortable with. All interesting stuff. Cheers again. -- Adam --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Java inner classes
[sorry didn't see your follow-up Grant, was busy writing mine] Cheers. -- Adam --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Java inner classes
Way hey! Sorted it. Once I RTFM'ed, I saw where I was going wrong: cfset oDoc.add(oField.init(id, 1, oStoreNo, oIndexNo)) And from the Java docs for field: blockquote Throws: IllegalArgumentException - in any of the following situations: * the field is neither stored nor indexed /blockquote So, yeah... that'd be why I got the error. Once I changed the Field.Store to YES, it worked. It's like pulling teeth, but I'm getting there. -- Adam --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Java inner classes
Hmmm, Actually a good point, but as they are not inner classes and are constructors / methods have you tried myClass.Field(arg1); myClass.Field(arg1,arg2); ?? On 4/26/07, Adam Cameron [EMAIL PROTECTED] wrote: 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? -- Adam (PS: first posted to the Adobe CF forums: http://tinyurl.com/2r3w84) -- Senior Coldfusion Developer Aegeon Pty. Ltd. www.aegeon.com.au Phone: +613 8676 4223 Mobile: 0404 998 273 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Java inner classes
You do it the same way you do in Java cfset createobject(component,org.apache.lucene.document.Field:Index) I pretty sure you'll still have some problems though as CF won't recognise the static value of the Field. My experience is that with Lucene 2 you need to write a complete java wrapper and not try and do it all in CF. Grant On Apr 26, 5:34 am, Andrew Scott [EMAIL PROTECTED] wrote: Hmmm, Actually a good point, but as they are not inner classes and are constructors / methods have you tried myClass.Field(arg1); myClass.Field(arg1,arg2); ?? On 4/26/07, Adam Cameron [EMAIL PROTECTED] wrote: 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? -- Adam (PS: first posted to the Adobe CF forums:http://tinyurl.com/2r3w84) -- Senior Coldfusion Developer Aegeon Pty. Ltd.www.aegeon.com.au Phone: +613 8676 4223 Mobile: 0404 998 273 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---