⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 domaintemplateprocess.java

📁 EasyJWeb是基于java技术
💻 JAVA
字号:
package com.easyjf.generator;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.velocity.context.Context;

import com.easyjf.web.tools.generator.TemplateProcess;

public class DomainTemplateProcess implements TemplateProcess {

	private String attributes;

	private String domainName;

	public DomainTemplateProcess(String domainName, String attributes) {
		this.setDomainName(domainName);
		this.setAttributes(attributes);
	}

	public void process(Context context) throws Exception {
		String[] parms = this.getAttributes().split("#");
		List<Map> fields = new ArrayList<Map>();
		for (int i = 0; i < parms.length; i++) {
			String[] field = parms[i].split(":");
			String Name = field[0].substring(0, 1).toUpperCase()
					+ field[0].substring(1);
			String Type = field[2].substring(0, 1).toUpperCase()
					+ field[2].substring(1);
			if ("Email".equals(Type)) {
				Type = "String";
			}
			Map map = new HashMap();
			map.put("name", field[0]);
			map.put("Name", Name);
			map.put("alias", field[1]);
			map.put("type", field[2].toLowerCase());
			map.put("Type", Type);
			map.put("length", field[3]);
			if (field.length >= 5)
				map.put("validatorName", field[4]);
			fields.add(map);
		}
		Object svuid = Math.random() < 0.1 ? "-" : ""
				+ Math.round(Math.pow(10, 17) * Math.random()) + "L";
		context.put("svuid", svuid);
		context.put("nowTime", new java.util.Date().toString());
		context.put("domainName", this.getDomainName());
		context.put("fields", fields);
	}

	public String getAttributes() {
		return attributes;
	}

	public void setAttributes(String attributes) {
		this.attributes = attributes;
	}

	public String getDomainName() {
		return domainName;
	}

	public void setDomainName(String domainName) {
		this.domainName = domainName;
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -