本文整理汇总了Java中com.jfinal.kit.StrKit.firstCharToUpperCase方法的典型用法代码示例。如果您正苦于以下问题:Java StrKit.firstCharToUpperCase方法的具体用法?Java StrKit.firstCharToUpperCase怎么用?Java StrKit.firstCharToUpperCase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jfinal.kit.StrKit
的用法示例。
在下文中一共展示了StrKit.firstCharToUpperCase方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: call
import com.jfinal.kit.StrKit; //导入方法依赖的package包/类
@Override
public Object call(Object[] paras, Context ctx) {
Object o = paras[0];
if (o != null) {
try {
String name = (String)o;
String[] names = name.split("_");
if(names.length == 1) {
return StrKit.firstCharToUpperCase(names[0]);
}
StringBuffer sb = new StringBuffer();
for(int i = 0; i < names.length; i++) {
sb.append(StrKit.firstCharToUpperCase(names[i]));
}
ctx.byteWriter.writeString(sb.toString());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return "";
}
示例2: call
import com.jfinal.kit.StrKit; //导入方法依赖的package包/类
@Override
public Object call(Object[] paras, Context ctx) {
Object o = paras[0];
if (o != null) {
try {
String name = (String)o;
return StrKit.firstCharToUpperCase(name);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return "";
}
示例3: call
import com.jfinal.kit.StrKit; //导入方法依赖的package包/类
@Override
public Object call(Object[] paras, Context ctx) {
Object o = paras[0];
// 对于枚举是类的名字,对于array是泛型类型
Object v = paras[1];
if ( o != null ) {
try {
String type = (String) o;
switch ( type ) {
case "string":
return "String";
case "integer":
return "Integer";
case "boolean":
return "Boolean";
case "number":
return "BigDecimal";
case "date":
return "Date";
case "object":
return "JSONObject";
// 特殊的是枚举和数组
// 数组目前只能支持java的基础类型,enum不支持
case "array":
return "List<" + StrKit.firstCharToUpperCase(v.toString()) + ">";
case "enum":
return StrKit.firstCharToUpperCase(v.toString());
default:
throw new Error("不支持: " + type);
}
} catch ( Exception e ) {
throw new RuntimeException(e);
}
}
return "";
}
示例4: camelNameConvert
import com.jfinal.kit.StrKit; //导入方法依赖的package包/类
private String camelNameConvert(String name) {
String[] names = name.split("_");
if(names.length == 1) {
return StrKit.firstCharToUpperCase(names[0]);
}
StringBuffer sb = new StringBuffer();
for(int i = 0; i < names.length; i++) {
sb.append(StrKit.firstCharToUpperCase(names[i]));
}
return sb.toString();
}
示例5: genSetMethodName
import com.jfinal.kit.StrKit; //导入方法依赖的package包/类
@Override
protected void genSetMethodName(ColumnMeta columnMeta, StringBuilder ret) {
ret.append(JbaseGenerator.getRemark(columnMeta));
String setterMethodName = "set" + StrKit.firstCharToUpperCase(StrKit.toCamelCase(columnMeta.name));
String attrName = StrKit.toCamelCase(columnMeta.name);
String setter = String.format(setterTemplate, setterMethodName, attrName, columnMeta.name, attrName);
ret.append(setter);
}
示例6: genIsNullMethod
import com.jfinal.kit.StrKit; //导入方法依赖的package包/类
private void genIsNullMethod(ColumnMeta columnMeta, StringBuilder ret) {
ret.append(JbaseGenerator.getRemark(columnMeta));
String methodName = "isNull" + StrKit.firstCharToUpperCase(StrKit.toCamelCase(columnMeta.name));
String setter = String.format(isNullTemplate, methodName, columnMeta.name);
ret.append(setter);
}
示例7: generateInterfaceControllerCode
import com.jfinal.kit.StrKit; //导入方法依赖的package包/类
public void generateInterfaceControllerCode(Object projectId, String classPath, String beanClassPath, String templatePath) {
if ( StrKit.isBlank(templatePath) ) templatePath = MAVEN_BASE + "gen/web/4interfaceControllerTemp00.btl";
Template t_controller = gt.getTemplate(templatePath);
Project project = Project.dao.findById(projectId);
if ( project == null ) return;
List<Folder> folderList = Folder.dao.find("SELECT * FROM w_folder WHERE w_project_id = ?", projectId);
if ( folderList == null ) return;
// 一个目录相当于一个controller
for ( Folder folder : folderList ) {
String moduleName = folder.getName().toLowerCase();
String className = StrKit.firstCharToUpperCase(folder.getName()) + "Controller";
String controllerClassPath = classPath +
File.separator + "module" +
File.separator + moduleName +
File.separator + "controller";
File file = getConfigGenerateFile(controllerClassPath, className + ".java");
t_controller.binding("classPath", classPath.replaceAll(Matcher.quoteReplacement(File.separator), "."));
t_controller.binding("moduleName", moduleName);
t_controller.binding("className", className);
t_controller.binding("beanClassPath", beanClassPath.replaceAll(Matcher.quoteReplacement(File.separator), "."));
// 获取接口
List<Interface> interfaceList = Interface.dao.find("SELECT * FROM w_interface WHERE w_project_id = ? AND w_folder_id = ? order by seq asc", projectId, folder.getId());
List<String> beanNameList = new ArrayList<>();
// 特殊的没有bean的接口,使用接口code -> 参数名字来做存储
/**
* @ActionKey("/root/xx/${hhId}")
* public void xx() {}
* xx -> hhId
*
* xx 就是接口的code
*/
Map<String, String> interfaceParamMap = new HashMap<>();
// 没有参数的接口map
Map<String, String> noParaminterfaceMap = new HashMap<>();
for ( Interface anInterface : interfaceList ) {
boolean hasBean = Db.findFirst("SELECT COUNT(1) FROM w_parameter WHERE w_interface_id = ?", anInterface.getId()).getLong("COUNT(1)") > 0;
if ( StrKit.notBlank(anInterface.getCode()) && hasBean ) {
beanNameList.add(StrKit.firstCharToUpperCase(anInterface.getCode()) + "Bean");
} else {
noParaminterfaceMap.put(anInterface.getCode(), "no bean");
}
// 没有参数
boolean isUrlParam = false;
String url = anInterface.getRelativeUrl();
if ( StrKit.isBlank(url) ) {
System.err.println(String.format("接口[%s:(%s)]没有填写url", anInterface.getName(), anInterface.getCode()));
continue;
}
isUrlParam = url.matches(".*/\\$\\{[A-Za-z_]+\\}$");
if ( StrKit.notBlank(anInterface.getCode()) && isUrlParam ) {
int start = url.indexOf("/${");
int end = url.indexOf("}");
url = url.substring(start + 3, end);
// 将${}中的东西写入
interfaceParamMap.put(anInterface.getCode(), url);
}
}
t_controller.binding("interfaceParamMap", interfaceParamMap);
t_controller.binding("beanNameList", beanNameList);
t_controller.binding("interfaceList", interfaceList);
t_controller.binding("noParaminterfaceMap", noParaminterfaceMap);
System.out.println(file.getAbsolutePath());
try {
FileKit.write(t_controller.render(), file);
} catch ( Exception e ) {
e.printStackTrace();
}
}
System.out.println("############Generate interface controller code success############");
}
示例8: generateInterfaceServiceCode
import com.jfinal.kit.StrKit; //导入方法依赖的package包/类
/**
* 用户编写业务代码的service,为了防止生成controller和bean代码不被覆盖
* 这个方法在被调用时,需要做一次密码身份认证,以免菜鸟勿用
*
* @param projectId 项目id
* @param folderId 如果有该数据,只生成当前的目录接口的service,其他忽略
* @param classPath 生成代码的路径
* @param beanClassPath 相关bean代码的路径
* @param templatePath 使用的模版
*/
public void generateInterfaceServiceCode(Object projectId, Object folderId, String classPath, String beanClassPath, String templatePath) {
if ( StrKit.isBlank(templatePath) ) templatePath = MAVEN_BASE + "gen/web/4interfaceServiceTemp00.btl";
Template t_service = gt.getTemplate(templatePath);
Project project = Project.dao.findById(projectId);
if ( project == null ) return;
List<Folder> folderList = Folder.dao.find("SELECT * FROM w_folder WHERE w_project_id = ?", projectId);
if ( folderList == null ) return;
// 一个目录相当于一个controller
for ( Folder folder : folderList ) {
// 忽略其他folder目录下的service生成请求
if ( !( folderId != null && folderId.equals(folder.getId()) ) ) {
continue;
}
String moduleName = folder.getName().toLowerCase();
String className = "__" + StrKit.firstCharToUpperCase(folder.getName()) + "ControllerService__";
String serviceClassPath = classPath +
File.separator + "module" +
File.separator + moduleName +
File.separator + "service";
File file = getConfigGenerateFile(serviceClassPath, className + ".java");
t_service.binding("classPath", classPath.replaceAll(Matcher.quoteReplacement(File.separator), "."));
t_service.binding("moduleName", moduleName);
t_service.binding("className", className);
t_service.binding("beanClassPath", beanClassPath.replaceAll(Matcher.quoteReplacement(File.separator), "."));
// 获取接口
List<Interface> interfaceList = Interface.dao.find("SELECT * FROM w_interface WHERE w_project_id = ? AND w_folder_id = ? order by seq asc", projectId, folder.getId());
List<String> beanNameList = new ArrayList<>();
Map<String, String> interfaceParamMap = new HashMap<>();
for ( Interface anInterface : interfaceList ) {
boolean hasBean = Db.findFirst("SELECT COUNT(1) FROM w_parameter WHERE w_interface_id = ?", anInterface.getId()).getLong("COUNT(1)") > 0;
if ( StrKit.notBlank(anInterface.getCode()) && hasBean )
beanNameList.add(StrKit.firstCharToUpperCase(anInterface.getCode()) + "Bean");
// 没有参数
boolean isUrlParam = false;
String url = anInterface.getRelativeUrl();
isUrlParam = url.matches(".*/\\$\\{[A-Za-z_]+\\}$");
if ( StrKit.notBlank(anInterface.getCode()) && isUrlParam ) {
int start = url.indexOf("/${");
int end = url.indexOf("}");
url = url.substring(start + 3, end);
// 将${}中的东西写入
interfaceParamMap.put(anInterface.getCode(), url);
}
}
t_service.binding("interfaceParamMap", interfaceParamMap);
t_service.binding("beanNameList", beanNameList);
t_service.binding("interfaceList", interfaceList);
System.out.println(file.getAbsolutePath());
try {
FileKit.write(t_service.render(), file);
} catch ( Exception e ) {
e.printStackTrace();
}
}
System.out.println("############Generate interface service code success############");
}