use of kyj.Fx.dao.wizard.core.FxDaoResultSetConverter in project Gargoyle by callakrsos.
the class GargoyleDaoBaseFxExtractDaoMethod method resultSetConverter.
/* (non-Javadoc)
* @see kyj.Fx.dao.wizard.core.DaoBaseResultSetStatement#resultSetConverter()
*/
@Override
protected IResultSetConverter resultSetConverter() {
return new FxDaoResultSetConverter() {
@Override
public String convert(String varName, String resultSetVarName, TbpSysDaoColumnsDVO col) {
StringBuffer sb = new StringBuffer();
String columnName = col.getColumnName();
String columnType = col.getColumnType();
String programType = col.getProgramType();
sb.append(varName).append(".").append(setStatement(columnName)).append("(").append(getStatement(resultSetVarName, columnType, programType, columnName)).append(");");
return sb.toString();
}
@Override
public String getTypeTo(String columnType) {
return DatabaseTypeMappingResourceLoader.getInstance().get(columnType);
}
private String setStatement(String dbColumnName) {
String setter = "set" + getSetterStatement(dbColumnName);
return setter;
}
private String getStatement(String resultSetVarName, String columnType, String programType, String dbColumnName) {
String typeTo = getTypeTo(columnType);
if (programType != null && !programType.isEmpty()) {
typeTo = programType;
}
//ResultSet에서 getInteger라는 함수는 존재하지않으며, 대신 getInt라는 함수가 존재함.
if ("Integer".equals(typeTo)) {
typeTo = "Int";
} else if ("Long".equals(typeTo)) {
typeTo = "Long";
} else if ("Double".equals(typeTo)) {
typeTo = "Double";
}
return resultSetVarName + "." + "get" + typeTo + "(\"" + dbColumnName + "\")";
}
private String getSetterStatement(String str) {
StringTokenizer stringTokenizer = new StringTokenizer(str, "_");
String nextElement = null;
char[] charArray = null;
String temp = "";
while (stringTokenizer.hasMoreElements()) {
nextElement = (String) stringTokenizer.nextElement();
charArray = nextElement.toCharArray();
charArray[0] = Character.toUpperCase(charArray[0]);
for (int i = 1; i < charArray.length; i++) {
charArray[i] = Character.toLowerCase(charArray[i]);
}
temp += String.valueOf(charArray);
}
return temp;
}
};
}
use of kyj.Fx.dao.wizard.core.FxDaoResultSetConverter in project Gargoyle by callakrsos.
the class GargoyleDbUtilBaseFxExtractDaoMethod method resultSetConverter.
/* (non-Javadoc)
* @see kyj.Fx.dao.wizard.core.DaoBaseResultSetStatement#resultSetConverter()
*/
@Override
protected IResultSetConverter resultSetConverter() {
return new FxDaoResultSetConverter() {
@Override
public String convert(String varName, String resultSetVarName, TbpSysDaoColumnsDVO col) {
StringBuffer sb = new StringBuffer();
String columnName = col.getColumnName();
String columnType = col.getColumnType();
String programType = col.getProgramType();
sb.append(varName).append(".").append(setStatement(columnName)).append("(").append(getStatement(resultSetVarName, columnType, programType, columnName)).append(");");
return sb.toString();
}
@Override
public String getTypeTo(String columnType) {
return DatabaseTypeMappingResourceLoader.getInstance().get(columnType);
}
private String setStatement(String dbColumnName) {
String setter = "set" + getSetterStatement(dbColumnName);
return setter;
}
private String getStatement(String resultSetVarName, String columnType, String programType, String dbColumnName) {
String typeTo = getTypeTo(columnType);
if (programType != null && !programType.isEmpty()) {
typeTo = programType;
}
//ResultSet에서 getInteger라는 함수는 존재하지않으며, 대신 getInt라는 함수가 존재함.
if ("Integer".equals(typeTo)) {
typeTo = "Int";
} else if ("Long".equals(typeTo)) {
typeTo = "Long";
} else if ("Double".equals(typeTo)) {
typeTo = "Double";
}
return resultSetVarName + "." + "get" + typeTo + "(\"" + dbColumnName + "\")";
}
private String getSetterStatement(String str) {
StringTokenizer stringTokenizer = new StringTokenizer(str, "_");
String nextElement = null;
char[] charArray = null;
String temp = "";
while (stringTokenizer.hasMoreElements()) {
nextElement = (String) stringTokenizer.nextElement();
charArray = nextElement.toCharArray();
charArray[0] = Character.toUpperCase(charArray[0]);
for (int i = 1; i < charArray.length; i++) {
charArray[i] = Character.toLowerCase(charArray[i]);
}
temp += String.valueOf(charArray);
}
return temp;
}
};
}
Aggregations