What I'm using now is a initDecap method on a utils object. I have two base classes for plugins, one for my java generating plugins and one for my xml generating plugins. Both of these classes have delegate methods for the initdecap method.
My experience is that I use the method for both generating XML and Java so it might even be good to have such (a) method(s) on the Plugin class.
The method looks something like this.
public String initDecap(String string) {
char character = string.charAt(0);
return string.replaceFirst(Character.toString(character), Character
.toString(Character.toLowerCase(character)));
}
In my templates I use it like this ${plugin.initDecap($class.name)}
Joris
|
Konstantin Priblouda <[EMAIL PROTECTED]> 2005-10-06 03:15 PM
|
|
--- Joris Wijlens <[EMAIL PROTECTED]> wrote:
> Hi,
>
> How do I get the class name starting with a lower
> case in a velocity
> template? So if I generate methods with parameters I
> can use the class
> name with lower case as the parameter name.
At the moment there is no standart solution. Though
I can imagine that abstract java generating plugin
could profit from such utility methods
( say, decapitalize first, camel hump, getter/setter
pair... )
Those methods could be already there - check generama
or other java generating plugins.
YOur patch shall it be necessary would be welcome in
JIRA :)
BTW, are you developing plugin for internal use? Or
like to share it with community? In this case you also
should read/write to dedicated plugin interest list.
And if by any chance you know Ruud Wetering, greet him
from me.
regards,
----[ Konstantin Pribluda http://www.pribluda.de ]----------------
Still using XDoclet 1.x? XDoclet 2 is released and of production quality.
check it out: http://xdoclet.codehaus.org
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
