速度字符串功能 [英] Velocity string function
问题描述
我刚开始使用Java Velocity。
现在我想创建一个java类模板。
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
}
问题是s_attribute。 name第一个字符是小写。当我为属性创建getter和setter函数时。我需要将第一个字符更改为大写字母。
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.
有没有人知道怎么做?
推荐答案
你可以在这些对象上调用标准java方法。如果 s_attribute.name
是String类型,您可以直接使用 $ s_attribute.name.toUpperCase()
或针对您的具体情况使用 $ s_attribute.name.substring(0,1).toUpperCase()
和 $ s_attribute.name.substring(1).toLowerCase()
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()
这篇关于速度字符串功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!