I have a Groovy script that converts some very poorly formatted data into XML. This part works fine, but it's also happily passing some characters along that aren't legal in XML. So I'm adding some code to strip these out, and this is where the problem is coming from.
The code that isn't compiling is this:
def illegalChars = ~/[\u0000-...
I want to read a webpage A in ISO-8859-1 charset, according to the browser, and return the content in UTF-8 as a content of the webpage B.
This is: I want to show the content of the page A in the same charset that I use to show the rest of the page B, that is UTF-8.
How do I do this in java/groovy?
thanks in advance
...
The following Groovy commands illustrate my problem.
First of all, this works (as seen on lotrepls.appspot.com) as expected (note that \u0061 is 'a').
>>> print "a".matches(/\u0061/)
true
Now let's say that we want to match \n, using the Unicode escape \u000A. The following, using "pattern" as a string, behaves as expected:
>>> pri...
I have some resources I must access with SSL that use self-signed certificates. In general, most tools have a simple setting to allow these to be accessed without error or just a warning. However, it seems like the proper way to do this with the JVM is to import the signing certificate into a keystore as a CA.
I have a groovy script I...
By default SomeController.groovy has a controller name of some. Also, pkg.SomeController has a controller name of pkg/some.
Is there a way to plug a custom mechanism for this translation. In my particular instance I want to get rid of the pkg (it's a long story why I need this)
I can try to use @Controller("name") but given the number ...
Hi,
I am currently trying to specify custom error messages in grails for the default constraints but so far all I get back is the default error message.
I know that I have to edit the grails-app/i18n/messages.properties file
If I change the following default error codes message, it will correctly display the new error message
default...
So we have some unit tests written in groovy. We have the Groovy Eclipse plugin going, we have gmaven going, but the problem is that the maven eclipse plugin doesn't automatically add the src/test/groovy directory as a source directory. So, I enlisted the build-helper plugin to add a source directory, but then the problem becomes the sou...
Hi,
In python, I can use eval() to execute user entered code in my program.
Is there anything similar I can do in Groovy? I want to have a SWING UI textbox where the user enters a piece of code that I want to execute?
Thanks,
Hari
...
I'm using groovy.xml.MarkupBuilder to create XML response but it creates prettyprinted result which is unneeded in production.
def writer = new StringWriter()
def xml = new MarkupBuilder(writer)
def cities = cityApiService.list(params)
xml.methodResponse() {
resultStatus() {
r...
I would like to develop some apps for the JVM using a concise, dynamic language. The most popular choices for this seem to be Jython, JRuby, Groovy, and maybe Clojure.
Rhino appears to be fast and very stable, but I see no books on Rhino development and little discussion. Why is there apparently little use of JavaScript for other than e...
I have been maintaining a maven java project for year.
Recently, I learned Ruby and asked why haven't these nice features (of Ruby) existed in Java, and I am so happy to find Groovy the answer. It's already out there for more than 6 years and what a shame I didn't know about it sooner.
Now come to the story:
I have a lot of java code wri...
With more than a little help from daviderossi.blogspot.com I have managed to get some code working to replace an xml value with another
def fm_xml = '''<?xml version="1.0" encoding="UTF-8"?>
<MAlong>
<Enquiry.ID>SC11147</Enquiry.ID>
<student.name_middle></student.name_middle>
<student.name_known></student.name_known>
<student.name_previ...
With more than a little help from daviderossi.blogspot.com I have managed to get some code working to replace an xml value with another
This give me the following output which both edits the value at the 'ix' position BUT also adds a second copy at the end. If I search for it with LastIndexOf and delete it then it deletes the first occu...
Use Case: Take an HTML file with comments in a specific format (a format I specified), and change it to a JSP page that fills in these special areas with custom JSP code.
Simple Example:
<html>
<!-- start:custom-title-content -->
<h1>this is the generic title content used to develop the HTML page</h1>
<!-- end:custom-title-content --...
I have a test grails app setup with a context of "/testapp". When I add a link in my gsp that references / it does not go to the root of my grails.app.context, but to the root of my grails.serverURL property.
For example given a link with href "/css/main.css"
I would expect that this link would actually look in localhost:8080/testapp/c...
What is the best way to remove null items from a list in Groovy?
ex: [null, 30, null]
want to return: [30]
...
I have two java projects, A and B, A depends on B. In project B I've added a groovy class (Foo.groovy) and a java class (Bar.java) that uses the groovy class. In MyEclipse, Foo.class is in bin-groovy, and I can run things from MyEclipse just fine. However, when MyEclipse deploys project A to tomcat, it does not include the Foo.class file...
I have a script that is available on the web, and I want to run it directly by entering its url, instead of downloading it and running later. Is there a way to do it ?
...
How to find whether the string contains '/' as last character .
I need to append / to last character if not present only
ex1 : def s = home/work
this shuould be home/work/
ex2 : def s = home/work/
this will remain same as home/work/
Mybad thought this is simple, but fails
thanks in advance
...
I want to print my xml which is coming from an external feed on the console.
When I do
log.debug "${xml}"
I get xml values on the console but not the starting and end tags. For example
<fruits>
<fruit1>apple</fruit1>
<fruit2>orange</fruit2>
</fruits>
Just prints appleorange
Just the values concatenated one after other...