commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marco Tedone" <mted...@jemos.co.uk>
Subject [jelly] invokeTag does not understand 'escapeText' attribute + optimal Java source formatting?
Date Sun, 07 May 2006 10:34:40 GMT
Hi, in the effort of trying to optimize the formatting of interfaces 
auto-generated by my tool, I incurred in the following exception:

<snip>...file:/D:/OPENSOURCES/eclipse_projects/ClankerTestProject/interfaces.jelly:21:34:

<j:invokeStatic> This tag does not understand the 'escapeText' attribute

The online documentation says that this attribute is supported by 
invokeStatic.

Additionally I'd like to ask your opinion about Java source formatting. I'm 
writing a tool that can be used to auto-generate code (Java, XML, etc), and 
I'm writing a set of jelly tags to use this tool. Although the tool works 
(i.e. I get a Java interface generated and compiled properly), the output is 
somewhat awful. Ok, who cares, it's auto geneated code right? Well, if there 
is no solution I'd go with it but I was wondering if there would be a way to 
optimize the layout of a Java source code. For instance, this is the script 
I'm using to auto generate interfaces:

[begin]
<j:jelly trim="false"
xmlns:j="jelly:core"
xmlns:x="jelly:xml"
xmlns:html="jelly:html"
xmlns:jemos="jelly:uk.co.jemos.clanker.jelly.libs.ClankerJellyLibrary">
//Auto-generated by Jemos Clanker. Do not edit
package ${packageName};
/**
* Defines interface for class ${clazz.fullName}
*/
public interface ${clazz.name}${suffix} {
<j:forEach items="${clazz.methods}" var="method">

<!-- Formats parameters and except -->
<j:invokeStatic var="params"
                           method="formatMethodParams"
                          className="uk.co.jemos.clanker.jelly.helper.StringFormatter"
                          escapeText="false">
    <j:arg type="uk.co.jemos.clanker.components.Method" value="${method}" />
</j:invokeStatic>

<!-- Retrieves the exceptions -->
<j:invokeStatic var="exceptions"
                           method="formatMethodExceptions"
                           className="uk.co.jemos.clanker.jelly.helper.StringFormatter"
                           escapeText="false">
  <j:arg type="uk.co.jemos.clanker.components.Method" value="${method}" />
</j:invokeStatic>

<!-- Method's signature -->
<j:choose trim = "true">
  <j:when test="${null != exceptions}" trim="true">
     public ${method.returnType} ${method.name}(${params}) throws 
${exceptions};
  </j:when>
<j:otherwise trim="true">
    public ${method.returnType} ${method.name}(${params});
</j:otherwise>
<j:whitespace />
</j:choose>
</j:forEach>
}
</j:jelly>
[/end]


The output is syntactically correct, however there is a huge amount of space 
(virtually everything enclosed between <j:foreach> and <j:choose>) between 
two methods. I tried to apply the 'trim' attribute to <j:forEach> but in 
this
case I get all interface methods (and exceptions) on one line, which is even 
worst. I tried <j:whitespace> without luck. I was wondering if there is 
something like: <j:newLine> which I could use in conjunction with 
<j:forEach> with 'trim' set to true.

Marco



---
[This E-mail has been scanned for viruses but it is your responsibility 
to maintain up to date anti virus software on the device that you are
currently using to read this email. ]


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message