## org.apache.axis.encoding
Class DeserializerImpl

    java.lang.Object
      |
      +--org.xml.sax.helpers.DefaultHandler
            |
            +--org.apache.axis.message.SOAPHandler
                  |
                  +--org.apache.axis.encoding.DeserializerImpl

All Implemented Interfaces:
  Callback, org.xml.sax.ContentHandler, Deserializer, Deserializer, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, java.io.Serializable

Direct Known Subclasses:
  ArrayDeserializer, Base64Deserializer, BeanDeserializer, CastorDeserializer, DocumentDeserializer, ElementDeserializer, HexDeserializer, JAFDataHandlerDeserializer, MapDeserializer, SimpleDeserializer, VectorDeserializer

public class DeserializerImpl
extends SOAPHandler
implements Deserializer, Deserializer, Callback

The Deserializer base class.

Author:
  Glen Daniels (gdaniels@allaire.com) Re-architected for JAX-RPC Compliance by, Rich Scheuerle (sche@us.ibm.com)
See Also:
  Serialized Form

Field Summary
`protected QName` `defaultType`
`protected java.lang.String` `id`
`protected boolean` `isEnded`
`protected boolean` `isHref`
`protected boolean` `isNil`
`protected static org.apache.commons.logging.Log` `log`
`protected java.util.Vector` `targets`
`protected java.lang.Object` `value`

Fields inherited from class org.apache.axis.message.SOAPHandler
`myElement`

Constructor Summary
`DeserializerImpl()`

Method Summary
`void` `addChildDeserializer(Deserializer dSer)`
`boolean` `componentsReady()` Some deserializers (ArrayDeserializer) require all of the component values to be known before the value is complete.
`void` `endElement(java.lang.String namespace, java.lang.String localName, DeserializationContext context)` endElement is called when the end element tag is reached.
`QName` `getDefaultType()`
`java.lang.String` `getMechanismType()` JAX-RPC compliant method which returns mechanism type.
`java.lang.Object` `getValue()` Get the deserialized value.
`java.lang.Object` `getValue(java.lang.Object hint)` If the deserializer has component values (like ArrayDeserializer) this method gets the specific component via the hint.
`java.util.Vector` `getValueTargets()` Get the Value Targets of the Deserializer.
`void` `moveValueTargets(Deserializer other)` Move someone else's targets to our own (see DeserializationContext) The DeserializationContext only allows one Deserializer to wait for a unknown multi-ref'ed value.
`void` `onEndElement(java.lang.String namespace, java.lang.String localName, DeserializationContext context)` onEndElement is called by endElement.
`SOAPHandler` `onStartChild(java.lang.String namespace, java.lang.String localName, java.lang.String prefix, org.xml.sax.Attributes attributes, DeserializationContext context)` onStartChild is called on each child element.
`void` `onStartElement(java.lang.String namespace, java.lang.String localName, java.lang.String prefix, org.xml.sax.Attributes attributes, DeserializationContext context)` This method is invoked after startElement when the element requires deserialization (i.e.
`void` `registerValueTarget(Target target)` For deserializers of non-primitives, the value may not be known until later (due to multi-referencing).
`void` `removeValueTargets()` Remove the Value Targets of the Deserializer.
`void` `setChildValue(java.lang.Object value, java.lang.Object hint)` If the deserializer has component values (like ArrayDeserializer) this method sets the specific component via the hint.
`void` `setDefaultType(QName qName)` In some circumstances an element may not have a type attribute, but a default type qname is known from information in the container.
`void` `setValue(java.lang.Object value)` Set the deserialized value.
`void` `setValue(java.lang.Object value, java.lang.Object hint)`
`void` `startElement(java.lang.String namespace, java.lang.String localName, java.lang.String prefix, org.xml.sax.Attributes attributes, DeserializationContext context)` This method is invoked when an element start tag is encountered.
`void` `valueComplete()` The valueComplete() method is invoked when the end tag of the element is read.

Methods inherited from class org.apache.axis.message.SOAPHandler
`makeNewElement, onEndChild`

Methods inherited from class org.xml.sax.helpers.DefaultHandler
`characters, endDocument, endElement, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping, unparsedEntityDecl, warning`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### log

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

### value

    protected java.lang.Object value

### isEnded

    protected boolean isEnded

### targets

    protected java.util.Vector targets

### defaultType

    protected QName defaultType

### isHref

    protected boolean isHref

### isNil

    protected boolean isNil

### id

    protected java.lang.String id

Constructor Detail

### DeserializerImpl

    public DeserializerImpl()

Method Detail

### getMechanismType

    public java.lang.String getMechanismType()

  JAX-RPC compliant method which returns mechanism type.

  Specified by:
    `getMechanismType` in interface `Deserializer`
  Returns:
    XML processing mechanism type

### getValue

    public java.lang.Object getValue()

  Get the deserialized value.

  Specified by:
    `getValue` in interface `Deserializer`
  Returns:
    Object representing deserialized value or null

### setValue

    public void setValue(java.lang.Object value)

  Set the deserialized value.

  Specified by:
    `setValue` in interface `Deserializer`
  Parameters:
    `value` - Object representing deserialized value

### getValue

    public java.lang.Object getValue(java.lang.Object hint)

  If the deserializer has component values (like ArrayDeserializer) this method gets the specific component via the hint. The default implementation returns null.

  Specified by:
    `getValue` in interface `Deserializer`
  Returns:
    Object representing deserialized value or null

### setChildValue

    public void setChildValue(java.lang.Object value,
                              java.lang.Object hint)
                       throws org.xml.sax.SAXException

  If the deserializer has component values (like ArrayDeserializer) this method sets the specific component via the hint. The default implementation does nothing.

  Specified by:
    `setChildValue` in interface `Deserializer`
  Parameters:
    `hint` - Object representing deserialized value or null
    `value` - Object representing deserialized value or null
    `org.xml.sax.SAXException`

### setValue

    public void setValue(java.lang.Object value,
                         java.lang.Object hint)
                  throws org.xml.sax.SAXException

  Specified by:
    `setValue` in interface `Callback`
    `org.xml.sax.SAXException`

### setDefaultType

    public void setDefaultType(QName qName)

  In some circumstances an element may not have a type attribute, but a default type qname is known from information in the container. For example, an element of an array may not have a type= attribute, so the default qname is the component type of the array. This method is used to communicate the default type information to the deserializer.

  Specified by:
    `setDefaultType` in interface `Deserializer`

### getDefaultType

    public QName getDefaultType()

  Specified by:
    `getDefaultType` in interface `Deserializer`

### registerValueTarget

    public void registerValueTarget(Target target)

  For deserializers of non-primitives, the value may not be known until later (due to multi-referencing). In such cases the deserializer registers Target object(s). When the value is known, the set(value) will be invoked for each Target registered with the Deserializer. The Target object abstracts the function of setting a target with a value. See the Target interface for more info.

  Specified by:
    `registerValueTarget` in interface `Deserializer`
  Parameters:
    `target` -

### getValueTargets

    public java.util.Vector getValueTargets()

  Get the Value Targets of the Deserializer.

  Specified by:
    `getValueTargets` in interface `Deserializer`
  Returns:
    Vector of Target objects or null

### removeValueTargets

    public void removeValueTargets()

  Remove the Value Targets of the Deserializer.

  Specified by:
    `removeValueTargets` in interface `Deserializer`

### moveValueTargets

    public void moveValueTargets(Deserializer other)

  Move someone else's targets to our own (see DeserializationContext) The DeserializationContext only allows one Deserializer to wait for a unknown multi-ref'ed value. So to ensure that all of the targets are updated, this method is invoked to copy the Target objects to the waiting Deserializer.

  Specified by:
    `moveValueTargets` in interface `Deserializer`
  Parameters:
    `other` - is the Deserializer to copy targets from.

### componentsReady

    public boolean componentsReady()

  Some deserializers (ArrayDeserializer) require all of the component values to be known before the value is complete. (For the ArrayDeserializer this is important because the elements are stored in an ArrayList, and all values must be known before the ArrayList is converted into the expected array. This routine is used to indicate when the components are ready. The default (true) is useful for most Deserializers.

  Specified by:
    `componentsReady` in interface `Deserializer`

### valueComplete

    public void valueComplete()
                       throws org.xml.sax.SAXException

  The valueComplete() method is invoked when the end tag of the element is read. This results in the setting of all registered Targets (see registerValueTarget). Note that the valueComplete() only processes the Targets if componentReady() returns true. So if you override componentReady(), then your specific Deserializer will need to call valueComplete() when your components are ready (See ArrayDeserializer)

  Specified by:
    `valueComplete` in interface `Deserializer`
    `org.xml.sax.SAXException`

### addChildDeserializer

    public void addChildDeserializer(Deserializer dSer)

### startElement

    public void startElement(java.lang.String namespace,
                             java.lang.String localName,
                             java.lang.String prefix,
                             org.xml.sax.Attributes attributes,
                             DeserializationContext context)
                      throws org.xml.sax.SAXException

  This method is invoked when an element start tag is encountered. DeserializerImpl provides default behavior, which involves the following: - directly handling the deserialization of a nill value - handling the registration of the id value. - handling the registration of a fixup if this element is an href. - calling onStartElement to do the actual deserialization if not nill or href cases.

  Specified by:
    `startElement` in interface `Deserializer`
  Overrides:
    `startElement` in class `SOAPHandler`
  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 Normally a specific Deserializer (FooDeserializer) should extend DeserializerImpl. Here is the flow that will occur in such cases: 1) DeserializerImpl.startElement(...) will be called and do the id/href/nill stuff. 2) If real deserialization needs to take place DeserializerImpl.onStartElement will be invoked, which will attempt to install the specific Deserializer (FooDeserializer) 3) The FooDeserializer.startElement(...) will be called to do the Foo specific stuff. This results in a call to FooDeserializer.onStartElement(...) if startElement was not overridden. 4) The onChildElement(...) method is called for each child element. Nothing occurs if not overridden. The FooDeserializer.onStartChild(...) method should return the deserializer for the child element. 5) When the end tag is reached, the endElement(..) method is invoked. The default behavior is to handle hrefs/ids, call onEndElement and then call the Deserializer valueComplete method. So the methods that you potentially want to override are: onStartElement, onStartChild, componentsReady, setValue(object, hint) You probably should not override startElement or endElement. If you need specific behaviour at the end of the element consider overriding onEndElement. See the pre-existing Deserializers for more information.
    `org.xml.sax.SAXException`

### onStartElement

    public void onStartElement(java.lang.String namespace,
                               java.lang.String localName,
                               java.lang.String prefix,
                               org.xml.sax.Attributes attributes,
                               DeserializationContext context)
                        throws org.xml.sax.SAXException

  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.) DeserializerImpl provides default behavior, which simply involves obtaining a correct Deserializer and plugging its handler.

  Specified by:
    `onStartElement` in interface `Deserializer`
  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
    `org.xml.sax.SAXException`

### onStartChild

    public SOAPHandler onStartChild(java.lang.String namespace,
                                    java.lang.String localName,
                                    java.lang.String prefix,
                                    org.xml.sax.Attributes attributes,
                                    DeserializationContext context)
                             throws org.xml.sax.SAXException

  onStartChild is called on each child element. The default behavior supplied by DeserializationImpl is to do nothing. A specific deserializer may perform other tasks. For example a BeanDeserializer will construct a deserializer for the indicated property and return it.

  Specified by:
    `onStartChild` in interface `Deserializer`
  Overrides:
    `onStartChild` in class `SOAPHandler`
  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.
    `org.xml.sax.SAXException`

### endElement

    public final void endElement(java.lang.String namespace,
                                 java.lang.String localName,
                                 DeserializationContext context)
                          throws org.xml.sax.SAXException

  endElement is called when the end element tag is reached. It handles href/id information for multi-ref processing and invokes the valueComplete() method of the deserializer which sets the targets with the deserialized value.

  Specified by:
    `endElement` in interface `Deserializer`
  Overrides:
    `endElement` in class `SOAPHandler`
  Parameters:
    `namespace` - is the namespace of the child element
    `localName` - is the local name of the child element
    `context` - is the deserialization context
    `org.xml.sax.SAXException`

### onEndElement

    public void onEndElement(java.lang.String namespace,
                             java.lang.String localName,
                             DeserializationContext context)
                      throws org.xml.sax.SAXException

  onEndElement is called by endElement. It is not called if the element has an href.

  Specified by:
    `onEndElement` in interface `Deserializer`
  Parameters:
    `namespace` - is the namespace of the child element
    `localName` - is the local name of the child element
    `context` - is the deserialization context
    `org.xml.sax.SAXException`

Copyright © 2003 Apache Web Services Project. All Rights Reserved.