Examples of BeanPropertyDescriptor


Examples of org.apache.axis.utils.BeanPropertyDescriptor

        } else {
            BeanPropertyDescriptor[] pd = BeanUtils.getPd(javaType, null);
            propertyMap = new HashMap();
            // loop through properties and grab the names for later
            for (int i = 0; i < pd.length; i++) {
                BeanPropertyDescriptor descriptor = pd[i];
                propertyMap.put(descriptor.getName(), descriptor);
            }
        }

        return propertyMap;
    }
View Full Code Here

Examples of org.apache.axis.utils.BeanPropertyDescriptor

                                    String prefix,
                                    Attributes attributes,
                                    DeserializationContext context)
        throws SAXException
    {
        BeanPropertyDescriptor propDesc = null;

        String encodingStyle = context.getMessageContext().getEncodingStyle();
        boolean isEncoded = Constants.isSOAP_ENC(encodingStyle);

        QName elemQName = new QName(namespace, localName);
        // The collectionIndex needs to be reset for Beans with multiple arrays
        if ((prevQName == null) || (!prevQName.equals(elemQName))) {
            collectionIndex = -1;
       
        prevQName = elemQName;

        if (typeDesc != null) {      
            // Lookup the name appropriately (assuming an unqualified
            // name for SOAP encoding, using the namespace otherwise)
            String fieldName = typeDesc.getFieldNameForElement(elemQName,
                                                               isEncoded);
            propDesc = (BeanPropertyDescriptor)propertyMap.get(fieldName);
        }

        if (propDesc == null) {
            // look for a field by this name.
            propDesc = (BeanPropertyDescriptor) propertyMap.get(localName);
        }

        // try and see if this is an xsd:any namespace="##any" element before
        // reporting a problem
        if (propDesc == null) {
            // try to put unknown elements into a SOAPElement property, if
            // appropriate
            propDesc = getAnyPropertyDesc();
            if (propDesc != null) {
                try {
                    MessageElement [] curElements = (MessageElement[])propDesc.get(value);
                    int length = 0;
                    if (curElements != null) {
                        length = curElements.length;
                    }
                    MessageElement [] newElements = new MessageElement[length + 1];
                    if (curElements != null) {
                        System.arraycopy(curElements, 0,
                                         newElements, 0, length);
                    }
                    MessageElement thisEl = context.getCurElement();

                    newElements[length] = thisEl;
                    propDesc.set(value, newElements);

                    return new SOAPHandler();
                } catch (Exception e) {
                    throw new SAXException(e);
                }
            }
        }


        if (propDesc == null) {
            // No such field
            throw new SAXException(
                    JavaUtils.getMessage("badElem00", javaType.getName(),
                                         localName));
        }

        // Get the child's xsi:type if available
        QName childXMLType = context.getTypeFromXSITypeAttr(namespace,
                                                            localName,
                                                            attributes);
       
        // Get Deserializer for child, default to using DeserializerImpl
        Deserializer dSer = getDeserializer(childXMLType, propDesc.getType(),
                                            attributes.getValue("href"),
                                            context);
        // It is an error if the dSer is not found, the base
        // deserializer impl is returned so that it can generate the correct message.
        if (dSer == null) {
            dSer = new DeserializerImpl();
            return (SOAPHandler)dSer;
        }

        // Register value target
        if (propDesc.isWriteable()) {
            // If this is an indexed property, and the deserializer we found
            // was NOT the ArrayDeserializer, this is a non-SOAP array:
            // <bean>
            //   <field>value1</field>
            //   <field>value2</field>
            // ...
            // In this case, we want to use the collectionIndex and make sure
            // the deserialized value for the child element goes into the
            // right place in the collection.
            if (propDesc.isIndexed() && !(dSer instanceof ArrayDeserializer)) {
                    collectionIndex++;
                    dSer.registerValueTarget(new BeanPropertyTarget(value,
                                                    propDesc, collectionIndex));
            } else {
                // If we're here, the element maps to a single field value,
View Full Code Here

Examples of org.apache.axis.utils.BeanPropertyDescriptor

            String fieldName = typeDesc.getFieldNameForAttribute(attrQName);
            if (fieldName == null)
                continue;

            // look for the attribute property
            BeanPropertyDescriptor bpd =
                    (BeanPropertyDescriptor) propertyMap.get(fieldName);
            if (bpd != null) {
                if (!bpd.isWriteable() || bpd.isIndexed() ) continue ;
               
                // Get the Deserializer for the attribute
                Deserializer dSer = getDeserializer(null, bpd.getType(),
                                                    null, context);

                if (dSer == null)
                    throw new SAXException(
                            JavaUtils.getMessage("unregistered00",
                                                 bpd.getType().toString()));
               
                if (! (dSer instanceof SimpleDeserializer))
                    throw new SAXException(
                            JavaUtils.getMessage("AttrNotSimpleType00",
                                                 bpd.getName(),
                                                 bpd.getType().toString()));
               
                // Success!  Create an object from the string and set
                // it in the bean
                try {
                    dSer.onStartElement(namespace, localName, prefix,
                                        attributes, context);
                    Object val = ((SimpleDeserializer)dSer).
                        makeValue(attributes.getValue(i));
                    bpd.set(value, val);
                } catch (Exception e) {
                    throw new SAXException(e);
                }
               
            } // if
View Full Code Here

Examples of org.apache.axis.utils.BeanPropertyDescriptor

                    }
                }
                continue;
            }

            BeanPropertyDescriptor bpd = propertyDescriptor[i];
            Class type = bpd.getType();
            // Attribute must extend a simple type, enum or SimpleType
            if (!types.isAcceptableAsAttribute(type)) {
                throw new AxisFault(JavaUtils.getMessage("AttrNotSimpleType01",
                        type.getName()));
            }
View Full Code Here

Examples of org.apache.axis.utils.BeanPropertyDescriptor

                propertyMap = typeDesc.getPropertyDescriptorMap();
            } else {  
                BeanPropertyDescriptor[] pd = BeanUtils.getPd(javaType, null);
                propertyMap = new HashMap();
                for (int i = 0; i < pd.length; i++) {
                    BeanPropertyDescriptor descriptor = pd[i];
                    propertyMap.put(descriptor.getName(), descriptor);
                }
            }
        }
    }
View Full Code Here

Examples of org.apache.axis.utils.BeanPropertyDescriptor

            String fieldName = typeDesc.getFieldNameForAttribute(attrQName);
            if (fieldName == null)
                continue;

            // look for the attribute property
            BeanPropertyDescriptor bpd =
                    (BeanPropertyDescriptor) propertyMap.get(fieldName);
            if (bpd != null) {
                if (!bpd.isWriteable() || bpd.isIndexed() ) continue ;

                // determine the QName for this child element
                TypeMapping tm = context.getTypeMapping();
                Class type = bpd.getType();
                QName qn = tm.getTypeQName(type);
                if (qn == null)
                    throw new SAXException(
                            JavaUtils.getMessage("unregistered00", type.toString()));

                // get the deserializer
                Deserializer dSer = context.getDeserializerForType(qn);
                if (dSer == null)
                    throw new SAXException(
                            JavaUtils.getMessage("noDeser00", type.toString()));
                if (! (dSer instanceof SimpleDeserializer))
                    throw new SAXException(
                            JavaUtils.getMessage("AttrNotSimpleType00",
                                                 bpd.getName(),
                                                 type.toString()));

                // Success!  Create an object from the string and save
                // it in our attribute map for later.
                if (attributeMap == null) {
View Full Code Here

Examples of org.apache.axis.utils.BeanPropertyDescriptor

        for (Iterator iterator = entries.iterator(); iterator.hasNext();) {
            Map.Entry entry = (Map.Entry) iterator.next();
            String name = (String) entry.getKey();
            Object val = entry.getValue();
           
            BeanPropertyDescriptor bpd =
                    (BeanPropertyDescriptor) propertyMap.get(name);
            if (!bpd.isWriteable() || bpd.isIndexed()) continue;
            try {
                bpd.set(value, val );
            } catch (Exception e) {
                throw new SAXException(e);
            }
        }
    }
View Full Code Here

Examples of org.apache.axis.utils.BeanPropertyDescriptor

        this.typeDesc = typeDesc;
        // Get a list of the bean properties
        BeanPropertyDescriptor[] pd = BeanUtils.getPd(javaType);
        // loop through properties and grab the names for later
        for (int i = 0; i < pd.length; i++) {
            BeanPropertyDescriptor descriptor = pd[i];
            propertyMap.put(descriptor.getName(), descriptor);
        }

        // create a value
        try {
            value=javaType.newInstance();
View Full Code Here

Examples of org.apache.axis.utils.BeanPropertyDescriptor

                                    String prefix,
                                    Attributes attributes,
                                    DeserializationContext context)
        throws SAXException
    {
        BeanPropertyDescriptor propDesc = null;
       
        QName elemQName = new QName(namespace, localName);
        // The collectionIndex needs to be reset for Beans with multiple arrays
        if ((prevQName == null) || (!prevQName.equals(elemQName))) {
            prevQName = elemQName;
            collectionIndex = -1;
       
        prevQName = elemQName;

        if (typeDesc != null) {      
           
            // First lookup the field using the target namespace context
            // and local name.  If this fails and the incoming element
            // name is not prefixed, lookup the name assuming an unqualified
            // name.
            String fieldName = typeDesc.getFieldNameForElement(elemQName,
                                                               false);
            if (fieldName == null && (prefix == null || prefix.equals(""))) {
                fieldName =
                    typeDesc.getFieldNameForElement(
                      new QName("", elemQName.getLocalPart()), false);
            }

            propDesc = (BeanPropertyDescriptor)propertyMap.get(fieldName);
        }

        if (propDesc == null) {
            // look for a field by this name.
            propDesc = (BeanPropertyDescriptor) propertyMap.get(localName);
        }

        // Currently the meta data does not consider inheritance.
        // Glen is working on a fix.  In the meantime, the following
        // code attempts to get the meta data from the base class. 
        // (this fix does not work in all cases, but is necessary to
        // get comprehensive tests Animal - Cat inheritance to work).
        if (propDesc == null) {
            Class superClass = javaType;
            while (superClass != null && propDesc == null) {
                superClass = superClass.getSuperclass();
                if (superClass != null) {
                    TypeDesc td = TypeDesc.getTypeDescForClass(superClass);
                    if (td != null) {
                        String fieldName =
                            td.getFieldNameForElement(elemQName,
                                                      false);
                        if (fieldName == null &&
                            (prefix == null || prefix.equals(""))) {
                            fieldName =
                                td.getFieldNameForElement(
                                new QName("", elemQName.getLocalPart()), false);
                        }
                       
                        propDesc =
                            (BeanPropertyDescriptor)propertyMap.get(fieldName);
                    }
                }
            }
        }

        if (propDesc == null) {
            // No such field
            throw new SAXException(
                    JavaUtils.getMessage("badElem00", javaType.getName(),
                                         localName));
        }

        // Determine the QName for this child element.
        // Look at the type attribute specified.  If this fails,
        // use the javaType of the property to get the type qname.
        QName qn = context.getTypeFromAttributes(namespace, localName, attributes);
       
        // get the deserializer
        Deserializer dSer = context.getDeserializerForType(qn);
       
        // If no deserializer, use the base DeserializerImpl.
        // There may not be enough information yet to choose the
        // specific deserializer.
        if (dSer == null) {
            dSer = new DeserializerImpl();
            // determine a default type for this child element
            TypeMapping tm = context.getTypeMapping();
            Class type = propDesc.getType();
            dSer.setDefaultType(tm.getTypeQName(type));
        }
               
        if (propDesc.isWriteable()) {
            if (!propDesc.isIndexed()) {
                // Success!  Register the target and deserializer.
                collectionIndex = -1;
                dSer.registerValueTarget(
                    new BeanPropertyTarget(value, propDesc));
            } else {
View Full Code Here

Examples of org.apache.axis.utils.BeanPropertyDescriptor

                continue;

            String attrName = attributes.getLocalName(i);

            // look for the attribute property
            BeanPropertyDescriptor bpd =
                    (BeanPropertyDescriptor) propertyMap.get(fieldName);
            if (bpd != null) {
                if (!bpd.isWriteable() || bpd.isIndexed() ) continue ;
               
                // determine the QName for this child element
                TypeMapping tm = context.getTypeMapping();
                Class type = bpd.getType();
                QName qn = tm.getTypeQName(type);
                if (qn == null)
                    throw new SAXException(
                            JavaUtils.getMessage("unregistered00", type.toString()));
               
                // get the deserializer
                Deserializer dSer = context.getDeserializerForType(qn);
                if (dSer == null)
                    throw new SAXException(
                            JavaUtils.getMessage("noDeser00", type.toString()));
                if (! (dSer instanceof SimpleDeserializer))
                    throw new SAXException(
                            JavaUtils.getMessage("AttrNotSimpleType00",
                                                 bpd.getName(),
                                                 type.toString()));
               
                // Success!  Create an object from the string and set
                // it in the bean
                try {
                    Object val = ((SimpleDeserializer)dSer).
                        makeValue(attributes.getValue(i));
                    bpd.set(value, val);
                } catch (Exception e) {
                    throw new SAXException(e);
                }
               
            } // if
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.