本文整理汇总了Java中com.jfinal.kit.StrKit类的典型用法代码示例。如果您正苦于以下问题:Java StrKit类的具体用法?Java StrKit怎么用?Java StrKit使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StrKit类属于com.jfinal.kit包,在下文中一共展示了StrKit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generate
import com.jfinal.kit.StrKit; //导入依赖的package包/类
@Override
public void generate(List<TableMeta> tableMetas) {
System.out.println("Generate base model ...");
System.out.println("Base Model Output Dir: " + baseModelOutputDir);
Engine engine = Engine.create("forServiceImpl");
engine.setSourceFactory(new ClassPathSourceFactory());
engine.addSharedMethod(new StrKit());
engine.addSharedObject("getterTypeMap", getterTypeMap);
engine.addSharedObject("javaKeyword", javaKeyword);
for (TableMeta tableMeta : tableMetas) {
genBaseModelContent(tableMeta);
}
writeToFile(tableMetas);
}
示例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;
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 "";
}
示例3: generateMappingModel
import com.jfinal.kit.StrKit; //导入依赖的package包/类
public void generateMappingModel(Object projectId, String templatePath) {
if ( StrKit.isBlank(templatePath) ) templatePath = MAVEN_BASE + "gen/config/4jfinalmappingmodel.btl";
Template t_pojo = gt.getTemplate(templatePath);
List<Record> list = Db.find("select a.*, b.name primary_name, b.java_type, c.package, c.module_name from w_db_model a, w_db_model_item b, w_generate c where a.id = b.w_model_id and c.w_model_id = a.id and b.is_primary = 1 and a.project_id = ?", projectId);
t_pojo.binding("models", list);
File file = getConfigGenerateFile(
File.separator + "org" +
File.separator + "hacker" +
File.separator + "core" +
File.separator + "config",
"MappingModel.java");
System.out.println(file.getAbsolutePath());
try {
FileKit.write(t_pojo.render(), file);
} catch ( FileNotFoundException | BeetlException e ) {
e.printStackTrace();
}
System.out.println("############getGenerateConfig success############");
}
示例4: generateMappingRoute
import com.jfinal.kit.StrKit; //导入依赖的package包/类
public void generateMappingRoute(Object projectId, String templatePath) {
if ( StrKit.isBlank(templatePath) ) templatePath = MAVEN_BASE + "gen/config/4jfinalmappingroute.btl";
Template t_pojo = gt.getTemplate(templatePath);
List<Record> list = Db.find("select a.*, b.name primary_name, b.java_type, c.package, c.module_name from w_db_model a, w_db_model_item b, w_generate c where a.id = b.w_model_id and c.w_model_id = a.id and b.is_primary = 1 and a.project_id = ?", projectId);
t_pojo.binding("models", list);
File file = getConfigGenerateFile(
File.separator + "org" +
File.separator + "hacker" +
File.separator + "core" +
File.separator + "config",
"MappingRoute.java");
System.out.println(file.getAbsolutePath());
try {
FileKit.write(t_pojo.render(), file);
} catch ( FileNotFoundException | BeetlException e ) {
e.printStackTrace();
}
System.out.println("############getGenerateConfig success############");
}
示例5: generate
import com.jfinal.kit.StrKit; //导入依赖的package包/类
@Override
public void generate(List<TableMeta> tableMetas) {
System.out.println("Generate base model ...");
System.out.println("Base Model Output Dir: " + baseModelOutputDir);
Engine engine = Engine.create("forService");
engine.setSourceFactory(new ClassPathSourceFactory());
engine.addSharedMethod(new StrKit());
engine.addSharedObject("getterTypeMap", getterTypeMap);
engine.addSharedObject("javaKeyword", javaKeyword);
for (TableMeta tableMeta : tableMetas) {
genBaseModelContent(tableMeta);
}
writeToFile(tableMetas);
}
示例6: create
import com.jfinal.kit.StrKit; //导入依赖的package包/类
public void create(){
ResultData result = new ResultData();
String parentPath=getPara("parentPath");
if(StrKit.isBlank(parentPath)){
parentPath="/";
}
String nodeName=getPara("nodeName");
nodeName= StringUtil.rtrim(nodeName,new char[]{'/'});
String nodeData=getPara("nodeData");
Integer mode=getParaToInt("nodeType");
try{
ZkClient zkClient=getSessionAttr("zk-client");
ZKPlugin zkPlugin=new ZKPlugin(zkClient);
if(!parentPath.equals("/")) {
nodeName = parentPath + "/" + nodeName;
}else{
nodeName = "/" + nodeName;
}
zkPlugin.create(nodeName,nodeData.getBytes(),mode);
result.setMessage("创建成功");
} catch (Exception e) {
result.setSuccess(false);
result.setMessage("创建失败");
}
renderJson(result);
}
示例7: modify
import com.jfinal.kit.StrKit; //导入依赖的package包/类
public void modify(){
ResultData result = new ResultData();
String parentPath=getPara("parentPath");
if(StrKit.isBlank(parentPath)){
parentPath="/";
}
String nodeData=getPara("nodeData");
try{
ZkClient zkClient=getSessionAttr("zk-client");
ZKPlugin zkPlugin=new ZKPlugin(zkClient);
if(zkClient.exists(parentPath)) {
zkPlugin.edit(parentPath, nodeData.getBytes());
result.setMessage("数据修改成功");
}else{
result.setSuccess(false);
result.setMessage("节点路径不存在失败");
}
}catch (Exception e){
result.setSuccess(false);
result.setMessage("数据修改失败");
log.error("数据修改失败,错误",e);
}
renderJson(result);
}
示例8: configRoute
import com.jfinal.kit.StrKit; //导入依赖的package包/类
/**
* 路由配置
*/
@SuppressWarnings("unchecked")
public void configRoute(Routes routes) {
List<Class<Controller>> controllerClassList = ClassScaner.scanSubClass(Controller.class);
if (controllerClassList != null) {
for (Class<?> clazz : controllerClassList) {
UrlMapping urlMapping = clazz.getAnnotation(UrlMapping.class);
if (null != urlMapping && StringUtils.isNotBlank(urlMapping.url())) {
if (StrKit.notBlank(urlMapping.viewPath())) {
routes.add(urlMapping.url(), (Class<? extends Controller>) clazz, urlMapping.viewPath());
} else {
routes.add(urlMapping.url(), (Class<? extends Controller>) clazz);
}
}
}
}
}
示例9: logFromConfig
import com.jfinal.kit.StrKit; //导入依赖的package包/类
private void logFromConfig(Controller c, LogConfig log) {
SysLog sysLog = new SysLog();
sysLog.ip = ServletKit.getIp(c.getRequest());
sysLog.user = logProcesser.getUsername(c);
Map<String, String[]> parameterMap = c.getRequest().getParameterMap();
Set<Entry<String, String[]>> entrySet = parameterMap.entrySet();
Map<String, String> paraMap = Maps.newHashMap();
for (Entry<String, String[]> entry : entrySet) {
String key = entry.getKey();
String value = entry.getValue()[0];
String result = log.params.get(key);
if (StrKit.isBlank(result))
continue;
paraMap.put(result, value);
}
sysLog.message = logProcesser.formatMessage(log.title, paraMap);
logProcesser.process(sysLog);
}
示例10: wirtToFile
import com.jfinal.kit.StrKit; //导入依赖的package包/类
/**
* 若 model 文件存在,则不生成,以免覆盖用户手写的代码
*/
protected void wirtToFile(TableMeta tableMeta) throws IOException {
String pre =tableMeta.name.toLowerCase().replace("_", "").replace(tableMeta.modelName.toLowerCase(), "");
String outDir =serviceOutputDir;
if(StrKit.notBlank(pre)){
outDir = serviceOutputDir + File.separator + pre;
}
File dir = new File(outDir);
if (!dir.exists()) dir.mkdirs();
String target = outDir + File.separator + tableMeta.modelName+"Service" + ".java";
File file = new File(target);
if (file.exists()) {
return; // 若 serivce 存在,不覆盖
}
FileWriter fw = new FileWriter(file);
try {
fw.write(tableMeta.modelContent);
} finally {
fw.close();
}
}
示例11: wirtToFile
import com.jfinal.kit.StrKit; //导入依赖的package包/类
protected void wirtToFile(TableMeta tableMeta) throws IOException {
String pre = tableMeta.name.toLowerCase().replace("_", "").replace(tableMeta.modelName.toLowerCase(), "");
String outDir = baseModelOutputDir;
if (StrKit.notBlank(pre)) {
outDir = baseModelOutputDir + File.separator + pre;
}
File dir = new File(outDir);
if (!dir.exists()) dir.mkdirs();
String target = outDir + File.separator + tableMeta.baseModelName + ".java";
FileWriter fw = new FileWriter(target);
try {
fw.write(tableMeta.baseModelContent);
} finally {
fw.close();
}
}
示例12: loadJobsFromProperties
import com.jfinal.kit.StrKit; //导入依赖的package包/类
private void loadJobsFromProperties() {
if (StrKit.isBlank(jobConfig)) {
return;
}
jobProp = ResourceKit.readProperties(jobConfig);
Set<Map.Entry<String, String>> entries = jobProp.entrySet();
for (Map.Entry<String, String> entry : entries) {
String key = entry.getKey();
if (!key.endsWith(JOB) || !isEnableJob(enable(key))) {
continue;
}
String jobClassName = jobProp.get(key) + "";
String jobCronExp = jobProp.get(cronKey(key)) + "";
Class<Job> job = Reflect.on(jobClassName).get();
try {
jobs.put(job.newInstance(), jobCronExp);
} catch (Exception e) {
Throwables.propagate(e);
}
}
}
示例13: getPath
import com.jfinal.kit.StrKit; //导入依赖的package包/类
private String getPath(String property) {
if (StrKit.isBlank(property) || (!"downloads".equals(property) && !"uploads".equals(property))) {
throw new IllegalArgumentException("property is invalid, property just use `downloads` or `uploads`");
}
this.loadPropertyFile();
String app = this.getAppName();
String baseDir = this.getProperty(String.format("app.%s.basedir", property));
if (baseDir.endsWith("/")) {
if (!baseDir.endsWith(property+"/")) {
baseDir += (property+"/");
}
}else{
if (!baseDir.endsWith(property)) {
baseDir += ("/"+property+"/");
}else{
baseDir += "/";
}
}
return (new StringBuilder(baseDir).append(app).toString());
}
示例14: initSender
import com.jfinal.kit.StrKit; //导入依赖的package包/类
private void initSender() {
jmsSender = new JmsSender();
jmsSender.queueProducers = Maps.newHashMap();
String sendQueues = JmsConfig.getStr("sendQueues");
logger.debug("sendQueues :" + sendQueues);
if (StrKit.notBlank(sendQueues)) {
for (String queueName : sendQueues.split(",")) {
jmsSender.queueProducers.put(queueName, new QueueProducer(serverUrl, username, password, queueName));
}
}
String sendTopics = JmsConfig.getStr("sendTopics");
logger.debug("sendTopics :" + sendTopics);
if (StrKit.notBlank(sendTopics)) {
jmsSender.topicPublishers = Maps.newHashMap();
for (String topicName : sendTopics.split(",")) {
jmsSender.topicPublishers.put(topicName, new TopicPublisher(serverUrl, username, password, topicName));
}
}
}
示例15: loadJobsFromProperties
import com.jfinal.kit.StrKit; //导入依赖的package包/类
private void loadJobsFromProperties() {
if (StrKit.isBlank(config)) {
return;
}
jobProp = ResourceKit.readProperties(config);
Set<Map.Entry<String, String>> entries = jobProp.entrySet();
for (Map.Entry<String, String> entry : entries) {
String key = entry.getKey();
if (!key.endsWith(JOB) || !isEnableJob(enable(key))) {
continue;
}
String jobClassName = jobProp.get(key) + "";
String jobCronExp = jobProp.get(cronKey(key)) + "";
Class<Runnable> clazz = Reflect.on(jobClassName).get();
try {
jobs.put(clazz.newInstance(), jobCronExp);
} catch (Exception e) {
Throwables.propagate(e);
}
}
}