Pierre Thibault | 20 Jul 08:28
Picon

[groovy-user] Recursivity bug with closure?

Hello,

I think that I found a recursivity bug with closure. This code does not work:

def factoriel = { int v ->
    if (v == 0) {
        return 1
    } else {
        return v*this.factoriel(v-1)
    }
}

println factoriel(5)

But this work well:

def factoriel(int v) {
    if (v == 0) {
        return 1
    } else {
        return v*this.factoriel(v-1)
    }
}

println factoriel(5)

I've tried with Groovy 1.5.5 and 1.5.6.

Any idea?

Pierre


Yahoo! Canada Toolbar : Search from anywhere on the web and bookmark your favourite sites. Download it now!

Pierre Thibault | 19 Jul 22:48
Picon

[groovy-user] Maven Javadoc integration

Hello,

I would like to know if it is possible to use Javadoc in Groovy files and have Maven to generate the documentation. I would like to know how to do that.

Pierre

Looking for the perfect gift? Give the gift of Flickr!
Andres Almiray | 19 Jul 04:27
Picon
Favicon
Gravatar

[groovy-user] Gant + jdk5/jdk6


Hi guys,

I need to build jdk5 and jdk6 specific code and would like to use Gant for
this purpose. I'm wondering if there is a quick way to specify the target
bytecode via a 'target' property (as in regular Ant's javac target) on
groovy/groovyc. I haven't found the way yet and the workaround is rather
lengthy and well ... un-Groovy.

TIA

Andres
--

-- 
View this message in context: http://www.nabble.com/Gant-%2B-jdk5-jdk6-tp18540651p18540651.html
Sent from the groovy - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Raphaël Piéroni | 18 Jul 22:58
Picon

[groovy-user] Usage of Factory to extend SwingBuilder

Hi folks,

I'd like to enhance the SwingBuilder with s custom made factory.

I successfully had
animatedPane = panel {
                imageLabel = label(id: 'imageLabel', text: 'Image goes here')
            }
            imageTransition = animate(duration: 1000, acceleration:
0.3f, deceleration: 0.15f, component: animatedPane, closure: {
                animatedPane.removeAll()
                animatedPane.add label(icon: model.image)
                animatedPane.revalidate()
            })

in my swing builder script.

I registered a factory to animate which override newInstance only
    Object newInstance(FactoryBuilderSupport builder, def name, def
value, Map attributes) {
        def animator = new Animator(attributes.duration)
        animator.acceleration = attributes.acceleration
        animator.deceleration = attributes.deceleration
        new ScreenTransition(attributes.component, attributes.closure
as TransitionTarget, animator)
    }

I would like to enable
animate(...) {...}
and give retreive the closure

I also would like to have deault values whe not given.

Regards,

Raphaël
JRM | 18 Jul 17:34
Picon

[groovy-user] Category methods: where do they live at runtime?

I've searched the list and groovy docs for an answer to this, but I've  
been unable to find an answer so far.  If it's been covered already,  
my apologies.

Is it possible (under Groovy 1.5.4)  from within the scope of a  
category usage to get a reference at runtime to the methods that are  
added from the category?  I can't seem to figure out where references  
to those methods are stored.  They aren't available in the MetaClass  
or the binding.  Where do they come from?   It's all so magical.  :-)

Here is a script that demonstrates trying to find them in the script's  
class methods and metaClass methods:

public class MyMagicCategory {

    static def whereDoILive( Script self ) {
      println "Hello. I'm right here."
    }
}

use (MyMagicCategory) {
   whereDoILive()
   def  foundInMethods = this.class.methods.find{ it.name ==  
"doSomething" } != null
   def  foundInMetaMethods = this.metaClass.metaMethods.find{ it.name  
== "doSomething" } != null

   assert foundInMethods || foundInMetaMethods
}

Output:
Hello. I'm right here.
Exception thrown: java.lang.AssertionError: Expression:  
(foundInMethods || foundInMetaMethods). Values: foundInMethods =  
false, foundInMetaMethods = false

java.lang.AssertionError: Expression: (foundInMethods ||  
foundInMetaMethods). Values: foundInMethods = false,  
foundInMetaMethods = false
	at Script15$_run_closure1.doCall(Script15:14)
	at Script15$_run_closure1.doCall(Script15)
	at Script15.run(Script15:9)

Thanks for the help!

--
Jason

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Martin C. Martin | 18 Jul 17:04

[groovy-user] Groovy on alternate JVMs

Has anyone tried Groovy on JVMs other than HotSpot?  Any success or failure?

Best,
Martin

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Picon

[groovy-user] making Eclipse groovy plugin aware of my additional jar files

Hi

I'm using Eclipse groovy plugin 1.5.1.  Eclipse gives "unable to resolve class" in my groovy script when I
want to operate on class that is in added Jar file. 
How can I make Eclipse groovy plugin be aware of my additional jar files?
Will be very grateful for any advise.

Greetings

Rafal Baranowski

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

nagy | 18 Jul 11:27
Picon

[groovy-user] Problem with setCharacterEncoding in groovlet

Hi,
 
 
and get in my groovlet
 
String defText = request.getParameter('text')?:'** KEIN TEXT **'
in defText is "undefined character" '\ufffd'
 
when is use
request.setCharacterEncoding('ISO-8859-1') or other there ist no effect.
 
 
lg
\^/ili
Marc Palmer | 17 Jul 23:13
Picon
Favicon

[groovy-user] Idea / a better way to do this?

Hi,

I wanted to see if a condition holds for all elements in a collection,  
but I cannot (it is late) see a clean simple way of doing this using  
the GDK.

We don't seem to have something like:

def allmatch = someList.holdsTrue { it.age > 25 }

I can't see how to do this at the moment without an external var of  
some kind to track state - maybe I'm missing something?

If not, shall I jira this for 2.0?

Marc

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Rubee | 17 Jul 15:37
Picon
Favicon

[groovy-user] creating a new method inside invokeMethod


I've seen examples where invokeMethod creates a new method so that, on the
next call, the performance hit is reduced. Here's an example from Venkat
Subramaniam's excellent "Programming Groovy." (See p. 223.)

class Manager
{
.......
def methodMissing(String name, args)
  {
    println "intercepting call to $name..."
    def delegateTo = null

    if(name.startsWith('simple')) { delegateTo = worker }
    if(name.startsWith('advanced')) { delegateTo = expert }

    if (delegateTo?.metaClass.respondsTo(delegateTo, name, args)) 
    { 
      Manager.metaClass."${name}" = { Object[] varArgs -> 
            return delegateTo.invokeMethod(name, *varArgs)
      }

      return delegateTo.invokeMethod(name, args)
    }

    throw new MissingMethodException(name, Manager.class, args)
  }
........
} //end class

I need to do this is an webapp, which means my analog to the Manager class
shown here lives in a multi-threaded enviroment.  

My question, then, is how do I handle method-creation in a mulit-threaded
environment?  I suppose that question boils down to: what do I need to
synchronize on, if anything?  

I hope developers are doing this kind of thing all the time, and maybe
someone can show me a real-world example.

--

-- 
View this message in context: http://www.nabble.com/creating-a-new-method-inside-invokeMethod-tp18508436p18508436.html
Sent from the groovy - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Guillaume Laforge | 17 Jul 12:29
Picon
Gravatar

[groovy-user] Groovy cross-platform installer for 1.5.6

Hi all,

Just a quick heads-up to tell you we've received a nice contribution
from the IzPack community (http://izpack.org/) in the form of a
cross-platform installer for Groovy 1.5.6.

I've updated the download section to add a link to it in the
installers section:
http://groovy.codehaus.org/Download

And you can find a direct link to this installer here:
http://dist.groovy.codehaus.org/distributions/installers/cross-platform/groovy-1.5.6-cross-platform-installer.jar

Thank you Julien :-)

--

-- 
Guillaume Laforge
Groovy Project Manager
G2One, Inc. Vice-President Technology
http://www.g2one.com

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Gmane