dev@woodstock.java.net

Re: Please review: fix for CR 81

From: richard ratta <Richard.Ratta_at_Sun.COM>
Date: Tue, 01 May 2007 15:17:24 -0400

I don't have your code to check it out but it seems like

 "<type>java.util.List&lt;com.sun.webui.jsf.model.Indicator&gt;</type>"

works. And as long as your change does this, please putback the change.
I don't see a list of files here, so I will assume that you are also
releasing
the template with the reference to the "escaper".

Thanks.

-rick

Gregory Murphy wrote:

> This is fix for CR 81, 'annotations doesn't support "List<> obj"
> syntax' (https://woodstock.dev.java.net/issues/show_bug.cgi?id=81).
>
> In sum, the annotations processor needs support to escape component or
> property metadata, depending on the format of the file that is being
> written. This fix introduces a simple "Escaper" interface, which
> defines a single method for escaping strings:
>
> /**
>
> * An escaper is a utility object used to escape component or property
> metadata
>
> * when it is written to a file. The transformation performed is
> dependent on the
>
> * file format.
>
> */
>
> public interface Escaper {
>
> /**
>
> * Escape the text specified and return it.
>
> */
>
> public String escape(String text);
>
> }
>
>
> File generators may be provided an escaper that is appropriate for the
> type of file that they will be writing. I will add one impl of
> escaper, for handling XML files:
>
> /**
>
> * An escaper for XML file types.
>
> */
>
> public class XmlEscaper implements Escaper {
>
> /**
>
> * Escape the text specified and return it.
>
> */
>
> public String escape(String text) {
>
> if (text == null)
>
> return null;
>
> StringBuffer buffer = new StringBuffer();
>
> for (char c : text.toCharArray()) {
>
> if (c == '>')
>
> buffer.append("&gt;");
>
> else if (c == '<')
>
> buffer.append("&lt;");
>
> else if (c == '&')
>
> buffer.append("&amp;");
>
> else if (c == '"')
>
> buffer.append("&quot;");
>
> else
>
> buffer.append(c);
>
> }
>
> return buffer.toString();
>
> }
>
> }
>
>
> The generator impl for the taglib files makes it's escaper available
> to its template context like this:
>
> velocityContext.put("escaper", this.getEscaper());
>
>
> Which can then be used in the template like this:
>
> <type>${escaper.escape($propertyInfo.type)}</type>
>
>
> That's the gist.
>
> // Gregory
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_woodstock.dev.java.net
> For additional commands, e-mail: dev-help_at_woodstock.dev.java.net
>