org.jboss.axis.encoding
Class DeserializationContextImpl

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.jboss.axis.encoding.DeserializationContextImpl
All Implemented Interfaces:
javax.xml.rpc.encoding.DeserializationContext, ContentHandler, DTDHandler, EntityResolver, ErrorHandler, LexicalHandler

public class DeserializationContextImpl
extends DefaultHandler
implements LexicalHandler, DeserializationContext

Author:
Glen Daniels (gdaniels@macromedia.com) Re-architected for JAX-RPC Compliance by:, Rich Scheuerle (scheu@us.ibm.com)

Field Summary
protected  boolean haveSeenSchemaNS
           
protected  InputSource inputSource
           
protected  MessageContext msgContext
           
protected  int startOfMappingsPos
           
 
Constructor Summary
DeserializationContextImpl(InputSource is, MessageContext ctx, String messageType)
          Construct Deserializer
DeserializationContextImpl(InputSource is, MessageContext ctx, String messageType, SOAPEnvelopeAxisImpl env)
          Construct Deserializer
DeserializationContextImpl(MessageContext ctx, SOAPHandler initialHandler)
          Construct Deserializer using MessageContext and EnvelopeBuilder handler
 
Method Summary
 void addObjectById(String id, Object obj)
          Add the object associated with this id (where id is the value of an id= attribute, i.e.
 void characters(char[] p1, int p2, int p3)
           
 void comment(char[] ch, int start, int length)
           
 void deserializing(boolean isDeserializing)
           
 void endCDATA()
           
 void endDocument()
          endDocument is invoked at the end of the document.
 void endDTD()
           
 void endElement(String namespace, String localName, String qName)
          endElement is called at the end tag of an element
 void endEntity(String name)
           
 void endPrefixMapping(String prefix)
           
 SOAPElementAxisImpl getCurElement()
          Get current MessageElement
 ArrayList getCurrentNSMappings()
          Get the Namespace Mappings.
 int getCurrentRecordPos()
          Get the current position in the record.
 Deserializer getDeserializer(Class cls, javax.xml.namespace.QName xmlType)
          Get a Deserializer which can turn a given xml type into a given Java type
 Deserializer getDeserializerForClass(Class cls)
          Convenience method to get the Deserializer for a specific java class from its meta data.
 Deserializer getDeserializerForType(javax.xml.namespace.QName xmlType)
          Convenience method to get the Deserializer for a specific xmlType.
 Locator getDocumentLocator()
           
 SOAPElementAxisImpl getElementByID(String id)
          Get the MessageElement for the indicated id (where id is the #value of an href) If the MessageElement has not been processed, the MessageElement will be returned.
 SOAPEnvelopeAxisImpl getEnvelope()
          Get Envelope
 MessageContext getMessageContext()
          Get MessageContext
 String getNamespaceURI(String prefix)
          Get the Namespace for a particular prefix
 Object getObjectByRef(String href)
          Gets the MessageElement or actual Object value associated with the href value.
 javax.xml.namespace.QName getQNameFromString(String qNameStr)
          Construct a QName from a string of the form :
 SAX2EventRecorder getRecorder()
          Get Event Recorder
 int getStartOfMappingsPos()
          Get the start of the mapping position
 javax.xml.namespace.QName getTypeFromAttributes(String namespace, String localName, Attributes attrs)
          Create a QName for the type of the element defined by localName and namespace with the specified attributes.
 javax.xml.namespace.QName getTypeFromXSITypeAttr(String namespace, String localName, Attributes attrs)
          Create a QName for the type of the element defined by localName and namespace from the XSI type.
 TypeMapping getTypeMapping()
          Get the TypeMapping for this DeserializationContext
 TypeMappingRegistry getTypeMappingRegistry()
          Get the TypeMappingRegistry we're using.
 void ignorableWhitespace(char[] p1, int p2, int p3)
           
 boolean isDoneParsing()
          Return if done parsing document.
 boolean isNil(Attributes attrs)
          Convenenience method that returns true if the value is nil (due to the xsi:nil) attribute.
 boolean isProcessingRef()
           
 void parse()
          Create a parser and parse the inputSource
 SOAPHandler popElementHandler()
           
 void processingInstruction(String p1, String p2)
           
 void pushElementHandler(SOAPHandler handler)
          ************************************************************* Management of sub-handlers (deserializers)
 void pushNewElement(SOAPElementAxisImpl elem)
          Push the MessageElement into the recorder
 void registerElementByID(String id, SOAPElementAxisImpl elem)
          Register the MessageElement with this id (where id is id= form without the #) This routine is called when the MessageElement with an id is read.
 void registerFixup(String href, Deserializer dser)
          During deserialization, an element with an href=#id may be encountered before the element defining id=id is read.
 void registerResolverForID(String id, IDResolver resolver)
          Each id can have its own kind of resolver.
 void replaceElementHandler(SOAPHandler handler)
          Replace the handler at the top of the stack.
 InputSource resolveEntity(String publicId, String systemId)
           
 void setCurElement(SOAPElementAxisImpl el)
          Set current MessageElement
 void setDocumentLocator(Locator locator)
           
 void setProcessingRef(boolean ref)
           
 void setRecorder(SAX2EventRecorder recorder)
          Set Event Recorder
 void skippedEntity(String p1)
           
 void startCDATA()
           
 void startDocument()
          ************************************************************* SAX event handlers
 void startDTD(String name, String publicId, String systemId)
           
 void startElement(String namespace, String localName, String qName, Attributes attributes)
          startElement is called when an element is read.
 void startEntity(String name)
           
 void startPrefixMapping(String prefix, String uri)
          Record the current set of prefix mappings in the nsMappings table.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
error, fatalError, notationDecl, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

msgContext

protected MessageContext msgContext

inputSource

protected InputSource inputSource

startOfMappingsPos

protected int startOfMappingsPos

haveSeenSchemaNS

protected boolean haveSeenSchemaNS
Constructor Detail

DeserializationContextImpl

public DeserializationContextImpl(MessageContext ctx,
                                  SOAPHandler initialHandler)
Construct Deserializer using MessageContext and EnvelopeBuilder handler

Parameters:
ctx - is the MessageContext
initialHandler - is the EnvelopeBuilder handler

DeserializationContextImpl

public DeserializationContextImpl(InputSource is,
                                  MessageContext ctx,
                                  String messageType)
Construct Deserializer

Parameters:
is - is the InputSource
ctx - is the MessageContext
messageType - is the MessageType to construct an EnvelopeBuilder

DeserializationContextImpl

public DeserializationContextImpl(InputSource is,
                                  MessageContext ctx,
                                  String messageType,
                                  SOAPEnvelopeAxisImpl env)
Construct Deserializer

Parameters:
is - is the InputSource
ctx - is the MessageContext
messageType - is the MessageType to construct an EnvelopeBuilder
env - is the SOAPEnvelope to construct an EnvelopeBuilder
Method Detail

deserializing

public void deserializing(boolean isDeserializing)

parse

public void parse()
           throws SAXException
Create a parser and parse the inputSource

Throws:
SAXException

getCurElement

public SOAPElementAxisImpl getCurElement()
Get current MessageElement


setCurElement

public void setCurElement(SOAPElementAxisImpl el)
Set current MessageElement


getMessageContext

public MessageContext getMessageContext()
Get MessageContext


getEnvelope

public SOAPEnvelopeAxisImpl getEnvelope()
Get Envelope


getRecorder

public SAX2EventRecorder getRecorder()
Get Event Recorder


setRecorder

public void setRecorder(SAX2EventRecorder recorder)
Set Event Recorder


getCurrentNSMappings

public ArrayList getCurrentNSMappings()
Get the Namespace Mappings. Returns null if none are present.


getNamespaceURI

public String getNamespaceURI(String prefix)
Get the Namespace for a particular prefix


getQNameFromString

public javax.xml.namespace.QName getQNameFromString(String qNameStr)
Construct a QName from a string of the form :

Parameters:
qNameStr - is the prefixed name from the xml text
Returns:
QName

getTypeFromXSITypeAttr

public javax.xml.namespace.QName getTypeFromXSITypeAttr(String namespace,
                                                        String localName,
                                                        Attributes attrs)
Create a QName for the type of the element defined by localName and namespace from the XSI type.

Parameters:
namespace - of the element
localName - is the local name of the element
attrs - are the attributes on the element

getTypeFromAttributes

public javax.xml.namespace.QName getTypeFromAttributes(String namespace,
                                                       String localName,
                                                       Attributes attrs)
Create a QName for the type of the element defined by localName and namespace with the specified attributes.

Parameters:
namespace - of the element
localName - is the local name of the element
attrs - are the attributes on the element

getDeserializerForClass

public Deserializer getDeserializerForClass(Class cls)
Convenience method to get the Deserializer for a specific java class from its meta data.

Parameters:
cls - is the Class used to find the deserializer
Returns:
Deserializer

isNil

public boolean isNil(Attributes attrs)
Convenenience method that returns true if the value is nil (due to the xsi:nil) attribute.

Parameters:
attrs - are the element attributes.
Returns:
true if xsi:nil is true

getDeserializer

public final Deserializer getDeserializer(Class cls,
                                          javax.xml.namespace.QName xmlType)
Get a Deserializer which can turn a given xml type into a given Java type


getDeserializerForType

public final Deserializer getDeserializerForType(javax.xml.namespace.QName xmlType)
Convenience method to get the Deserializer for a specific xmlType.

Parameters:
xmlType - is QName for a type to deserialize
Returns:
Deserializer

getTypeMapping

public TypeMapping getTypeMapping()
Get the TypeMapping for this DeserializationContext


getTypeMappingRegistry

public TypeMappingRegistry getTypeMappingRegistry()
Get the TypeMappingRegistry we're using.

Returns:
TypeMapping or null

getElementByID

public SOAPElementAxisImpl getElementByID(String id)
Get the MessageElement for the indicated id (where id is the #value of an href) If the MessageElement has not been processed, the MessageElement will be returned. If the MessageElement has been processed, the actual object value is stored with the id and this routine will return null.

Parameters:
id - is the value of an href attribute
Returns:
MessageElement or null

getObjectByRef

public Object getObjectByRef(String href)
Gets the MessageElement or actual Object value associated with the href value. The return of a MessageElement indicates that the referenced element has not been processed. If it is not a MessageElement, the Object is the actual deserialized value. In addition, this method is invoked to get Object values via Attachments.

Parameters:
href - is the value of an href attribute (or an Attachment id)
Returns:
MessageElement other Object or null

addObjectById

public void addObjectById(String id,
                          Object obj)
Add the object associated with this id (where id is the value of an id= attribute, i.e. it does not start with #). This routine is called to associate the deserialized object with the id specified on the XML element.

Parameters:
id - (id name without the #)
obj - is the deserialized object for this id.

registerFixup

public void registerFixup(String href,
                          Deserializer dser)
During deserialization, an element with an href=#id may be encountered before the element defining id=id is read. In these cases, the getObjectByRef method above will return null. The deserializer is placed in a table keyed by href (a fixup table). After the element id is processed, the deserializer is informed of the value so that it can update its target(s) with the value.

Parameters:
href - (#id syntax)
dser - is the deserializer of the element

registerElementByID

public void registerElementByID(String id,
                                SOAPElementAxisImpl elem)
Register the MessageElement with this id (where id is id= form without the #) This routine is called when the MessageElement with an id is read. If there is a Deserializer in our fixup list (described above), the 'fixup' deserializer is given to the MessageElement. When the MessageElement is completed, the 'fixup' deserializer is informed and it can set its targets.

Parameters:
id - (id name without the #)
elem - is the MessageElement

registerResolverForID

public void registerResolverForID(String id,
                                  IDResolver resolver)
Each id can have its own kind of resolver. This registers a resolver for the id.


getCurrentRecordPos

public int getCurrentRecordPos()
Get the current position in the record.


getStartOfMappingsPos

public int getStartOfMappingsPos()
Get the start of the mapping position


pushNewElement

public void pushNewElement(SOAPElementAxisImpl elem)
Push the MessageElement into the recorder


pushElementHandler

public void pushElementHandler(SOAPHandler handler)
************************************************************* Management of sub-handlers (deserializers)


replaceElementHandler

public void replaceElementHandler(SOAPHandler handler)
Replace the handler at the top of the stack.

This is only used when we have a placeholder Deserializer for a referenced object which doesn't know its type until we hit the referent.


popElementHandler

public SOAPHandler popElementHandler()

setProcessingRef

public void setProcessingRef(boolean ref)

isProcessingRef

public boolean isProcessingRef()

startDocument

public void startDocument()
                   throws SAXException
************************************************************* SAX event handlers

Specified by:
startDocument in interface ContentHandler
Overrides:
startDocument in class DefaultHandler
Throws:
SAXException

endDocument

public void endDocument()
                 throws SAXException
endDocument is invoked at the end of the document.

Specified by:
endDocument in interface ContentHandler
Overrides:
endDocument in class DefaultHandler
Throws:
SAXException

isDoneParsing

public boolean isDoneParsing()
Return if done parsing document.


startPrefixMapping

public void startPrefixMapping(String prefix,
                               String uri)
                        throws SAXException
Record the current set of prefix mappings in the nsMappings table.

!!! We probably want to have this mapping be associated with the MessageElements, since they may potentially need access to them long after the end of the prefix mapping here. (example: when we need to record a long string of events scanning forward in the document to find an element with a particular ID.)

Specified by:
startPrefixMapping in interface ContentHandler
Overrides:
startPrefixMapping in class DefaultHandler
Throws:
SAXException

endPrefixMapping

public void endPrefixMapping(String prefix)
                      throws SAXException
Specified by:
endPrefixMapping in interface ContentHandler
Overrides:
endPrefixMapping in class DefaultHandler
Throws:
SAXException

setDocumentLocator

public void setDocumentLocator(Locator locator)
Specified by:
setDocumentLocator in interface ContentHandler
Overrides:
setDocumentLocator in class DefaultHandler

getDocumentLocator

public Locator getDocumentLocator()

characters

public void characters(char[] p1,
                       int p2,
                       int p3)
                throws SAXException
Specified by:
characters in interface ContentHandler
Overrides:
characters in class DefaultHandler
Throws:
SAXException

ignorableWhitespace

public void ignorableWhitespace(char[] p1,
                                int p2,
                                int p3)
                         throws SAXException
Specified by:
ignorableWhitespace in interface ContentHandler
Overrides:
ignorableWhitespace in class DefaultHandler
Throws:
SAXException

processingInstruction

public void processingInstruction(String p1,
                                  String p2)
                           throws SAXException
Specified by:
processingInstruction in interface ContentHandler
Overrides:
processingInstruction in class DefaultHandler
Throws:
SAXException

skippedEntity

public void skippedEntity(String p1)
                   throws SAXException
Specified by:
skippedEntity in interface ContentHandler
Overrides:
skippedEntity in class DefaultHandler
Throws:
SAXException

startElement

public void startElement(String namespace,
                         String localName,
                         String qName,
                         Attributes attributes)
                  throws SAXException
startElement is called when an element is read. This is the big work-horse.

This guy also handles monitoring the recording depth if we're recording (so we know when to stop).

Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class DefaultHandler
Throws:
SAXException

endElement

public void endElement(String namespace,
                       String localName,
                       String qName)
                throws SAXException
endElement is called at the end tag of an element

Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class DefaultHandler
Throws:
SAXException

startDTD

public void startDTD(String name,
                     String publicId,
                     String systemId)
              throws SAXException
Specified by:
startDTD in interface LexicalHandler
Throws:
SAXException

endDTD

public void endDTD()
            throws SAXException
Specified by:
endDTD in interface LexicalHandler
Throws:
SAXException

startEntity

public void startEntity(String name)
                 throws SAXException
Specified by:
startEntity in interface LexicalHandler
Throws:
SAXException

endEntity

public void endEntity(String name)
               throws SAXException
Specified by:
endEntity in interface LexicalHandler
Throws:
SAXException

startCDATA

public void startCDATA()
                throws SAXException
Specified by:
startCDATA in interface LexicalHandler
Throws:
SAXException

endCDATA

public void endCDATA()
              throws SAXException
Specified by:
endCDATA in interface LexicalHandler
Throws:
SAXException

comment

public void comment(char[] ch,
                    int start,
                    int length)
             throws SAXException
Specified by:
comment in interface LexicalHandler
Throws:
SAXException

resolveEntity

public InputSource resolveEntity(String publicId,
                                 String systemId)
Specified by:
resolveEntity in interface EntityResolver
Overrides:
resolveEntity in class DefaultHandler


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.