This commit is contained in:
Redkale
2016-09-07 13:53:33 +08:00
parent 9d82ca84a4
commit d202b2fbad

View File

@@ -381,45 +381,9 @@ public final class EntityInfo<T> {
protected String formatToString(Object value) { protected String formatToString(Object value) {
if (value == null) return null; if (value == null) return null;
if (value instanceof CharSequence) return new StringBuilder().append('\'').append(value.toString().replace("'", "\\'")).append('\'').toString(); if (value instanceof CharSequence) {
// final Class t = value.getClass(); return new StringBuilder().append('\'').append(value.toString().replace("'", "\\'")).append('\'').toString();
// if (t == int[].class) { }
// int[] val = (int[]) value;
// if (val.length == 0) return "";
// StringBuilder sb = new StringBuilder();
// sb.append(val[0]);
// for (int i = 1; i < val.length; i++) {
// sb.append(';').append(val[i]);
// }
// return sb.toString();
// } else if (t == long[].class) {
// long[] val = (long[]) value;
// if (val.length == 0) return "";
// StringBuilder sb = new StringBuilder();
// sb.append(val[0]);
// for (int i = 1; i < val.length; i++) {
// sb.append(';').append(val[i]);
// }
// return sb.toString();
// } else if (t == String[].class) {
// String[] val = (String[]) value;
// if (val.length == 0) return "";
// StringBuilder sb = new StringBuilder();
// sb.append(val[0]);
// for (int i = 1; i < val.length; i++) {
// sb.append(';').append(val[i]);
// }
// return sb.toString();
// } else if (t == short[].class) {
// short[] val = (short[]) value;
// if (val.length == 0) return "";
// StringBuilder sb = new StringBuilder();
// sb.append(val[0]);
// for (int i = 1; i < val.length; i++) {
// sb.append(';').append(val[i]);
// }
// return sb.toString();
// }
return String.valueOf(value); return String.valueOf(value);
} }
@@ -428,96 +392,40 @@ public final class EntityInfo<T> {
for (Attribute<T, Serializable> attr : queryAttributes) { for (Attribute<T, Serializable> attr : queryAttributes) {
if (sels == null || sels.test(attr.field())) { if (sels == null || sels.test(attr.field())) {
Serializable o = (Serializable) set.getObject(this.getSQLColumn(null, attr.field())); Serializable o = (Serializable) set.getObject(this.getSQLColumn(null, attr.field()));
if (o != null) { final Class t = attr.type();
Class t = attr.type(); if (t.isPrimitive()) {
if (t == int.class) { if (o != null) {
o = ((Number) o).intValue(); if (t == int.class) {
} else if (t == short.class) { o = ((Number) o).intValue();
o = ((Number) o).shortValue(); } else if (t == long.class) {
o = ((Number) o).longValue();
} else if (t == short.class) {
o = ((Number) o).shortValue();
} else if (t == float.class) {
o = ((Number) o).floatValue();
} else if (t == double.class) {
o = ((Number) o).doubleValue();
} else if (t == byte.class) {
o = ((Number) o).byteValue();
} else if (t == char.class) {
o = (char) ((Number) o).intValue();
}
} else if (t == int.class) {
o = 0;
} else if (t == long.class) { } else if (t == long.class) {
o = ((Number) o).longValue(); o = 0L;
} else if (t == short.class) {
o = (short) 0;
} else if (t == float.class) { } else if (t == float.class) {
o = ((Number) o).floatValue(); o = 0.0f;
} else if (t == double.class) { } else if (t == double.class) {
o = ((Number) o).doubleValue(); o = 0.0d;
} else if (t == byte.class) { } else if (t == byte.class) {
o = ((Number) o).byteValue(); o = (byte) 0;
// } else if (t == short[].class) { } else if (t == boolean.class) {
// String s = o.toString(); o = false;
// if (s.isEmpty()) { } else if (t == char.class) {
// o = new short[0]; o = (char) 0;
// } else {
// String[] strs = o.toString().split(";");
// short[] v = new short[strs.length];
// int k = 0;
// for (int i = 0; i < strs.length; i++) {
// if (strs[i].isEmpty()) continue;
// v[k++] = Short.parseShort(strs[i]);
// }
// if (k == v.length) {
// o = v;
// } else {
// o = new short[k];
// System.arraycopy(v, 0, o, 0, k);
// }
// }
// } else if (t == int[].class) {
// String s = o.toString();
// if (s.isEmpty()) {
// o = new int[0];
// } else {
// String[] strs = o.toString().split(";");
// int[] v = new int[strs.length];
// int k = 0;
// for (int i = 0; i < strs.length; i++) {
// if (strs[i].isEmpty()) continue;
// v[k++] = Integer.parseInt(strs[i]);
// }
// if (k == v.length) {
// o = v;
// } else {
// o = new int[k];
// System.arraycopy(v, 0, o, 0, k);
// }
// }
// } else if (t == long[].class) {
// String s = o.toString();
// if (s.isEmpty()) {
// o = new long[0];
// } else {
// String[] strs = o.toString().split(";");
// long[] v = new long[strs.length];
// int k = 0;
// for (int i = 0; i < strs.length; i++) {
// if (strs[i].isEmpty()) continue;
// v[k++] = Long.parseLong(strs[i]);
// }
// if (k == v.length) {
// o = v;
// } else {
// o = new long[k];
// System.arraycopy(v, 0, o, 0, k);
// }
// }
// } else if (t == String[].class) {
// String s = o.toString();
// if (s.isEmpty()) {
// o = new String[0];
// } else {
// String[] strs = o.toString().split(";");
// String[] v = new String[strs.length];
// int k = 0;
// for (int i = 0; i < strs.length; i++) {
// if (strs[i].isEmpty()) continue;
// v[k++] = strs[i];
// }
// if (k == v.length) {
// o = v;
// } else {
// o = new String[k];
// System.arraycopy(v, 0, o, 0, k);
// }
// }
} }
} }
attr.set(obj, o); attr.set(obj, o);