데이터 변환 시 time, timestamp 추가.
This commit is contained in:
@@ -1,460 +1,462 @@
|
|||||||
package com.nexacro.spring.data.support;
|
package com.nexacro.spring.data.support;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.nexacro.spring.data.convert.NexacroConverter.ConvertiblePair;
|
import com.nexacro.spring.data.convert.NexacroConverter.ConvertiblePair;
|
||||||
import com.nexacro.spring.util.ReflectionUtil;
|
import com.nexacro.spring.util.ReflectionUtil;
|
||||||
import com.nexacro.xapi.data.ColumnHeader;
|
import com.nexacro.xapi.data.ColumnHeader;
|
||||||
import com.nexacro.xapi.data.DataSet;
|
import com.nexacro.xapi.data.DataSet;
|
||||||
import com.nexacro.xapi.data.DataTypes;
|
import com.nexacro.xapi.data.DataTypes;
|
||||||
import com.nexacro.xapi.data.Variable;
|
import com.nexacro.xapi.data.Variable;
|
||||||
import com.nexacro.xapi.data.datatype.DataType;
|
import com.nexacro.xapi.data.datatype.DataType;
|
||||||
import com.nexacro.xapi.data.datatype.DataTypeFactory;
|
import com.nexacro.xapi.data.datatype.DataTypeFactory;
|
||||||
import com.nexacro.xapi.data.datatype.PlatformDataType;
|
import com.nexacro.xapi.data.datatype.PlatformDataType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>DataSet혹은 Variable의 데이터 변환을 위한 helper class
|
* <p>DataSet혹은 Variable의 데이터 변환을 위한 helper class
|
||||||
*
|
*
|
||||||
* @author Park SeongMin
|
* @author Park SeongMin
|
||||||
* @since 2015. 7. 28.
|
* @since 2015. 7. 28.
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
* @see
|
* @see
|
||||||
*/
|
*/
|
||||||
public abstract class NexacroConverterHelper {
|
public abstract class NexacroConverterHelper {
|
||||||
|
|
||||||
private static final Set<ConvertiblePair> listToDataSetConvertibleSets = Collections.singleton(new ConvertiblePair(List.class, DataSet.class));
|
private static final Set<ConvertiblePair> listToDataSetConvertibleSets = Collections.singleton(new ConvertiblePair(List.class, DataSet.class));
|
||||||
private static final Set<ConvertiblePair> dataSetToListConvertibleSets = Collections.singleton(new ConvertiblePair(DataSet.class, List.class));
|
private static final Set<ConvertiblePair> dataSetToListConvertibleSets = Collections.singleton(new ConvertiblePair(DataSet.class, List.class));
|
||||||
|
|
||||||
private static final Set<ConvertiblePair> objectToVariableConvertibleSets = new HashSet<ConvertiblePair>();
|
private static final Set<ConvertiblePair> objectToVariableConvertibleSets = new HashSet<ConvertiblePair>();
|
||||||
private static final Set<ConvertiblePair> variableToObjectConvertibleSets = new HashSet<ConvertiblePair>();
|
private static final Set<ConvertiblePair> variableToObjectConvertibleSets = new HashSet<ConvertiblePair>();
|
||||||
|
|
||||||
private static final Map<Class<?>, Class<?>> primitiveTypeWrapperMap = new HashMap<Class<?>, Class<?>>(8);
|
private static final Map<Class<?>, Class<?>> primitiveTypeWrapperMap = new HashMap<Class<?>, Class<?>>(8);
|
||||||
private static final Map<Class<?>, Class<?>> nonPrimitiveTypeMap = new HashMap<Class<?>, Class<?>>(4);
|
private static final Map<Class<?>, Class<?>> nonPrimitiveTypeMap = new HashMap<Class<?>, Class<?>>(4);
|
||||||
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// byte[], int, long, float, double, boolean, Object, String, BigDecimal, Date
|
// byte[], int, long, float, double, boolean, Object, String, BigDecimal, Date
|
||||||
// byte, char, short는 지원하지 않는다.
|
// byte, char, short는 지원하지 않는다.
|
||||||
primitiveTypeWrapperMap.put(byte[].class, Byte[].class);
|
primitiveTypeWrapperMap.put(byte[].class, Byte[].class);
|
||||||
// 아래 항목 지원 시 데이터 유실이 발생할 수 있다.
|
// 아래 항목 지원 시 데이터 유실이 발생할 수 있다.
|
||||||
// primitiveWrapperTypeMap.put(byte.class, Byte.class);
|
// primitiveWrapperTypeMap.put(byte.class, Byte.class);
|
||||||
// primitiveWrapperTypeMap.put(char.class, Character.class);
|
// primitiveWrapperTypeMap.put(char.class, Character.class);
|
||||||
// primitiveWrapperTypeMap.put(short.class, Short.class);
|
// primitiveWrapperTypeMap.put(short.class, Short.class);
|
||||||
primitiveTypeWrapperMap.put(int.class, Integer.class);
|
primitiveTypeWrapperMap.put(int.class, Integer.class);
|
||||||
primitiveTypeWrapperMap.put(long.class, Long.class);
|
primitiveTypeWrapperMap.put(long.class, Long.class);
|
||||||
primitiveTypeWrapperMap.put(float.class, Float.class);
|
primitiveTypeWrapperMap.put(float.class, Float.class);
|
||||||
primitiveTypeWrapperMap.put(double.class, Double.class);
|
primitiveTypeWrapperMap.put(double.class, Double.class);
|
||||||
primitiveTypeWrapperMap.put(boolean.class, Boolean.class);
|
primitiveTypeWrapperMap.put(boolean.class, Boolean.class);
|
||||||
|
|
||||||
nonPrimitiveTypeMap.put(Object.class, Object.class);
|
nonPrimitiveTypeMap.put(Object.class, Object.class);
|
||||||
nonPrimitiveTypeMap.put(String.class, String.class);
|
nonPrimitiveTypeMap.put(String.class, String.class);
|
||||||
nonPrimitiveTypeMap.put(BigDecimal.class, BigDecimal.class);
|
nonPrimitiveTypeMap.put(BigDecimal.class, BigDecimal.class);
|
||||||
nonPrimitiveTypeMap.put(Date.class, Date.class);
|
nonPrimitiveTypeMap.put(Date.class, Date.class);
|
||||||
nonPrimitiveTypeMap.put(java.sql.Date.class, java.sql.Date.class); // used java.util.map in ibatis
|
nonPrimitiveTypeMap.put(java.sql.Date.class, java.sql.Date.class); // used java.util.map in ibatis
|
||||||
|
nonPrimitiveTypeMap.put(java.sql.Timestamp.class, java.sql.Timestamp.class); // used java.util.map in ibatis
|
||||||
Set<Class<?>> keySet = primitiveTypeWrapperMap.keySet();
|
nonPrimitiveTypeMap.put(java.sql.Time.class, java.sql.Time.class); // used java.util.map in ibatis
|
||||||
for(Class<?> clazz: keySet) {
|
|
||||||
objectToVariableConvertibleSets.add(new ConvertiblePair(clazz, Variable.class));
|
Set<Class<?>> keySet = primitiveTypeWrapperMap.keySet();
|
||||||
objectToVariableConvertibleSets.add(new ConvertiblePair(primitiveTypeWrapperMap.get(clazz), Variable.class));
|
for(Class<?> clazz: keySet) {
|
||||||
}
|
objectToVariableConvertibleSets.add(new ConvertiblePair(clazz, Variable.class));
|
||||||
for(Class<?> clazz: keySet) {
|
objectToVariableConvertibleSets.add(new ConvertiblePair(primitiveTypeWrapperMap.get(clazz), Variable.class));
|
||||||
variableToObjectConvertibleSets.add(new ConvertiblePair(Variable.class, clazz));
|
}
|
||||||
variableToObjectConvertibleSets.add(new ConvertiblePair(Variable.class, primitiveTypeWrapperMap.get(clazz)));
|
for(Class<?> clazz: keySet) {
|
||||||
}
|
variableToObjectConvertibleSets.add(new ConvertiblePair(Variable.class, clazz));
|
||||||
|
variableToObjectConvertibleSets.add(new ConvertiblePair(Variable.class, primitiveTypeWrapperMap.get(clazz)));
|
||||||
Set<Class<?>> nonKeySet = nonPrimitiveTypeMap.keySet();
|
}
|
||||||
for(Class<?> clazz: nonKeySet) {
|
|
||||||
objectToVariableConvertibleSets.add(new ConvertiblePair(clazz, Variable.class));
|
Set<Class<?>> nonKeySet = nonPrimitiveTypeMap.keySet();
|
||||||
}
|
for(Class<?> clazz: nonKeySet) {
|
||||||
for(Class<?> clazz: nonKeySet) {
|
objectToVariableConvertibleSets.add(new ConvertiblePair(clazz, Variable.class));
|
||||||
variableToObjectConvertibleSets.add(new ConvertiblePair(Variable.class, clazz));
|
}
|
||||||
}
|
for(Class<?> clazz: nonKeySet) {
|
||||||
|
variableToObjectConvertibleSets.add(new ConvertiblePair(Variable.class, clazz));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Set<ConvertiblePair> getObjectToVariableConvertibleTypes() {
|
}
|
||||||
return objectToVariableConvertibleSets;
|
|
||||||
}
|
static Set<ConvertiblePair> getObjectToVariableConvertibleTypes() {
|
||||||
|
return objectToVariableConvertibleSets;
|
||||||
static Set<ConvertiblePair> getVariableToObjectConvertibleTypes() {
|
}
|
||||||
return variableToObjectConvertibleSets;
|
|
||||||
}
|
static Set<ConvertiblePair> getVariableToObjectConvertibleTypes() {
|
||||||
|
return variableToObjectConvertibleSets;
|
||||||
static Set<ConvertiblePair> getListToDataSetConvertibleTypes() {
|
}
|
||||||
return listToDataSetConvertibleSets;
|
|
||||||
}
|
static Set<ConvertiblePair> getListToDataSetConvertibleTypes() {
|
||||||
|
return listToDataSetConvertibleSets;
|
||||||
static Set<ConvertiblePair> getDataSetToListConvertibleTypes() {
|
}
|
||||||
return dataSetToListConvertibleSets;
|
|
||||||
}
|
static Set<ConvertiblePair> getDataSetToListConvertibleTypes() {
|
||||||
|
return dataSetToListConvertibleSets;
|
||||||
public static Object getDefaultValue(DataType dataType) {
|
}
|
||||||
|
|
||||||
int type = dataType.getType();
|
public static Object getDefaultValue(DataType dataType) {
|
||||||
|
|
||||||
if(type == DataTypes.STRING) {
|
int type = dataType.getType();
|
||||||
return DataTypes.DEFAULT_VALUE_STRING;
|
|
||||||
} else if(type == DataTypes.INT) {
|
if(type == DataTypes.STRING) {
|
||||||
return DataTypes.DEFAULT_VALUE_INT;
|
return DataTypes.DEFAULT_VALUE_STRING;
|
||||||
} else if(type == DataTypes.LONG) {
|
} else if(type == DataTypes.INT) {
|
||||||
return DataTypes.DEFAULT_VALUE_LONG;
|
return DataTypes.DEFAULT_VALUE_INT;
|
||||||
} else if(type == DataTypes.FLOAT) {
|
} else if(type == DataTypes.LONG) {
|
||||||
return DataTypes.DEFAULT_VALUE_FLOAT;
|
return DataTypes.DEFAULT_VALUE_LONG;
|
||||||
} else if(type == DataTypes.DOUBLE) {
|
} else if(type == DataTypes.FLOAT) {
|
||||||
return DataTypes.DEFAULT_VALUE_DOUBLE;
|
return DataTypes.DEFAULT_VALUE_FLOAT;
|
||||||
} else if(type == DataTypes.BOOLEAN) {
|
} else if(type == DataTypes.DOUBLE) {
|
||||||
return DataTypes.DEFAULT_VALUE_BOOLEAN;
|
return DataTypes.DEFAULT_VALUE_DOUBLE;
|
||||||
} else if(type == DataTypes.DATE) {
|
} else if(type == DataTypes.BOOLEAN) {
|
||||||
return DataTypes.DEFAULT_VALUE_DATE;
|
return DataTypes.DEFAULT_VALUE_BOOLEAN;
|
||||||
} else if(type == DataTypes.DATE_TIME) {
|
} else if(type == DataTypes.DATE) {
|
||||||
return DataTypes.DEFAULT_VALUE_DATE_TIME;
|
return DataTypes.DEFAULT_VALUE_DATE;
|
||||||
} else if(type == DataTypes.TIME) {
|
} else if(type == DataTypes.DATE_TIME) {
|
||||||
return DataTypes.DEFAULT_VALUE_TIME;
|
return DataTypes.DEFAULT_VALUE_DATE_TIME;
|
||||||
} else if(type == DataTypes.BIG_DECIMAL) {
|
} else if(type == DataTypes.TIME) {
|
||||||
return DataTypes.DEFAULT_VALUE_BIG_DECIMAL;
|
return DataTypes.DEFAULT_VALUE_TIME;
|
||||||
} else if(type == DataTypes.BLOB) {
|
} else if(type == DataTypes.BIG_DECIMAL) {
|
||||||
return DataTypes.DEFAULT_VALUE_BLOB;
|
return DataTypes.DEFAULT_VALUE_BIG_DECIMAL;
|
||||||
}
|
} else if(type == DataTypes.BLOB) {
|
||||||
return DataTypes.DEFAULT_VALUE_OBJECT;
|
return DataTypes.DEFAULT_VALUE_BLOB;
|
||||||
}
|
}
|
||||||
|
return DataTypes.DEFAULT_VALUE_OBJECT;
|
||||||
public static Object getDefaultMetaDataValue(DataType dataType) {
|
}
|
||||||
|
|
||||||
int type = dataType.getType();
|
public static Object getDefaultMetaDataValue(DataType dataType) {
|
||||||
|
|
||||||
if(type == DataTypes.STRING) {
|
int type = dataType.getType();
|
||||||
return "";
|
|
||||||
} else if(type == DataTypes.INT) {
|
if(type == DataTypes.STRING) {
|
||||||
return DataTypes.DEFAULT_VALUE_INT;
|
return "";
|
||||||
} else if(type == DataTypes.LONG) {
|
} else if(type == DataTypes.INT) {
|
||||||
return DataTypes.DEFAULT_VALUE_LONG;
|
return DataTypes.DEFAULT_VALUE_INT;
|
||||||
} else if(type == DataTypes.FLOAT) {
|
} else if(type == DataTypes.LONG) {
|
||||||
return DataTypes.DEFAULT_VALUE_FLOAT;
|
return DataTypes.DEFAULT_VALUE_LONG;
|
||||||
} else if(type == DataTypes.DOUBLE) {
|
} else if(type == DataTypes.FLOAT) {
|
||||||
return DataTypes.DEFAULT_VALUE_DOUBLE;
|
return DataTypes.DEFAULT_VALUE_FLOAT;
|
||||||
} else if(type == DataTypes.BOOLEAN) {
|
} else if(type == DataTypes.DOUBLE) {
|
||||||
return DataTypes.DEFAULT_VALUE_BOOLEAN;
|
return DataTypes.DEFAULT_VALUE_DOUBLE;
|
||||||
} else if(type == DataTypes.DATE) {
|
} else if(type == DataTypes.BOOLEAN) {
|
||||||
return new Date();
|
return DataTypes.DEFAULT_VALUE_BOOLEAN;
|
||||||
} else if(type == DataTypes.DATE_TIME) {
|
} else if(type == DataTypes.DATE) {
|
||||||
return new Date();
|
return new Date();
|
||||||
} else if(type == DataTypes.TIME) {
|
} else if(type == DataTypes.DATE_TIME) {
|
||||||
return new Date();
|
return new Date();
|
||||||
} else if(type == DataTypes.BIG_DECIMAL) {
|
} else if(type == DataTypes.TIME) {
|
||||||
return new BigDecimal(0);
|
return new Date();
|
||||||
} else if(type == DataTypes.BLOB) {
|
} else if(type == DataTypes.BIG_DECIMAL) {
|
||||||
return new byte[0];
|
return new BigDecimal(0);
|
||||||
}
|
} else if(type == DataTypes.BLOB) {
|
||||||
|
return new byte[0];
|
||||||
return DataTypes.DEFAULT_VALUE_OBJECT;
|
}
|
||||||
}
|
|
||||||
|
return DataTypes.DEFAULT_VALUE_OBJECT;
|
||||||
public static DataType getDataType(Class targetClass) {
|
}
|
||||||
|
|
||||||
// DataTypeFactory의 byte[] 문제.
|
public static DataType getDataType(Class targetClass) {
|
||||||
if(String.class.equals(targetClass)) {
|
|
||||||
return PlatformDataType.STRING;
|
// DataTypeFactory의 byte[] 문제.
|
||||||
} else if(int.class.equals(targetClass) || Integer.class.equals(targetClass)) {
|
if(String.class.equals(targetClass)) {
|
||||||
return PlatformDataType.INT;
|
return PlatformDataType.STRING;
|
||||||
} else if(long.class.equals(targetClass) || Long.class.equals(targetClass)) {
|
} else if(int.class.equals(targetClass) || Integer.class.equals(targetClass)) {
|
||||||
return PlatformDataType.LONG;
|
return PlatformDataType.INT;
|
||||||
} else if(float.class.equals(targetClass) || Float.class.equals(targetClass)) {
|
} else if(long.class.equals(targetClass) || Long.class.equals(targetClass)) {
|
||||||
return PlatformDataType.FLOAT;
|
return PlatformDataType.LONG;
|
||||||
} else if(double.class.equals(targetClass) || Double.class.equals(targetClass)) {
|
} else if(float.class.equals(targetClass) || Float.class.equals(targetClass)) {
|
||||||
return PlatformDataType.DOUBLE;
|
return PlatformDataType.FLOAT;
|
||||||
} else if(boolean.class.equals(targetClass) || Boolean.class.equals(targetClass)) {
|
} else if(double.class.equals(targetClass) || Double.class.equals(targetClass)) {
|
||||||
return PlatformDataType.BOOLEAN;
|
return PlatformDataType.DOUBLE;
|
||||||
} else if(Date.class.equals(targetClass)) {
|
} else if(boolean.class.equals(targetClass) || Boolean.class.equals(targetClass)) {
|
||||||
return PlatformDataType.DATE_TIME;
|
return PlatformDataType.BOOLEAN;
|
||||||
} else if(BigDecimal.class.equals(targetClass)) {
|
} else if(Date.class.equals(targetClass)) {
|
||||||
return PlatformDataType.BIG_DECIMAL;
|
return PlatformDataType.DATE_TIME;
|
||||||
} else if(Object.class.equals(targetClass)) {
|
} else if(BigDecimal.class.equals(targetClass)) {
|
||||||
return PlatformDataType.UNDEFINED;
|
return PlatformDataType.BIG_DECIMAL;
|
||||||
} else if(targetClass.isArray() && (byte[].class.equals(targetClass) || Byte[].class.equals(targetClass))) {
|
} else if(Object.class.equals(targetClass)) {
|
||||||
return PlatformDataType.BLOB;
|
return PlatformDataType.UNDEFINED;
|
||||||
}
|
} else if(targetClass.isArray() && (byte[].class.equals(targetClass) || Byte[].class.equals(targetClass))) {
|
||||||
|
return PlatformDataType.BLOB;
|
||||||
return PlatformDataType.UNDEFINED;
|
}
|
||||||
}
|
|
||||||
|
return PlatformDataType.UNDEFINED;
|
||||||
static DataType getDataTypeOfValue(Object value) {
|
}
|
||||||
if(value == null) {
|
|
||||||
return PlatformDataType.UNDEFINED;
|
static DataType getDataTypeOfValue(Object value) {
|
||||||
}
|
if(value == null) {
|
||||||
DataType dataTypeOfValue = DataTypeFactory.getDataTypeOfValue(value);
|
return PlatformDataType.UNDEFINED;
|
||||||
if(dataTypeOfValue.getType() == PlatformDataType.UNDEFINED.getType()) {
|
}
|
||||||
if(value instanceof Byte[]) {
|
DataType dataTypeOfValue = DataTypeFactory.getDataTypeOfValue(value);
|
||||||
dataTypeOfValue = PlatformDataType.BLOB;
|
if(dataTypeOfValue.getType() == PlatformDataType.UNDEFINED.getType()) {
|
||||||
}
|
if(value instanceof Byte[]) {
|
||||||
} else if(dataTypeOfValue.getType() == PlatformDataType.DATE.getType()) {
|
dataTypeOfValue = PlatformDataType.BLOB;
|
||||||
// data는 DATE_TIME으로 변경.
|
}
|
||||||
dataTypeOfValue = PlatformDataType.DATE_TIME;
|
} else if(dataTypeOfValue.getType() == PlatformDataType.DATE.getType()) {
|
||||||
}
|
// data는 DATE_TIME으로 변경.
|
||||||
return dataTypeOfValue;
|
dataTypeOfValue = PlatformDataType.DATE_TIME;
|
||||||
}
|
}
|
||||||
|
return dataTypeOfValue;
|
||||||
|
}
|
||||||
static Variable toVariable(String name, Object value) {
|
|
||||||
Variable var = new Variable(name);
|
|
||||||
if(value == null) {
|
static Variable toVariable(String name, Object value) {
|
||||||
return var;
|
Variable var = new Variable(name);
|
||||||
}
|
if(value == null) {
|
||||||
// 최초 type 설정이 안되어 있을 경우 설정된 값에 따라 Type이 설정 된다.
|
return var;
|
||||||
if(value instanceof Byte[]) {
|
}
|
||||||
var.set(toPrimitive((Byte[]) value));
|
// 최초 type 설정이 안되어 있을 경우 설정된 값에 따라 Type이 설정 된다.
|
||||||
} else {
|
if(value instanceof Byte[]) {
|
||||||
var.set(value);
|
var.set(toPrimitive((Byte[]) value));
|
||||||
}
|
} else {
|
||||||
return var;
|
var.set(value);
|
||||||
}
|
}
|
||||||
|
return var;
|
||||||
static Object toObject(Variable variable, Class<?> targetClass) {
|
}
|
||||||
|
|
||||||
// 직접 변환할까..
|
static Object toObject(Variable variable, Class<?> targetClass) {
|
||||||
if(String.class.equals(targetClass)) {
|
|
||||||
return variable.getString();
|
// 직접 변환할까..
|
||||||
} else if(int.class.equals(targetClass) || Integer.class.equals(targetClass)) {
|
if(String.class.equals(targetClass)) {
|
||||||
return variable.getInt();
|
return variable.getString();
|
||||||
} else if(long.class.equals(targetClass) || Long.class.equals(targetClass)) {
|
} else if(int.class.equals(targetClass) || Integer.class.equals(targetClass)) {
|
||||||
return variable.getLong();
|
return variable.getInt();
|
||||||
} else if(float.class.equals(targetClass) || Float.class.equals(targetClass)) {
|
} else if(long.class.equals(targetClass) || Long.class.equals(targetClass)) {
|
||||||
return variable.getFloat();
|
return variable.getLong();
|
||||||
} else if(double.class.equals(targetClass) || Double.class.equals(targetClass)) {
|
} else if(float.class.equals(targetClass) || Float.class.equals(targetClass)) {
|
||||||
return variable.getDouble();
|
return variable.getFloat();
|
||||||
} else if(boolean.class.equals(targetClass) || Boolean.class.equals(targetClass)) {
|
} else if(double.class.equals(targetClass) || Double.class.equals(targetClass)) {
|
||||||
return variable.getBoolean();
|
return variable.getDouble();
|
||||||
} else if(Date.class.equals(targetClass)) {
|
} else if(boolean.class.equals(targetClass) || Boolean.class.equals(targetClass)) {
|
||||||
return variable.getDateTime();
|
return variable.getBoolean();
|
||||||
} else if(BigDecimal.class.equals(targetClass)) {
|
} else if(Date.class.equals(targetClass)) {
|
||||||
return variable.getBigDecimal();
|
return variable.getDateTime();
|
||||||
} else if(Object.class.equals(targetClass)) {
|
} else if(BigDecimal.class.equals(targetClass)) {
|
||||||
return variable.getObject();
|
return variable.getBigDecimal();
|
||||||
} else if(targetClass.isArray()) {
|
} else if(Object.class.equals(targetClass)) {
|
||||||
if(byte[].class.equals(targetClass)) {
|
return variable.getObject();
|
||||||
return variable.getBlob();
|
} else if(targetClass.isArray()) {
|
||||||
} else if(Byte[].class.equals(targetClass)) {
|
if(byte[].class.equals(targetClass)) {
|
||||||
byte[] blob = variable.getBlob();
|
return variable.getBlob();
|
||||||
return toObject(blob);
|
} else if(Byte[].class.equals(targetClass)) {
|
||||||
}
|
byte[] blob = variable.getBlob();
|
||||||
}
|
return toObject(blob);
|
||||||
|
}
|
||||||
return variable.getObject();
|
}
|
||||||
}
|
|
||||||
|
return variable.getObject();
|
||||||
static Object toObject(Object obj) {
|
}
|
||||||
if(obj == null) {
|
|
||||||
return null;
|
static Object toObject(Object obj) {
|
||||||
}
|
if(obj == null) {
|
||||||
if(obj instanceof Byte[]) {
|
return null;
|
||||||
return toPrimitive((Byte[])obj);
|
}
|
||||||
}
|
if(obj instanceof Byte[]) {
|
||||||
return obj;
|
return toPrimitive((Byte[])obj);
|
||||||
}
|
}
|
||||||
|
return obj;
|
||||||
static Object toObjectFromDataSetValue(DataSet ds, int rowIndex, int colIndex, Class<?> targetClass, boolean isSavedData, boolean isRemovedData) {
|
}
|
||||||
|
|
||||||
if(Object.class.equals(targetClass)) {
|
static Object toObjectFromDataSetValue(DataSet ds, int rowIndex, int colIndex, Class<?> targetClass, boolean isSavedData, boolean isRemovedData) {
|
||||||
if(isSavedData) {
|
|
||||||
return ds.getSavedData(rowIndex, colIndex);
|
if(Object.class.equals(targetClass)) {
|
||||||
} else if(isRemovedData) {
|
if(isSavedData) {
|
||||||
return ds.getRemovedData(rowIndex, colIndex);
|
return ds.getSavedData(rowIndex, colIndex);
|
||||||
} else {
|
} else if(isRemovedData) {
|
||||||
return ds.getObject(rowIndex, colIndex);
|
return ds.getRemovedData(rowIndex, colIndex);
|
||||||
}
|
} else {
|
||||||
} else if(String.class.equals(targetClass)) {
|
return ds.getObject(rowIndex, colIndex);
|
||||||
if(isSavedData) {
|
}
|
||||||
return ds.getSavedStringData(rowIndex, colIndex);
|
} else if(String.class.equals(targetClass)) {
|
||||||
} else if(isRemovedData) {
|
if(isSavedData) {
|
||||||
return ds.getRemovedStringData(rowIndex, colIndex);
|
return ds.getSavedStringData(rowIndex, colIndex);
|
||||||
} else {
|
} else if(isRemovedData) {
|
||||||
return ds.getString(rowIndex, colIndex);
|
return ds.getRemovedStringData(rowIndex, colIndex);
|
||||||
}
|
} else {
|
||||||
} else if(int.class.equals(targetClass) || Integer.class.equals(targetClass)) {
|
return ds.getString(rowIndex, colIndex);
|
||||||
if(isSavedData) {
|
}
|
||||||
return ds.getSavedIntData(rowIndex, colIndex);
|
} else if(int.class.equals(targetClass) || Integer.class.equals(targetClass)) {
|
||||||
} else if(isRemovedData) {
|
if(isSavedData) {
|
||||||
return ds.getRemovedIntData(rowIndex, colIndex);
|
return ds.getSavedIntData(rowIndex, colIndex);
|
||||||
} else {
|
} else if(isRemovedData) {
|
||||||
return ds.getInt(rowIndex, colIndex);
|
return ds.getRemovedIntData(rowIndex, colIndex);
|
||||||
}
|
} else {
|
||||||
} else if(long.class.equals(targetClass) || Long.class.equals(targetClass)) {
|
return ds.getInt(rowIndex, colIndex);
|
||||||
if(isSavedData) {
|
}
|
||||||
return ds.getSavedLongData(rowIndex, colIndex);
|
} else if(long.class.equals(targetClass) || Long.class.equals(targetClass)) {
|
||||||
} else if(isRemovedData) {
|
if(isSavedData) {
|
||||||
return ds.getRemovedLongData(rowIndex, colIndex);
|
return ds.getSavedLongData(rowIndex, colIndex);
|
||||||
} else {
|
} else if(isRemovedData) {
|
||||||
return ds.getLong(rowIndex, colIndex);
|
return ds.getRemovedLongData(rowIndex, colIndex);
|
||||||
}
|
} else {
|
||||||
} else if(float.class.equals(targetClass) || Float.class.equals(targetClass)) {
|
return ds.getLong(rowIndex, colIndex);
|
||||||
if(isSavedData) {
|
}
|
||||||
return ds.getSavedFloatData(rowIndex, colIndex);
|
} else if(float.class.equals(targetClass) || Float.class.equals(targetClass)) {
|
||||||
} else if(isRemovedData) {
|
if(isSavedData) {
|
||||||
return ds.getRemovedFloatData(rowIndex, colIndex);
|
return ds.getSavedFloatData(rowIndex, colIndex);
|
||||||
} else {
|
} else if(isRemovedData) {
|
||||||
return ds.getFloat(rowIndex, colIndex);
|
return ds.getRemovedFloatData(rowIndex, colIndex);
|
||||||
}
|
} else {
|
||||||
} else if(double.class.equals(targetClass) || Double.class.equals(targetClass)) {
|
return ds.getFloat(rowIndex, colIndex);
|
||||||
if(isSavedData) {
|
}
|
||||||
return ds.getSavedDoubleData(rowIndex, colIndex);
|
} else if(double.class.equals(targetClass) || Double.class.equals(targetClass)) {
|
||||||
} else if(isRemovedData) {
|
if(isSavedData) {
|
||||||
return ds.getRemovedDoubleData(rowIndex, colIndex);
|
return ds.getSavedDoubleData(rowIndex, colIndex);
|
||||||
} else {
|
} else if(isRemovedData) {
|
||||||
return ds.getDouble(rowIndex, colIndex);
|
return ds.getRemovedDoubleData(rowIndex, colIndex);
|
||||||
}
|
} else {
|
||||||
} else if(boolean.class.equals(targetClass) || Boolean.class.equals(targetClass)) {
|
return ds.getDouble(rowIndex, colIndex);
|
||||||
if(isSavedData) {
|
}
|
||||||
return ds.getSavedBooleanData(rowIndex, colIndex);
|
} else if(boolean.class.equals(targetClass) || Boolean.class.equals(targetClass)) {
|
||||||
} else if(isRemovedData) {
|
if(isSavedData) {
|
||||||
return ds.getRemovedBooleanData(rowIndex, colIndex);
|
return ds.getSavedBooleanData(rowIndex, colIndex);
|
||||||
} else {
|
} else if(isRemovedData) {
|
||||||
return ds.getBoolean(rowIndex, colIndex);
|
return ds.getRemovedBooleanData(rowIndex, colIndex);
|
||||||
}
|
} else {
|
||||||
} else if(Date.class.equals(targetClass)) {
|
return ds.getBoolean(rowIndex, colIndex);
|
||||||
if(isSavedData) {
|
}
|
||||||
return ds.getSavedDateTimeData(rowIndex, colIndex);
|
} else if(Date.class.equals(targetClass)) {
|
||||||
} else if(isRemovedData) {
|
if(isSavedData) {
|
||||||
return ds.getRemovedDateTimeData(rowIndex, colIndex);
|
return ds.getSavedDateTimeData(rowIndex, colIndex);
|
||||||
} else {
|
} else if(isRemovedData) {
|
||||||
return ds.getDateTime(rowIndex, colIndex);
|
return ds.getRemovedDateTimeData(rowIndex, colIndex);
|
||||||
}
|
} else {
|
||||||
} else if(BigDecimal.class.equals(targetClass)) {
|
return ds.getDateTime(rowIndex, colIndex);
|
||||||
if(isSavedData) {
|
}
|
||||||
return ds.getSavedBigDecimalData(rowIndex, colIndex);
|
} else if(BigDecimal.class.equals(targetClass)) {
|
||||||
} else if(isRemovedData) {
|
if(isSavedData) {
|
||||||
return ds.getRemovedBigDecimalData(rowIndex, colIndex);
|
return ds.getSavedBigDecimalData(rowIndex, colIndex);
|
||||||
} else {
|
} else if(isRemovedData) {
|
||||||
return ds.getBigDecimal(rowIndex, colIndex);
|
return ds.getRemovedBigDecimalData(rowIndex, colIndex);
|
||||||
}
|
} else {
|
||||||
} else if(targetClass.isArray()) {
|
return ds.getBigDecimal(rowIndex, colIndex);
|
||||||
if(byte[].class.equals(targetClass)) {
|
}
|
||||||
if(isSavedData) {
|
} else if(targetClass.isArray()) {
|
||||||
return ds.getSavedBlobData(rowIndex, colIndex);
|
if(byte[].class.equals(targetClass)) {
|
||||||
} else if(isRemovedData) {
|
if(isSavedData) {
|
||||||
return ds.getRemovedBlobData(rowIndex, colIndex);
|
return ds.getSavedBlobData(rowIndex, colIndex);
|
||||||
} else {
|
} else if(isRemovedData) {
|
||||||
return ds.getBlob(rowIndex, colIndex);
|
return ds.getRemovedBlobData(rowIndex, colIndex);
|
||||||
}
|
} else {
|
||||||
} else if(Byte[].class.equals(targetClass)) {
|
return ds.getBlob(rowIndex, colIndex);
|
||||||
byte[] blob;
|
}
|
||||||
if(isSavedData) {
|
} else if(Byte[].class.equals(targetClass)) {
|
||||||
blob = ds.getSavedBlobData(rowIndex, colIndex);
|
byte[] blob;
|
||||||
return toObject(blob);
|
if(isSavedData) {
|
||||||
} else if(isRemovedData) {
|
blob = ds.getSavedBlobData(rowIndex, colIndex);
|
||||||
blob = ds.getRemovedBlobData(rowIndex, colIndex);
|
return toObject(blob);
|
||||||
return toObject(blob);
|
} else if(isRemovedData) {
|
||||||
} else {
|
blob = ds.getRemovedBlobData(rowIndex, colIndex);
|
||||||
blob = ds.getBlob(rowIndex, colIndex);
|
return toObject(blob);
|
||||||
return toObject(blob);
|
} else {
|
||||||
}
|
blob = ds.getBlob(rowIndex, colIndex);
|
||||||
}
|
return toObject(blob);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// return object
|
}
|
||||||
if(isSavedData) {
|
|
||||||
return ds.getSavedData(rowIndex, colIndex);
|
// return object
|
||||||
} else if(isRemovedData) {
|
if(isSavedData) {
|
||||||
return ds.getRemovedData(rowIndex, colIndex);
|
return ds.getSavedData(rowIndex, colIndex);
|
||||||
} else {
|
} else if(isRemovedData) {
|
||||||
return ds.getObject(rowIndex, colIndex);
|
return ds.getRemovedData(rowIndex, colIndex);
|
||||||
}
|
} else {
|
||||||
}
|
return ds.getObject(rowIndex, colIndex);
|
||||||
|
}
|
||||||
static boolean isSupportedBean(Class clazz) {
|
}
|
||||||
if(!clazz.isInterface() && !clazz.isPrimitive() && !clazz.isEnum() && !clazz.isArray()) {
|
|
||||||
return true;
|
static boolean isSupportedBean(Class clazz) {
|
||||||
}
|
if(!clazz.isInterface() && !clazz.isPrimitive() && !clazz.isEnum() && !clazz.isArray()) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
static Map<String, Field> getAdjustConvertibleFields(Class clazz, DataSet ds) {
|
}
|
||||||
|
|
||||||
Map<String, Field> accessibleFields = getAccessibleFields(clazz);
|
static Map<String, Field> getAdjustConvertibleFields(Class clazz, DataSet ds) {
|
||||||
|
|
||||||
Map<String, Field> adjustConvertibleFields = new HashMap<String, Field>();
|
Map<String, Field> accessibleFields = getAccessibleFields(clazz);
|
||||||
// 획득한 field와 dataset field를 검사하여 실제로 사용될 field 들을 추려둔다.
|
|
||||||
int columnCount = ds.getColumnCount();
|
Map<String, Field> adjustConvertibleFields = new HashMap<String, Field>();
|
||||||
for(int i=0; i<columnCount; i++) {
|
// 획득한 field와 dataset field를 검사하여 실제로 사용될 field 들을 추려둔다.
|
||||||
ColumnHeader column = ds.getColumn(i);
|
int columnCount = ds.getColumnCount();
|
||||||
String columnName = column.getName();
|
for(int i=0; i<columnCount; i++) {
|
||||||
|
ColumnHeader column = ds.getColumn(i);
|
||||||
// 대소문자를 구별한다!
|
String columnName = column.getName();
|
||||||
Field field = accessibleFields.get(columnName);
|
|
||||||
if(field != null) {
|
// 대소문자를 구별한다!
|
||||||
adjustConvertibleFields.put(columnName, field);
|
Field field = accessibleFields.get(columnName);
|
||||||
}
|
if(field != null) {
|
||||||
}
|
adjustConvertibleFields.put(columnName, field);
|
||||||
|
}
|
||||||
return adjustConvertibleFields;
|
}
|
||||||
|
|
||||||
}
|
return adjustConvertibleFields;
|
||||||
|
|
||||||
static Map<String, Field> getAccessibleFields(Class clazz) {
|
}
|
||||||
|
|
||||||
Map<String, Field> accessibleFields = new HashMap<String, Field>();
|
static Map<String, Field> getAccessibleFields(Class clazz) {
|
||||||
|
|
||||||
Class<?> searchType = clazz;
|
Map<String, Field> accessibleFields = new HashMap<String, Field>();
|
||||||
while (!Object.class.equals(searchType) && searchType != null) {
|
|
||||||
Field[] fields = searchType.getDeclaredFields();
|
Class<?> searchType = clazz;
|
||||||
for (Field field : fields) {
|
while (!Object.class.equals(searchType) && searchType != null) {
|
||||||
Class<?> type = field.getType();
|
Field[] fields = searchType.getDeclaredFields();
|
||||||
if(isConvertibleType(type)) {
|
for (Field field : fields) {
|
||||||
ReflectionUtil.makeAccessible(field);
|
Class<?> type = field.getType();
|
||||||
accessibleFields.put(field.getName(), field);
|
if(isConvertibleType(type)) {
|
||||||
}
|
ReflectionUtil.makeAccessible(field);
|
||||||
}
|
accessibleFields.put(field.getName(), field);
|
||||||
searchType = searchType.getSuperclass();
|
}
|
||||||
}
|
}
|
||||||
|
searchType = searchType.getSuperclass();
|
||||||
return accessibleFields;
|
}
|
||||||
}
|
|
||||||
|
return accessibleFields;
|
||||||
static boolean isConvertibleType(Class<?> type) {
|
}
|
||||||
if(primitiveTypeWrapperMap.get(type) != null) {
|
|
||||||
return true;
|
static boolean isConvertibleType(Class<?> type) {
|
||||||
} else if(nonPrimitiveTypeMap.get(type) != null) {
|
if(primitiveTypeWrapperMap.get(type) != null) {
|
||||||
return true;
|
return true;
|
||||||
} else if(primitiveTypeWrapperMap.containsValue(type)) {
|
} else if(nonPrimitiveTypeMap.get(type) != null) {
|
||||||
return true;
|
return true;
|
||||||
} else if(nonPrimitiveTypeMap.containsValue(type)) {
|
} else if(primitiveTypeWrapperMap.containsValue(type)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
} else if(nonPrimitiveTypeMap.containsValue(type)) {
|
||||||
|
return true;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
return false;
|
||||||
/* commons.lang.ArrayUtils source*/
|
}
|
||||||
private static Byte[] toObject(byte[] array) {
|
|
||||||
if (array == null) {
|
/* commons.lang.ArrayUtils source*/
|
||||||
return null;
|
private static Byte[] toObject(byte[] array) {
|
||||||
} else if (array.length == 0) {
|
if (array == null) {
|
||||||
return new Byte[0];
|
return null;
|
||||||
}
|
} else if (array.length == 0) {
|
||||||
final Byte[] result = new Byte[array.length];
|
return new Byte[0];
|
||||||
for (int i = 0; i < array.length; i++) {
|
}
|
||||||
result[i] = new Byte(array[i]);
|
final Byte[] result = new Byte[array.length];
|
||||||
}
|
for (int i = 0; i < array.length; i++) {
|
||||||
return result;
|
result[i] = new Byte(array[i]);
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
private static byte[] toPrimitive(Byte[] array) {
|
}
|
||||||
if (array == null) {
|
|
||||||
return null;
|
private static byte[] toPrimitive(Byte[] array) {
|
||||||
} else if (array.length == 0) {
|
if (array == null) {
|
||||||
return new byte[0];
|
return null;
|
||||||
}
|
} else if (array.length == 0) {
|
||||||
final byte[] result = new byte[array.length];
|
return new byte[0];
|
||||||
for (int i = 0; i < array.length; i++) {
|
}
|
||||||
result[i] = array[i].byteValue();
|
final byte[] result = new byte[array.length];
|
||||||
}
|
for (int i = 0; i < array.length; i++) {
|
||||||
return result;
|
result[i] = array[i].byteValue();
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user