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(">");
else if (c == '<')
buffer.append("<");
else if (c == '&')
buffer.append("&");
else if (c == '"')
buffer.append(""");
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