jastrachan | 15 Apr 04:47 2004

Re: documentation frustration

On 14 Apr 2004, at 23:02, Will Schenk wrote:
> I recently discovered groovy and have been playing around with in for 
> the last
> couple of days -- very cool stuff.  I was going to learn ruby but this 
> seems
> like it will be more practical.
> However, it's been a very frustating experience, mostly because I have 
> no idea
> where to look for any documentation/examples.  The archives for this 
> list are
> extremly helpful (run the latest shapshot! run the latest shapshot! ;) 
> and
> http://www.ociweb.com/jnb/jnbFeb2004.html is a good orienter, but for 
> the most
> part I'm lost.
> For example, I'm trying to get the following (reduced) snippet to work:
> import java.io.File
> import groovy.xml.MarkupBuilder
> out = new File( "out.xml" ).newWriter();
> new MarkupBuilder( out );
> This fails with a "Could not find matching constructor for class:
> groovy.xml.MarkupBuilder".  The error message could be more useful 
> i.e. what
> class is "out"?  (out.getClass().getName() -> "BufferedWriter".

Then thats the answer - its a java.io.BufferedWriter :)

> OK, so I can
> deduce my problem from this, but it seems such an ineffecient way)  
> There are
> no docs anyway to really help me figure this out: I can find
> groovy.xml.MarkupBuilder in the api docs, but where can I find 
> information on
> "java.io.File"?  (I used http://glaforge.free.fr/weblog/?itemid=74 )

The javadoc is here...


and if you look at the constructors of MarkupBuilder...


there currently isn't one that takes a BufferedWriter.

This is bad - we should probably add helper constructors for this.

However in the mean time a simple workaround is

out = new File( "out.xml" ).newPrintWriter();
new MarkupBuilder( out );

> More to the point, how am I supposed to know that a particular groovy 
> class
> reference is even different from it's eponymic java class?

Its not - its the same Java JDK class

> And for that matter, is there any real-world scripts out there that I 
> could poke
> through to mine for examples?  I'm working with the unit testing stuff 
> now but
> anything else would be interesting as well.

There's heaps of scripts in the unit test area. Other than that I'm not 
sure of good places to look

> Sorry about the rant.  It's a very cool language, I just wish someone 
> would hit
> me over the head with TFM.

:) no worries I understand your frustrations. Hopefully the above will