This commit is contained in:
@@ -341,8 +341,24 @@ public abstract class Factory<R extends Reader, W extends Writer> {
|
|||||||
od = new ObjectDecoder(type);
|
od = new ObjectDecoder(type);
|
||||||
decoder = od;
|
decoder = od;
|
||||||
} else if (!clazz.getName().startsWith("java.")) {
|
} else if (!clazz.getName().startsWith("java.")) {
|
||||||
od = new ObjectDecoder(type);
|
SimpledCoder simpleCoder = null;
|
||||||
decoder = od;
|
for (final Method method : clazz.getDeclaredMethods()) {
|
||||||
|
if (!Modifier.isStatic(method.getModifiers())) continue;
|
||||||
|
if (method.getParameterTypes().length != 0) continue;
|
||||||
|
if (method.getReturnType() != SimpledCoder.class) continue;
|
||||||
|
try {
|
||||||
|
method.setAccessible(true);
|
||||||
|
simpleCoder = (SimpledCoder) method.invoke(null);
|
||||||
|
break;
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (simpleCoder == null) {
|
||||||
|
od = new ObjectDecoder(type);
|
||||||
|
decoder = od;
|
||||||
|
} else {
|
||||||
|
decoder = simpleCoder;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (decoder == null) throw new ConvertException("not support the type (" + type + ")");
|
if (decoder == null) throw new ConvertException("not support the type (" + type + ")");
|
||||||
register(type, decoder);
|
register(type, decoder);
|
||||||
@@ -403,8 +419,24 @@ public abstract class Factory<R extends Reader, W extends Writer> {
|
|||||||
} else if (clazz == Object.class) {
|
} else if (clazz == Object.class) {
|
||||||
return (Encodeable<W, E>) this.anyEncoder;
|
return (Encodeable<W, E>) this.anyEncoder;
|
||||||
} else if (!clazz.getName().startsWith("java.")) {
|
} else if (!clazz.getName().startsWith("java.")) {
|
||||||
oe = new ObjectEncoder(type);
|
SimpledCoder simpleCoder = null;
|
||||||
encoder = oe;
|
for (final Method method : clazz.getDeclaredMethods()) {
|
||||||
|
if (!Modifier.isStatic(method.getModifiers())) continue;
|
||||||
|
if (method.getParameterTypes().length != 0) continue;
|
||||||
|
if (method.getReturnType() != SimpledCoder.class) continue;
|
||||||
|
try {
|
||||||
|
method.setAccessible(true);
|
||||||
|
simpleCoder = (SimpledCoder) method.invoke(null);
|
||||||
|
break;
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (simpleCoder == null) {
|
||||||
|
oe = new ObjectEncoder(type);
|
||||||
|
encoder = oe;
|
||||||
|
} else {
|
||||||
|
encoder = simpleCoder;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (encoder == null) throw new ConvertException("not support the type (" + type + ")");
|
if (encoder == null) throw new ConvertException("not support the type (" + type + ")");
|
||||||
register(type, encoder);
|
register(type, encoder);
|
||||||
|
|||||||
Reference in New Issue
Block a user