I just start using Java Velocity. Now I want to create a java class template.
package $app.package_namespace public class ${app.name}Station { #foreach($s_attribute in $app.station) $s_attribute.type $s_attribute.name, #end public $app.name Station(#foreach($s_attribute in $app.station) $s_attribute.type $s_attribute.name; #end) { #foreach($s_attribute in $app.station) $s_attribute.name=$s_attribute.name; #end } #foreach($s_attribute in $app.station) public ${s_attribute.type} get${s_attribute.name}() { return get${s_attribute.name}(); } #end }
The problem is s_attribute.name first character is lowercase. When I create getter and setter function for attributes. I need change first character to uppercase.
Did anyone know how to do it?
A small diameter tubing string, often coiled tubing that is suspended inside the existing production tubing. By occupying part of the flow path space, the velocity of the produced fluid is increased and the potential to lift water from the well is increased.
Velocity can be used to generate web pages, SQL, PostScript and other output from templates. It can be used either as a standalone utility for generating source code and reports, or as an integrated component of other systems.
In the code you posted: there 2 ways to run velocity: running the main (but this is not what you do when you build your project) running ant form but since you don't fill any velocity context: velocity won't be able to replace the variable in your template (i.e. the generated html won't contains dynamic data)
A velocity code associates the location to a SKU's throughput. For example, fast moving items are stored in the lower level locations, or locations reachable by hand, in the bulk zone. Create a Velocity Code.
You can invoke standard java methods on these objects. If s_attribute.name
is type String you can directly use $s_attribute.name.toUpperCase()
or for your specific case use $s_attribute.name.substring(0,1).toUpperCase()
and $s_attribute.name.substring(1).toLowerCase()
There is capitalize()
method in DisplayTool
:
get${display.capitalize($s_attribute.name)}()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With