groovy

Is there any reasonable SSDP or DIDL Lib for java/groovy/python?

For a future project I am looking for a library to handle SSDP communication and messages in DIDL-Lite xml dialect. Is there any reasonable implementation of java, groovy or python? I don't like to use implementations of existing UPnP stacks like cybergarage or the frauenhofer UPnP stack because they are highly depending on these stack...

Unzip Archive with Groovy

Hi, is there a built-in support in Groovy to handle Zip files (the groovy way)? Or do i have to use java.util.zip.ZipFile to process Zip files in Groovy ? ...

Problem with ImageTools plugin in Grails

Hi guys, i have a grails project with an Image Domain Class and Controller. I just installed the grails ImageTools 1.0.4 Plugin and i would like to generate thumbnails for images wich will be uploaded. My Image-Domain-Class: class Image { byte[] data //String name byte[] thumbnail static constraints = { //name() data() } } ...

Case insensitive search in grails

I am developing grails application which uses file searching.For that I wrote the following code. This code works and it is gives the results with case sensitive.But I want to search files without case sensitive. def criteria = FileDomain.createCriteria() def results = criteria { and { like('user', User.findById(session?.user...

How to treat an entry in an XML file as a GString and have groovy still 'evaluate' it?

The 1st example below illustrates the working code. I want to take the working code a step further and store the SQL in an XML file. However, once I read it from an XML file I can't seem to get groovy to treat the SQL statement as a GString anymore. Here is the working example: private void testRefCursors(){ //object owner param...

Tired of ASP.NET, which of the following should I learn and why?

Which of the following technology is easy to learn and fun for developing a website? If you could only pick one which would it be and why Clojure/Compojure+Ring/Moustache+Ring Groovy/Grails Python/Django Ruby/Rails Turbogear Cappuccino or Sproutcore Javascript/jQuery ...

Grails Eclipse plugin

Hi, I've seen various posts on SO criticising the Eclipse Grails plugin, and am wondering if anyone has found a way to work productively with Grails within Eclipse? I had a look at the Grails plugin page, and the information there doesn't look very promising, particularly the conflicting advice regarding the 'Disable Groovy Compiler Ge...

Recompilation problem with groovlets (Groovy)

I'm new to Groovy, really like it, but found a compilation problem. I'm using Jetty as a webserver, which is serving .groovy files (groovlets) Consider two files: Test1.groovy which contains:    println new Test2().property Test2.groovy which contains:   public class Test2 {    String property = "print this"  } When calling /Test1.gr...

'this' in Groovy meta-programming

Hi, In the following Groovy code snipped to add a fileAsString method to the String class, could someone explain what exactly 'this' refers to. I thought it was the object on which the fileAsString method is invoked, but apparently that's actually what delegate refers to. String.metaClass.fileAsString = { this.class.getResourceAsSt...

Can I use AST transformations in Groovy to extend its syntax?

I have seen examples of how you can use the Groovy AST transformations to extend the language, e.g. to log before and after a method call as shown here. However, would it also be possible to use this framework to extend the syntax of the language itself? For instance, what if I wanted to be able to parse and transform the following into ...

Why does ant think I have an old version of Java?

I am trying to build Groovy from source (on RH Linux) using ant, but for some reason it thinks that my Java version is 1.4, and not 1.6, and thus it won't compile. The offending lines seem to be <condition property="groovy.build.vm5"> <not> <contains string="${ant.java.version}" substring="1.4"/> </not> </condition> i...

Problems compiling Groovy from source

I am trying to compile the latest Groovy distribution from source, using ant 1.7.1. The process runs along smoothly until "-createEmbeddableJar:", under which it fails saying BUILD FAILED myHomeDir/groovy-src-1.6.0/groovy-1.6.0/build.xml:582: The <unwar> type doesn't support the nested "globmapper" element. Build xml from line ...

Unsafe use of user-supplied GString:s in Groovy/Grails

The GString concept in Groovy is pretty powerful (see http://groovy.codehaus.org/Strings+and+GString). GStrings let you do things like: world = "World" println "Hello ${world}" # Output: Hello World println "1+2 = ${1+2}" # Output: 1+2 = 3 println "${System.exit(-1)}" # Program terminated I'm trying to figure out if using Groovy GStr...

grails default constraints

Hi, Assume I have a Grails domain object like this: class Todo { String name String priority String status static constraints = { name(blank: false) priority() } } What are the default constraints on a field if: It's listed in the constraints block without any actual contraints, e.g. priori...

How to establish a Hibernate session within a grails script

The following grails script: // Import.groovy includeTargets << grailsScript("Bootstrap") target(main: "Import some data...") { depends(bootstrap) def Channel = grailsApp.classLoader.loadClass("content.Channel") def c // works: saving a valid Channel succeeds c = Channel.newInstance(title:"A Channel", slug:"a-c...

Cannot get Groovy AST example to work

So, I am trying to learn how to use (and extend) Groovy, and I am following the example from this page. Basically, it shows how to define an annotation for Groovy code that lets you hook in to the compiler process. The example revolves around writing and annotation that will cause lines to be printed before and after method calls. My c...

Groovy GDK equivalent of Apache Commons StringUtils.capitalize(str) or Perl's ucfirst(str)

Yes/no-question: Is there a Groovy GDK function to capitalize the first character of a string? I'm looking for a Groovy equivalent of Perl's ucfirst(..) or Apache Commons StringUtils.capitalize(str) (the latter capitalizes the first letter of all words in the input string). I'm currently coding this by hand using .. str = str[0].toUpp...

Valid Java code that is NOT valid Groovy code?

Most Java code is also syntactically valid Groovy code. However, there are a few exceptions which leads me to my question: Which constructs/features in Java are syntactically invalid in Groovy? Please provide concrete examples of Java code (Java 1.6) that is NOT valid Groovy code (Groovy 1.6). Update: So far we've got five examples o...

The Groovy way to do value matching?

Just wonder groovy way to do value matching with default like this? if(params.max != 10 && params.max != 20 && params.max != 30){ params.max = 10 } ...

How to return specific date format as JSON in Grails?

In Grails, you can use the JSON converters to do this in the controller: render Book.list() as JSON The render result is [ {"id":1, "class":"Book", "author":"Stephen King", "releaseDate":'2007-04-06T00:00:00', "title":"The Shining"} ] You can control the output date by make a setting in Config.groovy grails.converters.json.dat...