zronph | 1 Mar 2010 01:25
Picon

Re: [groovy-user] can I write groovy code in java


fachhoch wrote:
> 
> I want to use groovy list, map closures etc in my java classes  .Can I
> write them inside a .java  file ?
> 
> 

You can't do this. You can however do the opposite; i.e. Write your class as
a Groovy file and compile with groovyc. You will then be able to use the
groovy class in your regular Java classes. (you will need groovy-all.jar on
your classpath though if remember correctly)

hope this helps.

Mark
--

-- 
View this message in context: http://old.nabble.com/can-I-write-groovy-code-in-java-tp27714267p27739174.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 | 1 Mar 2010 08:27
Gravatar

Re: [groovy-user] Difference between Web Console and Groovy Console

It's not a formatting issue.
out is bound in the console to output to System.out, which is
redirected / saved for printing in the output window
And actually, the correct usage of out in StreamingMarkupBuilder
should be mkp.out << "hi" instead of out << "hi".

On Sun, Feb 28, 2010 at 13:55, Roshan Dawrani
<roshandawrani@...> wrote:
> Looks like it is a web console bug. In regular console, both 1.7.x and 1.8.x
> give the output as <root><something>hi</something></root>
> (http://groovypp.appspot.com/ too)
>
> But groovyconsole.appspot.com probably formats the output wrongly as
> "hi<root><something></something></root>"
>
>
> On Sat, Feb 27, 2010 at 12:11 AM, Tom Nichols <tmnichols@...> wrote:
>>
>> In my local Groovy 1.7.0 console, the following snippet:
>>
>> import groovy.xml.*
>>
>> println new StreamingMarkupBuilder().bind {
>>  root {
>>    something() { out << "hi" }
>>  }
>> }.toString()
>>
>> Output:  <root><something>hi</something></root>
>>
(Continue reading)

Guillaume Laforge | 1 Mar 2010 08:32
Gravatar

Re: [groovy-user] Cannot search wiki-snapshot.pdf

Hi,

I've noticed that problem myself (when trying to do a copy'n paste in
another document), but couldn't figure out what was going wrong.
In your researches, did you find why such font encoding issues arise?
The problem is that the PDF of the wiki is generated by our wiki
(Confluence) itself, but I've got no idea if we can do anything at
generation time on our side to solve this problem, or if it's really
just an issue with the wiki itself (that Atlassian would need to fix).
Anyhow, this is a bit painful :-(

Guillaume

2010/2/28 朱强 <qng_zh@...>:
> I downloaded "JavaDoc and zipped online documentation" for groovy 1.7.1,
> opened wiki-snapshot.pdf with Acrobat Reader 9.0 on Simplified Chinese Windows XP,
> but I cannot search text within that pdf document.
>
> After google "cannot search pdf", it seems like that's font encoding related issues,
> so copy some text within wiki-snapshot.pdf and paste into Notepad do not show up
> correctly.
>
> What shoud I do to make wiki-snapshot.pdf to support search in PDF reader?
> Thanks.

--

-- 
Guillaume Laforge
Groovy Project Manager
Head of Groovy Development at SpringSource
http://www.springsource.com/g2one
(Continue reading)

Guillaume Laforge | 1 Mar 2010 11:13
Gravatar

Re: [groovy-user] DSL Help

Both method calls you're showing here would call the same method
from(String), and there's no magic way of dispatching to different
methods... unless you do the dispatching logic yourself inside that
method -- at least, nothing comes to mind for such a scenario.
So I'd advise to delegate to different implementations for your logic.

On Sun, Feb 28, 2010 at 00:51, zronph <mbarrett.mark@...> wrote:
>
> Hello there. I'm attempting to implement a DSL for the first time and am
> having a few troubles.
>
> Basically the I want to implement it so that based on the context that a
> method was called a different implementation would be called. For example
> consider the following code:
>
> "person1".from "people.csv" // select the column 'person1' from the csv file
> "property1".from "propertiesFile.properties" // read the property
> 'peroperty1' from the properties file
>
> Is there any way to define a context such as CsvContext and
> PropertiesContext, and depending how/where the from function was called it
> was use the relevant implementation?
>
> Also, if anyone knows of any good resources for DSLs I'd much appreciate a
> link :)
>
> Thanks for any help
>
> Mark
> --
(Continue reading)

Alex Wouda | 1 Mar 2010 11:30
Picon

Re: [groovy-user] reading Excel file with POI on OSX fails

Hi Thanks for the answer.

Little bit stupid but I was not aware Excel BIFF5 was old school..
I'll have the guys that generate Excel asked if they can upgrade, which makes it easier for me ;-)
Otherwise I'll revert to solutions I found at the POI list.

thanks

Alex

Op 28 feb 2010, om 18:46 heeft Jim White het volgende geschreven:

> Hi Alex.
> 
> The trouble seems pretty self-explanatory as does the solution (find a tool that works with BIFF5).
> 
> This question is not Groovy related AFAICT.  You'll have more luck I think on the POI list or other such forum.
> 
> A tools I know of that can convert (and evaluate) many versinos of Excel files is OpenOffice.  I've
integrated Groovy with OpenOffice which will help if you're trying to do this with Groovy, although the
server API stuff is not documented or supported, it is just part of the test code for GroovyForOpenOffice
and Wings.
> 
> http://api.openoffice.org/SDK/
> 
> http://wiki.services.openoffice.org/wiki/API/Samples/Groovy
> 
> http://ifcx.svn.sourceforge.net/viewvc/ifcx/Wings/trunk/Wings/src/org/ifcx/wings/openoffice/WingsTest.groovy?revision=128&view=markup
> 
> Jim
(Continue reading)

Alex McManus | 1 Mar 2010 12:03

Re: [groovy-user] DSL Help

You might make things a little easier by restructuring your DSL. For example:

from('people.csv') {
    column('person1')
}

That way, you have the context from the outer 'from' element. Of course, how useful this is depends on what you're trying to do with your DSL. Your best bet may be to find a DSL that is somewhat similar to what you are trying to do, and adapt this.

Have you found the DSL resources at the Groovy website?


Cheers, Alex.

On 1 March 2010 10:13, Guillaume Laforge <glaforge-yCVjj/EcxBJg9hUCZPvPmw@public.gmane.org> wrote:
Both method calls you're showing here would call the same method
from(String), and there's no magic way of dispatching to different
methods... unless you do the dispatching logic yourself inside that
method -- at least, nothing comes to mind for such a scenario.
So I'd advise to delegate to different implementations for your logic.

On Sun, Feb 28, 2010 at 00:51, zronph <mbarrett.mark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> Hello there. I'm attempting to implement a DSL for the first time and am
> having a few troubles.
>
> Basically the I want to implement it so that based on the context that a
> method was called a different implementation would be called. For example
> consider the following code:
>
> "person1".from "people.csv" // select the column 'person1' from the csv file
> "property1".from "propertiesFile.properties" // read the property
> 'peroperty1' from the properties file
>
> Is there any way to define a context such as CsvContext and
> PropertiesContext, and depending how/where the from function was called it
> was use the relevant implementation?
>
> Also, if anyone knows of any good resources for DSLs I'd much appreciate a
> link :)
>
> Thanks for any help
>
> Mark
> --
> View this message in context: http://old.nabble.com/DSL-Help-tp27732033p27732033.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
Groovy Project Manager
Head of Groovy Development at SpringSource
http://www.springsource.com/g2one

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

   http://xircles.codehaus.org/manage_email



zronph | 1 Mar 2010 13:54
Picon

Re: [groovy-user] DSL Help


Hello,

I managed to get something working by doing the following:

def csvFromImpl = { ... }
def propertiesFromImpl = { ... }

def csv = { c ->
    String.metaClass.from = csvFromImpl
    c()
}

def properties = { c ->
    String.metaClass.from = propertiesFromImpl
    c()
}

Then when I called either the csv or properties methods, using the
"str".from invoked the relevant implementation. There are a few issues with
this thougj; one is thread safty , another is I'm not sure how perfomant
this would be. Any thoughts?

Thanks

Mark

Guillaume Laforge-2 wrote:
> 
> Both method calls you're showing here would call the same method
> from(String), and there's no magic way of dispatching to different
> methods... unless you do the dispatching logic yourself inside that
> method -- at least, nothing comes to mind for such a scenario.
> So I'd advise to delegate to different implementations for your logic.
> 
> On Sun, Feb 28, 2010 at 00:51, zronph <mbarrett.mark@...> wrote:
>>
>> Hello there. I'm attempting to implement a DSL for the first time and am
>> having a few troubles.
>>
>> Basically the I want to implement it so that based on the context that a
>> method was called a different implementation would be called. For example
>> consider the following code:
>>
>> "person1".from "people.csv" // select the column 'person1' from the csv
>> file
>> "property1".from "propertiesFile.properties" // read the property
>> 'peroperty1' from the properties file
>>
>> Is there any way to define a context such as CsvContext and
>> PropertiesContext, and depending how/where the from function was called
>> it
>> was use the relevant implementation?
>>
>> Also, if anyone knows of any good resources for DSLs I'd much appreciate
>> a
>> link :)
>>
>> Thanks for any help
>>
>> Mark
>> --
>> View this message in context:
>> http://old.nabble.com/DSL-Help-tp27732033p27732033.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
> Groovy Project Manager
> Head of Groovy Development at SpringSource
> http://www.springsource.com/g2one
> 
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
> 
>     http://xircles.codehaus.org/manage_email
> 
> 
> 
> 

--

-- 
View this message in context: http://old.nabble.com/DSL-Help-tp27732033p27742979.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

c | 1 Mar 2010 16:18

[groovy-user] groovyConsole doesn't do include

I've been working on a script, but it has gotten too long so I want to
split the classes out into other files.  But using groovyConsole as my dev
tool is failing.  So I tried starting over and found a quirk: include
isn't recognized by groovyConsole.

I have this file:
---
package test

class MyClass {
    String name = "the name"
}
---
I go to run it and am correctly told: groovy.lang.GroovyRuntimeException:
This script or class could not be run.

So then I make a second file
---
package test

println "Printing..."+ (new MyClass()).name
---
I go to run it and it says:  1 compilation error:
unable to resolve class MyClass

I update that file so it says
---
package test
include test._

println "Printing..."+ (new MyClass()).name
---
Where I see 'include' isn't highlighted like package and 'new MyClass' are.

I go to run it and it still says:  1 compilation error:
unable to resolve class MyClass

So I fidget and try
---
package test
import test.MyClass    //test._

println "Printing..."+ (new MyClass()).name
---
'import' *does* highlight, but I get the same error but on line 2 now: 1
compilation error:
unable to resolve class test.MyClass

Is this JIRA-worthy or just a future feature?

Thx

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

    http://xircles.codehaus.org/manage_email

Uri Moszkowicz | 1 Mar 2010 17:44

[groovy-user] Re: Closure visibility problem

Consider the following program:

  class C {
     void m1(Closure c) {} 
  }

  class A {
    A() { m = new C() }
    void a1(Collection c) {
     c.each {
        m.m1({ it =~ /text/ })
      }
    }

    private def m 
  }

  class B extends A {}

  def b = new B() 
  b.a1(["a", "b"])

Running this program results in the following error: 
  Caught: groovy.lang.MissingPropertyException: No such property: m for 
class: B
           at A$_a1_closure1.doCall(a.groovy:11)
           at A.a1(a.groovy:10)
           at a.run(a.groovy:21)

Changing field m to be protected seems to solve the problem. Does anyone 
know why that change should be necessary? Defined in a member of
class A, shouldn't the closure defined in a1() have access to its 
private variables?

Thanks,
Uri

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

    http://xircles.codehaus.org/manage_email

Roshan Dawrani | 1 Mar 2010 18:02

Re: [groovy-user] Re: Closure visibility problem

This issue has very recently been raised at http://jira.codehaus.org/browse/GROOVY-4083.

On Mon, Mar 1, 2010 at 10:14 PM, Uri Moszkowicz <uri-webSqJVl7FcAvxtiuMwx3w@public.gmane.org> wrote:
Consider the following program:

 class C {
   void m1(Closure c) {}  }

 class A {
  A() { m = new C() }
  void a1(Collection c) {
   c.each {
      m.m1({ it =~ /text/ })
    }
  }

  private def m  }

 class B extends A {}

 def b = new B()  b.a1(["a", "b"])

Running this program results in the following error:  Caught: groovy.lang.MissingPropertyException: No such property: m for class: B
         at A$_a1_closure1.doCall(a.groovy:11)
         at A.a1(a.groovy:10)
         at a.run(a.groovy:21)

Changing field m to be protected seems to solve the problem. Does anyone know why that change should be necessary? Defined in a member of
class A, shouldn't the closure defined in a1() have access to its private variables?

Thanks,
Uri

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

  http://xircles.codehaus.org/manage_email





--
Roshan
http://groovypp.appspot.com/ (Groovy/Groovy++ Console)
http://groovy.dzone.com/users/roshandawrani

Gmane