public class BeanGenerator {
/**
* 实体名称
*/
private final static String BEAN_NAME = "${beanName}";
private final static String BEAN_SINCE = "${since}";
private final static String BEAN_VERSION = "${version}";
private final static String BEAN_AUTHOR = "${author}";
private final static String BEAN_NAME_ONE_LOWER_CASE = "${beanNameOneLowerCase}";
/**
* 实体注释
*/
private final static String BEAN_NOTE = "${beanNote}";
private final static String BEAN_NOTE_ONE_LOWER_CASE = "${beanNoteOneLowerCase}";
/**
* 属性循环开始
*/
private final static String PARAMETER_FOR_BEGIN = "${parameterBegin}";
/**
* 属性循环结束
*/
private final static String PARAMETER_FOR_END = "${parameterEnd}";
/**
* 属性名称
*/
private final static String PARAMETER_NAME = "${parameterName}";
private final static String PARAMETER_NAME_ONE_LOWER_CASE = "${parameterNameOneLowerCase}";
private final static String PARAMETER_NAME_ONE_UPPER_CASE = "${parameterNameOneUpperCase}";
private final static String PARAMETER_NAME_ALL_LOWER_CASE = "${parameterNameAllLowerCase}";
private final static String PARAMETER_NAME_ALL_UPPER_CASE = "${parameterNameAllUpperCase}";
/**
* 属性注释
*/
private final static String PARAMETER_NOTE = "${parameterNote}";
private final static String PARAMETER_NOTE_ONE_LOWER_CASE = "${parameterNoteOneLowerCase}";
private final static String PARAMETER_NOTE_ONE_UPPER_CASE = "${parameterNoteOneUpperCase}";
private final static String PARAMETER_NOTE_ALL_LOWER_CASE = "${parameterNoteAllLowerCase}";
private final static String PARAMETER_NOTE_ALL_UPPER_CASE = "${parameterNoteAllUpperCase}";
/**
* 属性类别
*/
private final static String PARAMETER_CLASS = "${parameterClass}";
private final static String PARAMETER_CLASS_ONE_LOWER_CASE = "${parameterClassOneLowerCase}";
private final static String PARAMETER_CLASS_ONE_UPPER_CASE = "${parameterClassOneUpperCase}";
private final static String PARAMETER_CLASS_ALL_LOWER_CASE = "${parameterClassAllLowerCase}";
private final static String PARAMETER_CLASS_ALL_UPPER_CASE = "${parameterClassAllUpperCase}";
private final static String BEAN_ALL_PARAMETERS_SET = "${allParametersSet}";
private final static String BEAN_ALL_PARAMETERS = "${allParameters}";
private final static String BEAN_ALL_PARAMETERS_STR = "${allParametersStr}";
private final static String BEAN_ALL_PARAMETERS_COMMENT = "${allParametersComment}";
private String importBeanExcelPath = "";
private String outputBasePath = "";
private String[] templatePaths = {
};
private List<Bean> beans;
private HSSFWorkbook hssfWorkbook;
private HSSFSheet hssfSheet;
private HSSFRow hssfRow;
private HSSFCell hssfCell;
private BufferedReader bufferedReader;
public BeanGenerator(String[] templatePaths, String importBeanExcelPath,
String outputBasePath) throws IOException {
this.templatePaths = templatePaths;
this.importBeanExcelPath = importBeanExcelPath;
this.outputBasePath = outputBasePath;
init();
}
public void init() throws IOException {
File file = new File(importBeanExcelPath);
FileInputStream fileInputStream = new FileInputStream(file);
hssfWorkbook = new HSSFWorkbook(fileInputStream);
if(hssfWorkbook.getNumberOfSheets()>1){
beans = new ArrayList<Bean>(hssfWorkbook.getNumberOfSheets()-1);
}else{
throw new IOException("workbook has no table sheets.");
}
}
/**
* 根据行列,返回EXCEL中cell的字符串
* @param row
* @param col
* @return
*/
private String cellValue(int row, int col) {
String value = null;
hssfRow = hssfSheet.getRow(row);
if (Util.isNull(hssfRow))
return null;
hssfCell = hssfRow.getCell((short) col);
if (Util.isNull(hssfCell))
return null;
value = hssfCell.getStringCellValue();
return value.trim();
}
分享到:
相关推荐
2. **Callback**:在CGLib中,Callback接口是回调函数的抽象,用于定义代理对象的方法执行行为。常用的Callback实现有MethodInterceptor,它允许我们在方法调用前后插入自定义逻辑。 3. **MethodInterceptor**:这...
2. CGLIB代理:如果目标bean没有实现任何接口,Spring会使用CGLIB库创建一个新的子类来作为代理。CGLIB是一个代码生成库,可以动态地生成一个类的子类,并重写其方法,从而插入额外的行为。 为了动态地为bean增加新...
2. **元数据获取**:工具通过JDBC连接到数据库,获取表的元数据,包括表名、字段名、字段类型、主键信息等。 3. **生成Bean**:根据元数据,generator自动生成Java Bean类。每个表对应一个Java类,类的属性对应表的...
2. **创建项目**: 创建新项目时,选择OWL Flies作为项目类型,点击Finish,不选择Next,这样就可以开始构建基于OWL的本体模型。 3. **OWL Classes**: OWL Classes代表概念或类别,是本体的核心元素。在Protege中,...
Step 2: 创建类 在 Protege 的主页面中,选择 OWL Classes 并点击“Create subclass”或右键点击 OWL:Thing 选择“Createsubclass”。然后,在 Class Editor 中输入类名“Animal”。 Step 3: 创建子类 在 Animal ...
直接输入java SqlToBean会出现如下帮助信息:H:BeanGenerator>java SqlToBean/**@author godblessyou@Date: 2005-05-06@OICQ: 345343747@param s:sourceFile "demo.sql" NaviCat导出的sql脚本文件,最好与...
- **导出本体**:可以将Protege构建的OWL本体导出为其他格式,如JADE的本体类,利用工具如beangenerator.jar进行转换。 9. **本体应用**: - **推理**:Protege支持基于OWL的推理,根据定义的类和属性,系统能够...
- 你需要编写一个Java程序,例如`BeanGenerator.java`和`BeanInfo.java`,这两个类可以生成JavaBean的get和set方法。 - 将编译后的jar文件放在EditPlus的plugins目录下,并设置好CLASSPATH环境变量。 - 在...