Does anyone have any useful advice/links to information about working with mp3 files in Groovy. I appreciate that this is just the same as working with Java libs, but wanted a simple solution to this problem:
I want to load an mp3 via a URL and interrogate it.
I'd like to test whether it exists and pull out the title, artist and defau...
I have the following Grails domain class:
class Product {
String name
Float basePrice
Category category
String image = "default.jpg"
static constraints = {
name(size:3..25, blank:false)
basePrice(scale:2, nullable:false)
category(inList:Category.list(), nullable:false)
image...
Is there a way to execute a Groovy class by specifying the package with dots, as with java?
Example: File ./my/package/MyClass.groovy:
package my.package
class MyClass {
static void main(String[] args) {
println "ok"
}
}
> cd my/package
my/package> groovy MyClass
ok
> cd ../..
> groovy my/package/MyClass.groovy
ok
> groovy ...
I would like to "spoil" plus method in Groovy in the following way:
Integer.metaClass.plus {Integer n -> delegate + n + 1}
assert 2+2 == 5
I am getting StackOverflowException (which is not surprising).
Is there any way to use "original" plus method inside metaclass' closure?
...
O Groovy Gurus,
This code snippet runs in around 1 second
for (int i in (1..10000000)) {
j = i;
}
while this one takes almost 9 second
for (int i = 1; i < 10000000; i++) {
j = i;
}
Why is it so?
...
I am using Groovy's XmlSlurper to parse xhtml document (or sudo xhthml one), and I'm trying to get to the text nodes of the document but can't figure how, here is the code:
import groovy.util.*
xmlText = '''
<TEXTFORMAT INDENT="10" LEADING="-5">
<P ALIGN="LEFT">
<FONT FACE="Garamond Premr Pro" SIZE="20" COLOR="#001200" LETTERSPA...
I need to implement a web app, but instead of using relational database I need to use different SOAP Web Services as a back-end. An important part of application only calls web services and displays the result. Since Web Services are clearly defined in form of Operation: In parameters and Return Type it seems to me that basic GUI could b...
In my Groovy program, I have a list of lines and want to select a contiguous block of lines from the list. The first line of the desired block contains a particular string, and the last line (which I can include or not - it doesn't matter) contains a (different) marker string.
Working code is below but surely there is a "groovier" way t...
Hi,
I have the following log4j config in my Grails 1.1 app
log4j = {
// Enable Hibernate SQL logging with param values
trace 'org.hibernate.type'
debug 'org.hibernate.SQL'
debug 'com.mycompany'
appenders {
console name: 'stdout', layout: pattern(conversionPattern: '%d{dd-MM-yyyy HH:mm:ss,SSS} %5p %c{1} - ...
By default, groovy's SimpleTemplateEngine uses <% %> as the scriptlet container. How do I escape these characters if I want to print out <% %>?
...
I would like to open a webpage from groovy, dump the specified webpage and eventually dump the webpage behind an anchor tag.
Does anybody has some sample code for this?
...
This is probably a very easy one for all SoapUI regulars.
In a SoapUI mock service response script, how do I extract the value inside the request I'm replying to?
Let's say the incoming request has
<ns1:foo>
<ns3:data>
<ns3:CustomerNumber>1234</ns3:CustomerNumber>
</ns3:data>
</ns1:foo>
How do I get the "1234" into a Groovy...
In Groovy, I have a parent class and a child class where the parent class's constructor tries setting the value of a field of the parent class using a closure as in the following code:
try {
def x = new ChildClass()
} catch (ex) {
ex.printStackTrace(System.err)
}
class ParentClass {
private values = []
ParentClass(columnCount)...
Hi
I have the following gsp page:
<g:def var="incidentMngmntId" value="${incidentMngmntInstance?.id}"/>
<g:link controller="ticketMngmnt"
action="list" params="[incidentMngmntId : incidentMngmntId]"
id="${incidentMngmntInstance?.id}"> Tickets
</g:link>
The generated URL is as follows
http://localhost:8080/smtool/tic...
Let's say we have a grails web application exposing several resources.
tags
urls
users
The application has a classical web-interface which the users interact with and some administration.
We want to expose the resources from the application to clients via a RESTful API and we don't want that part of the app to clutter up the control...
Which directories/files should be excluded when placing a Grails application under version control? I don't want non-source files or artifacts to be carried in SVN for my project.
...
I'm using IntelliJ Idea 8.1.2 for Grails development. The dynamic nature of Groovy is giving me a hard time debugging my code: I keep ending up in the internals of Groovy/Grails, i.e. CachedMethod, ExpandoMetaClass or the like.
Is there a way for example to tell the Idea debugger to completely skip the Groovy/Grails internals while debu...
Hey guys,
I think I am not the only one who is gonna ask this question next time.
After some experience with RoR I am impressed with the power of dynamic languages. Lots of projects are still forced for different reasons to use a java technology stack though. Since testing is an important part of any project I would like to hear your e...
I'm trying to dynamically create domain objects in Grails and encountered the problem that for any property referencing another domain object the metaproperty tells me its type is "java.lang.Object" and not the expected type.
For example:
class PhysicalSiteAssessment {
// site info
Site site
Date sampleDate
Boolean rain...
Hi,
I have a Groovy class similar to
class MyClass {
Foo foo
}
Under certain circumstances I don't want to initialize foo and want to stub out all the calls to it. Any methods that return a value should do nothing. I could do it like this:
Foo.metaClass.method1 = {param -> }
Foo.metaClass.method2 = { -> }
Foo.metaClass.method3 = ...