Class BeanDeserializer

All Implemented Interfaces:
Serializable, Deserializer, Callback, Deserializer, ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public class BeanDeserializer extends DeserializerImpl implements Serializable
General purpose deserializer for an arbitrary java bean.
Author:
Sam Ruby <rubys@us.ibm.com>, Rich Scheuerle <scheu@us.ibm.com>, Tom Jordahl <tomj@macromedia.com>
See Also:
  • Field Details

    • log

      protected static org.apache.commons.logging.Log log
    • propertyMap

      protected Map propertyMap
    • prevQName

      protected QName prevQName
    • constructorToUse

      protected Constructor constructorToUse
      Constructor if no default constructor
    • constructorTarget

      protected Target constructorTarget
      Constructor Target object to use (if constructorToUse != null)
    • typeDesc

      protected TypeDesc typeDesc
      Type metadata about this class for XML deserialization
    • collectionIndex

      protected int collectionIndex
    • cacheStringDSer

      protected SimpleDeserializer cacheStringDSer
    • cacheXMLType

      protected QName cacheXMLType
  • Constructor Details

    • BeanDeserializer

      public BeanDeserializer(Class javaType, QName xmlType)
    • BeanDeserializer

      public BeanDeserializer(Class javaType, QName xmlType, TypeDesc typeDesc)
    • BeanDeserializer

      public BeanDeserializer(Class javaType, QName xmlType, TypeDesc typeDesc, Map propertyMap)
  • Method Details

    • startElement

      public void startElement(String namespace, String localName, String prefix, Attributes attributes, DeserializationContext context) throws SAXException
      startElement The ONLY reason that this method is overridden is so that the object value can be set or a reasonable exception is thrown indicating that the object cannot be created. This is done at this point so that it occurs BEFORE href/id processing.
      Specified by:
      startElement in interface Deserializer
      Overrides:
      startElement in class DeserializerImpl
      Parameters:
      namespace - is the namespace of the element
      localName - is the name of the element
      prefix - is the prefix of the element
      attributes - are the attributes on the element...used to get the type
      context - is the DeserializationContext
      Throws:
      SAXException
    • onStartChild

      public SOAPHandler onStartChild(String namespace, String localName, String prefix, Attributes attributes, DeserializationContext context) throws SAXException
      Deserializer interface called on each child element encountered in the XML stream.
      Specified by:
      onStartChild in interface Deserializer
      Overrides:
      onStartChild in class DeserializerImpl
      Parameters:
      namespace - is the namespace of the child element
      localName - is the local name of the child element
      prefix - is the prefix used on the name of the child element
      attributes - are the attributes of the child element
      context - is the deserialization context.
      Returns:
      is a Deserializer to use to deserialize a child (must be a derived class of SOAPHandler) or null if no deserialization should be performed.
      Throws:
      SAXException
    • getAnyPropertyDesc

      public BeanPropertyDescriptor getAnyPropertyDesc()
      Get a BeanPropertyDescriptor which indicates where we should put extensibility elements (i.e. XML which falls under the auspices of an <xsd:any> declaration in the schema)
      Returns:
      an appropriate BeanPropertyDescriptor, or null
    • onStartElement

      public void onStartElement(String namespace, String localName, String prefix, Attributes attributes, DeserializationContext context) throws SAXException
      Set the bean properties that correspond to element attributes. This method is invoked after startElement when the element requires deserialization (i.e. the element is not an href and the value is not nil.)
      Specified by:
      onStartElement in interface Deserializer
      Overrides:
      onStartElement in class DeserializerImpl
      Parameters:
      namespace - is the namespace of the element
      localName - is the name of the element
      prefix - is the prefix of the element
      attributes - are the attributes on the element...used to get the type
      context - is the DeserializationContext
      Throws:
      SAXException
    • getDeserializer

      protected Deserializer getDeserializer(QName xmlType, Class javaType, String href, DeserializationContext context)
      Get the Deserializer for the attribute or child element.
      Parameters:
      xmlType - QName of the attribute/child element or null if not known.
      javaType - Class of the corresponding property
      href - String is the value of the href attribute, which is used to determine whether the child element is complete or an href to another element.
      context - DeserializationContext
      Returns:
      Deserializer or null if not found.
    • characters

      public void characters(char[] chars, int start, int end) throws SAXException
      Specified by:
      characters in interface ContentHandler
      Overrides:
      characters in class SOAPHandler
      Throws:
      SAXException
    • onEndElement

      public void onEndElement(String namespace, String localName, DeserializationContext context) throws SAXException
      Description copied from class: DeserializerImpl
      onEndElement is called by endElement. It is not called if the element has an href.
      Specified by:
      onEndElement in interface Deserializer
      Overrides:
      onEndElement in class DeserializerImpl
      Parameters:
      namespace - is the namespace of the child element
      localName - is the local name of the child element
      context - is the deserialization context
      Throws:
      SAXException
    • handleMixedContent

      protected void handleMixedContent() throws SAXException
      Throws:
      SAXException