SimpleDeserializerFactorypublic class SimpleDeserializerFactory extends BaseDeserializerFactory A deserializer for any simple type with a (String) constructor. Note:
this class is designed so that subclasses need only override the makeValue
method in order to construct objects of their own type. |
Fields Summary |
---|
private static final Class[] | STRING_STRING_CLASS | private static final Class[] | STRING_CLASS | private transient Constructor | constructor | private boolean | isBasicType |
Constructors Summary |
---|
public SimpleDeserializerFactory(Class javaType, QName xmlType)Note that the factory is constructed with the QName and xmlType. This is important
to allow distinction between primitive values and java.lang wrappers.
super(SimpleDeserializer.class, xmlType, javaType);
this.isBasicType = JavaUtils.isBasic(javaType);
initConstructor(javaType);
|
Methods Summary |
---|
public javax.xml.rpc.encoding.Deserializer | getDeserializerAs(java.lang.String mechanismType)Get the Deserializer and the set the Constructor so the
deserializer does not have to do introspection.
if (javaType == java.lang.Object.class) {
return null;
}
if (this.isBasicType) {
return new SimpleDeserializer(javaType, xmlType);
} else {
// XXX: don't think we can always expect to be SimpleDeserializer
// since getSpecialized() might return a different type
SimpleDeserializer deser =
(SimpleDeserializer) super.getDeserializerAs(mechanismType);
if (deser != null) {
deser.setConstructor(constructor);
}
return deser;
}
| private void | initConstructor(java.lang.Class javaType)
if (!this.isBasicType) {
// discover the constructor for non basic types
try {
if (QName.class.isAssignableFrom(javaType)) {
constructor =
javaType.getDeclaredConstructor(STRING_STRING_CLASS);
} else {
constructor =
javaType.getDeclaredConstructor(STRING_CLASS);
}
} catch (NoSuchMethodException e) {
try {
constructor =
javaType.getDeclaredConstructor(new Class[]{});
BeanPropertyDescriptor[] pds = BeanUtils.getPd(javaType);
if(pds != null) {
if(BeanUtils.getSpecificPD(pds,"_value")!=null){
return;
}
}
throw new IllegalArgumentException(e.toString());
} catch (NoSuchMethodException ex) {
throw new IllegalArgumentException(ex.toString());
}
}
}
| private void | readObject(java.io.ObjectInputStream in)
in.defaultReadObject();
initConstructor(javaType);
|
|