Hey folks,
I note that in most of the plugins (my recent contribution included)
there is no attempt to escape special characters inside Java string
constants generated inside a Velocity template. For example, at
plugin-beaninfo's BeanInfoPlugin.vm:307 we have this:
parameterDescriptor.setShortDescription("${parameterTag.getNamedParameter("short-description")}");
Now, the string being substituted here could include double quotes or
newline characters. It's a textual description, not an identifier. If
it does such characters, the generated code will be lexically bad and
will not compile.
Maybe there's already a facility of this kind, which I missed. But if
there isn't, there seems to be a Velocity add-on that can be included in
the framework so that this sort of escaping can be applied without a lot
of duplicated code for each plugin. I note that the Jakarta Velocity
tools provide just such a tool, called EscapeTool. See:
http://jakarta.apache.org/velocity/tools/generic/EscapeTool.html
If it was integrated with the XD2 dist, then invoking it would be as
easy as this:
parameterDescriptor.setShortDescription("${esc.java($parameterTag.getNamedParameter("short-description"))}");
It also escapes for SQL, JavaScript, and so on -- very handy.
I don't know enough about the non-plugin part of XD2 to have a clue how
this would be integrated. Does this seem useful to the person who
currently maintains that part of the world?
... . . . . j