Re: Possible New Groovy Features... - ctor calls without new keyword

2017-08-23 Thread John Wagenleitner
Just thought I'd mention list and map constructors [1], with those you can not only leave out the `new` keyword but also leave off the type (at least on the RHS) Foo foo = ['abc'] [1] http://groovy-lang.org/semantics.html#_list_and_map_constructors On Tue, Aug 22, 2017 at 4:16 PM, MG wrote: >

Re: foo() || return false ?

2017-07-18 Thread John Wagenleitner
s OP wants to do: >> >> if (!doSomething()) { >> return false >> } >> >> I don't know any groovy way to do that, though. >> >> >> On 2017-07-17 15:21 , John Wagenleitner wrote: >> >> Since the `||` operator expects an expression

Re: foo() || return false ?

2017-07-17 Thread John Wagenleitner
(); return false`. On Mon, Jul 17, 2017 at 5:24 PM, Guy Matz wrote: > Thanks so much for the reply! I'm not trying to do this, though: || false > > I'm trying to do this: || return false > > Is there a more groovy way? > > Thanks!! > > > On Mon, Ju

Re: foo() || return false ?

2017-07-17 Thread John Wagenleitner
That is not a valid start of an expression which is expected for the binary expression (expr || expr) so that's why it wont compile. I am not familiar with Scriptler and it is hard to tell without some more context, but how about just: doSomething() You can simplify by dropping the `|| false`. I

Re: Trouble with groovy.sql

2017-05-03 Thread John Wagenleitner
On Wed, May 3, 2017 at 10:59 AM, Thom DeCarlo wrote: > I'm using the groovy.sql libraries inside of a Java program and having > trouble with parameter substitution. My code looks like this: > > Mapparams = new HashMap(); > params.clear(); > params.put("source_system_id", Integer.valueOf(6)); > pa

Re: Invokedynamic

2017-04-30 Thread John Wagenleitner
On Fri, Apr 28, 2017 at 8:59 AM, Janice Treshova wrote: > Hi Groovy Users! > > I am new to Groovy and trying 2.4.11 on Windows (8.1). > > The "Invoke dynamic support" page on the Groovy-lang.org site says: > > The usual way to run a script from the command line is by "groovy >> foo.groovy", >> wh

Re: Optimising a Groovy script

2017-03-28 Thread John Wagenleitner
Hi Paul, The milliseconds to seconds conversion was off, so that puts the real time at ~0.5 seconds. > println "Took ${time/100} sec" Using the following I get somewhere close to 0.15. Using an int array may be worth it for higher values of N to avoid the boxing/unboxing of the ints. @Grapes

Re: Testing the Java 8 / Parrot parser online!

2017-03-25 Thread John Wagenleitner
On Sat, Mar 25, 2017 at 1:26 AM, Jochen Theodorou wrote: > On 25.03.2017 07:52, Russel Winder wrote: > >> On Fri, 2017-03-24 at 21:36 +0100, Guillaume Laforge wrote: >> >>> […] >>> >>> It's built with Java 8, and runs on the upcoming version of Google >>> App >>> Engine's Java runtime running on

Re: when does JsonSlurper return LazyMap vs LazyValueMap ?

2017-01-27 Thread John Wagenleitner
On Thu, Jan 26, 2017 at 12:27 PM, garneke wrote: > Update: > > I have determined that the difference in the return type has to do with > the JsonSlurper type. The INDEX_OVERLAY returns a LazyValueMap. > > > > That being said… > > What is the correct way to add a node or otherwise modify the Lazy

Re: parsing YAML with snakeyaml

2016-12-21 Thread John Wagenleitner
On Wed, Dec 21, 2016 at 11:58 AM, Dimitar Vassilev < dimitar.vassi...@gmail.com> wrote: > Good evening/morning/day, > Quick one how can I parse a YAML file with groovy and snakeyaml > > I have a nested hash YAML like: > > pkgcolls: > pkgcol1: > software:Foo > version:baz > pkgcol

Re: [VOTE] new operator ?=

2016-11-23 Thread John Wagenleitner
+1 On Nov 23, 2016 7:59 AM, "Daniel Sun" wrote: > Hi all, > > If the new operator ?= (e.g. a ?= 'foo' is equivalent of a = a ?: > 'foo') were to be added to Groovy programming language, do you like it? > (Yes: +1; No: -1; Not bad: 0) > > Cheers, > Daniel.Sun > > > > -- > View this messag

Re: 2.5 JsonBuilder Converters thoughts

2016-11-04 Thread John Wagenleitner
le since. > > > > Cheers > > > > On Fri, Oct 28, 2016 at 12:46 PM, Graeme Rocher > wrote: > >> Yeah I agree JsonOutput.unescaped allows the same flexibility without > >> compromising the most common use case. > >> > >> Cheers > >&

Re: Congratulations to our newest committer Daniel Sun

2016-11-03 Thread John Wagenleitner
On Nov 3, 2016 9:27 PM, "Paul King" wrote: > > Congratulations to Daniel Sun who is now a Groovy committer: > > https://projects.apache.org/committee.html?groovy > http://people.apache.org/phonebook.html?unix=groovy > > Daniel has been mostly working on the new Antlr 4 parser which will > see some

Re: 2.5 JsonBuilder Converters thoughts

2016-10-25 Thread John Wagenleitner
On Tue, Oct 25, 2016 at 12:07 PM, James Kleeh wrote: > Currently if one were to register a converter with options like so: > > JsonGenerator.Options options = new JsonGenerator.Options() > options.addConverter(MyCustomType) { MyCustomType mct -> > mct.name > } > > > Assuming “mct.name” return

Re: JsonOutput serialization options feature

2016-09-22 Thread John Wagenleitner
, and also seems to be a requested feature in GROOVY-6975 [1]. So seems worthwhile to add a disableUnicodeEscaping or disableNonAsciiEscaping option. I'll see if I can add that to the PR soon. [1] https://issues.apache.org/jira/browse/GROOVY-6975 > > On Mon, Sep 12, 2016 at 12:

Re: JsonOutput serialization options feature

2016-09-11 Thread John Wagenleitner
> > Thanks for pointing that out, I had forgot about that. I added a new method that accepts both a date format string and Locale. > > On 11/9/2016 6:59 πμ, John Wagenleitner wrote: > > Groovy Json users, > > I recently worked on a project where it wou

JsonOutput serialization options feature

2016-09-10 Thread John Wagenleitner
Groovy Json users, I recently worked on a project where it would have been helpful if JsonOutput/JsonBuilder/StreamingJsonBuilder had options for controlling the output. I noticed there were some open tickets [1] for feature requests around this so decided to try to add some options to control th

Re: TemplateEngines and Out of Memory

2016-06-27 Thread John Wagenleitner
Adding the following system property may help to extend the time before OOM: groovy.use.classvalue=true At least for me on Groovy 2.4.7 with jdk8_91 using that property let the loop run 25 minutes (made about half the iterations) vs. ~2.5 minutes without the property. I used a 64m heap. I belie

Re: XmlSlurper Namespace Question

2016-04-15 Thread John Wagenleitner
OT > “b:child2.b:content.b:dataNode” > > > > In order for this to work the XML has to be parsed with the XmlSlurper > argument namespaceAware=true. > > def root = new XmlSlurper(false, true).parseText(xml) > > > > Now the println will show that the namespace

Re: XmlSlurper Namespace Question

2016-04-15 Thread John Wagenleitner
Are you doing more than just removing nodes? The following seems to retain the namespace prefixes when serializing back out after removing a node. import groovy.xml.* String xml = ''' child1 child2 child3 ''' def root = new XmlSlurper().parseText(xml) root.child2.replaceNode {}

Re: No signature of method

2016-04-15 Thread John Wagenleitner
In your Java version you call awaitCompletion on the new ExecStartResultCallback: .exec( new ExecStartResultCallback(System.out, System.err) .awaitCompletion() ); In your Groovy version you don't, maybe just a mis-placed ending paren? .exec(new ExecStartResultCallback(System.out, System.

Re: ConfigSlurper not finding Config.groovy in jar

2016-04-15 Thread John Wagenleitner
If the build is compiling the file you probably either need to copy it into your jar from another location or you might be able to use the #parse(Class) method of ConfigSlurper. def config = new ConfigSlurper().parse(Config) On Fri, Apr 15, 2016 at 9:07 AM, Guy Matz wrote: > Hi! I can't seem t

Re: Can anyone comment on this stackoverflow posting that indicates XmlSlurper is actually namespace aware by default

2016-04-05 Thread John Wagenleitner
Setting namespaceAware to true (default) means that it provides support for namespaces, so in your sampleDoc it recognizes that an element such as "xact:update" is actually "{com.here.repl}update" instead of just "xact:update". Usually this would be used together with declareNamespace since the im

Re: Can anyone comment on this stackoverflow posting that indicates XmlSlurper is actually namespace aware by default

2016-04-05 Thread John Wagenleitner
I think the SO answer is correct that the documentation is incorrect. Originally the javadoc stated: "Uses the defaults of not validating and namespace aware." Some javadoc updates were made since and it was probably assumed that "not" also applied to namespace aware. Do you have any code sa

Re: Groovy SQL: Stored Procedure Call Not Executing configureStatement Closure

2016-03-10 Thread John Wagenleitner
Hi Guillermo, Yes, I think it was a bug. The call method taking a closure was not passing the created statement off to the configureStatement closure. This should be fixed by https://github.com/apache/groovy/pull/263 and the fix should be in 2.4.7. John On Thu, Mar 10, 2016 at 1:38 PM, Guiller

Re: "continue" does not continue the while loop after an assertion fails

2016-01-11 Thread John Wagenleitner
Could also put the text you were using in the asserts into a List instead and after the while loop assert list isEmpty(). On Jan 11, 2016 5:28 PM, "Edinson E. Padrón Urdaneta" < edinson.padron.urdan...@gmail.com> wrote: > ​​ > ​​ > I don't really know what are your intentions, so I gonna try to gu

Re: "continue" does not continue the while loop after an assertion fails

2016-01-11 Thread John Wagenleitner
The code never reaches the continue because the assert will throw an AssertionError since the expression in the if statement proves it will fail. If you remove the assert it should work. Also may want to remove the assert in your else branch, unless it is meant to abort the program if it's reache

Re: Sql cacheConnection/withTransaction always closes connection

2015-12-09 Thread John Wagenleitner
On Wed, Dec 9, 2015 at 6:20 AM, Alexander Holand Salgado < alexander.salg...@otrum.com> wrote: > Hi, > > > It seems that groovy.sql.Sql's cacheConnection {} and withTransaction {} > both close the used connection on returning, regardless of the > surrounding context, and if using a data source the