FileDocCategorySizeDatePackage
SimpleDeserializerFactory.javaAPI DocApache Axis 1.44301Sat Apr 22 18:57:26 BST 2006org.apache.axis.encoding.ser

SimpleDeserializerFactory

public 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.
author
Glen Daniels (gdaniels@apache.org)
author
Sam Ruby (rubys@us.ibm.com) Modified for JAX-RPC @author Rich Scheuerle (scheu@us.ibm.com)

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.DeserializergetDeserializerAs(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 voidinitConstructor(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 voidreadObject(java.io.ObjectInputStream in)

        in.defaultReadObject();
        initConstructor(javaType);