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()));
final Class t = attr.type();
if (t.isPrimitive()) {
if (o != null) { if (o != null) {
Class t = attr.type();
if (t == int.class) { if (t == int.class) {
o = ((Number) o).intValue(); o = ((Number) o).intValue();
} else if (t == short.class) {
o = ((Number) o).shortValue();
} else if (t == long.class) { } else if (t == long.class) {
o = ((Number) o).longValue(); o = ((Number) o).longValue();
} else if (t == short.class) {
o = ((Number) o).shortValue();
} else if (t == float.class) { } else if (t == float.class) {
o = ((Number) o).floatValue(); o = ((Number) o).floatValue();
} else if (t == double.class) { } else if (t == double.class) {
o = ((Number) o).doubleValue(); o = ((Number) o).doubleValue();
} else if (t == byte.class) { } else if (t == byte.class) {
o = ((Number) o).byteValue(); o = ((Number) o).byteValue();
// } else if (t == short[].class) { } else if (t == char.class) {
// String s = o.toString(); o = (char) ((Number) o).intValue();
// if (s.isEmpty()) { }
// o = new short[0]; } else if (t == int.class) {
// } else { o = 0;
// String[] strs = o.toString().split(";"); } else if (t == long.class) {
// short[] v = new short[strs.length]; o = 0L;
// int k = 0; } else if (t == short.class) {
// for (int i = 0; i < strs.length; i++) { o = (short) 0;
// if (strs[i].isEmpty()) continue; } else if (t == float.class) {
// v[k++] = Short.parseShort(strs[i]); o = 0.0f;
// } } else if (t == double.class) {
// if (k == v.length) { o = 0.0d;
// o = v; } else if (t == byte.class) {
// } else { o = (byte) 0;
// o = new short[k]; } else if (t == boolean.class) {
// System.arraycopy(v, 0, o, 0, k); o = false;
// } } else if (t == char.class) {
// } o = (char) 0;
// } 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);