📄 abstractcolumninfocache.java
字号:
package org.speedframework.cache;
import org.apache.log4j.Logger;
import org.speedframework.entity.CacheColumnBean;
import org.speedframework.entity.CacheTableBean;
import org.speedframework.exception.SpeedFrameworkException;
import org.speedframework.utilities.ColumnAnalyzer;
import org.speedframework.utilities.StringUtils;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* Class AbstractColumnInfoCache
*
* @author <a href="mailto:santafeng@gmail.com"> lizf </a>
* @version $Revision:1.0.0, $Date: 2007-10-9 8:20:41 $
*/
public abstract class AbstractColumnInfoCache implements IColumnInfoCache {
protected static final Logger log = Logger
.getLogger(AbstractColumnInfoCache.class);
protected CacheAction ca = new ColumnInfoCacheActionImpl();
/*
* (非 Javadoc)
*
* @see org.speedframework.cache.IColumnInfoCache#getColumnInfos(java.lang.Object)
*/
public String[] getColumnInfos(Object pojo) throws SpeedFrameworkException {
String[] colunm = null;
try {
String key = StringUtils.getExcuteTableName(pojo.getClass());
CacheTableBean ctb = (CacheTableBean) ca.get(key);
if (ctb != null) {
colunm = ColumnAnalyzer.getColumnName(ctb.getColumnList());
}
} catch (Exception e) {
throw new SpeedFrameworkException(
"Speed Table Colunm Cache is not support." + e);
}
return colunm;
}
/*
* (非 Javadoc)
*
* @see org.speedframework.cache.IColumnInfoCache#putColumnInfo(java.lang.Object,
* java.util.List)
*/
public void putColumnInfo(Object table, List columnInfo) throws Exception {
List colunm = null;
String tableName = StringUtils.getExcuteTableName(table.getClass());
Iterator it = columnInfo.iterator();
if (it.hasNext()) {
colunm = new ArrayList();
}
while (it.hasNext()) {
Map entity = (Map) it.next();
String columnName = (String) entity.get("field");
String primaryKey = (String) entity.get("pk");
String dataType = (String) entity.get("data_type");
String autoincrement = (String) entity.get("autoincrement");
String tableschem = (String) entity.get("tableschem");
CacheColumnBean ccb = new CacheColumnBean();
ccb.setColumnname(columnName.toLowerCase());
ccb.setDatatype(dataType.toLowerCase());
if ((primaryKey != null) && !primaryKey.equals("")) {
ccb.setPrimarykey(true);
}
if ((autoincrement != null) && !autoincrement.equals("")) {
ccb.setAutoincrement(true);
}
if (tableschem != null && !tableschem.equals("")) {
ccb.setTableschem(tableschem.trim());
}
colunm.add(ccb);
}
ca.save(tableName, colunm);
}
/*
* (非 Javadoc)
*
* @see org.speedframework.cache.IColumnInfoCache#getAutoIncrement(java.lang.Object)
*/
public String getAutoIncrement(Object pojo) throws Exception {
String colunm = null;
try {
String key = StringUtils.getExcuteTableName(pojo.getClass());
CacheTableBean ctb = (CacheTableBean) ca.get(key);
if (ctb != null) {
colunm = ColumnAnalyzer.getAutoIncrementColumnName(ctb
.getColumnList());
}
} catch (Exception e) {
throw new SpeedFrameworkException(
"Speed Table Colunm Cache is not support. " + e);
}
return colunm;
}
/*
* (非 Javadoc)
*
* @see org.speedframework.cache.IColumnInfoCache#getPrimaryKeyColumnInfos(java.lang.Object)
*/
public String[] getPrimaryKeyColumnInfos(Object pojo) throws Exception {
String[] colunm = null;
try {
String key = StringUtils.getExcuteTableName(pojo.getClass());
CacheTableBean ctb = (CacheTableBean) ca.get(key);
if (ctb != null) {
colunm = ColumnAnalyzer.getPrimaryColumnName(ctb
.getColumnList());
}
} catch (Exception e) {
throw new SpeedFrameworkException(
"Speed Table Colunm Cache is not support. " + e);
}
return colunm;
}
/*
* (非 Javadoc)
*
* @see org.speedframework.cache.IColumnInfoCache#getColumnInfoType(java.lang.Object,
* java.util.List)
*/
public String[][] getColumnInfoType(Object pojo, List paramName) {
String[][] colunm = null;
try {
String key = StringUtils.getExcuteTableName(pojo.getClass());
CacheTableBean ctb = (CacheTableBean) ca.get(key);
if (ctb != null) {
colunm = ColumnAnalyzer.getColumnType(ctb.getColumnList(),
paramName);
}
} catch (Exception e) {
throw new SpeedFrameworkException(
"Speed Table Colunm Cache is not support. " + e);
}
return colunm;
}
public String getTableschem(Object pojo) {
String tableschem = null;
try {
String key = StringUtils.getExcuteTableName(pojo.getClass());
CacheTableBean ctb = (CacheTableBean) ca.get(key);
if (ctb != null) {
tableschem = ColumnAnalyzer.getTableSchem(ctb.getColumnList());
}
} catch (Exception e) {
throw new SpeedFrameworkException(
"Speed Table Colunm Cache is not support. " + e);
}
return tableschem;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -