org.jboss.axis.encoding
Class DeserializationContextImpl

java.lang.Object
  extended byorg.xml.sax.helpers.DefaultHandler
      extended byorg.jboss.axis.encoding.DeserializationContextImpl
All Implemented Interfaces:
org.xml.sax.ContentHandler, DeserializationContext (src) , DeserializationContext (src) , org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, org.xml.sax.ext.LexicalHandler

public class DeserializationContextImpl
extends org.xml.sax.helpers.DefaultHandler
implements org.xml.sax.ext.LexicalHandler, DeserializationContext (src)


Field Summary
protected  boolean haveSeenSchemaNS
           
protected  org.xml.sax.InputSource inputSource
           
protected  MessageContext (src) msgContext
           
protected  int startOfMappingsPos
           
 
Constructor Summary
DeserializationContextImpl(org.xml.sax.InputSource is, MessageContext (src)  ctx, java.lang.String messageType)
          Construct Deserializer
DeserializationContextImpl(org.xml.sax.InputSource is, MessageContext (src)  ctx, java.lang.String messageType, SOAPEnvelopeAxisImpl (src)  env)
          Construct Deserializer
DeserializationContextImpl(MessageContext (src)  ctx, SOAPHandler (src)  initialHandler)
          Construct Deserializer using MessageContext and EnvelopeBuilder handler
 
Method Summary
 void addObjectById(java.lang.String id, java.lang.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(java.lang.String namespace, java.lang.String localName, java.lang.String qName)
          endElement is called at the end tag of an element
 void endEntity(java.lang.String name)
           
 void endPrefixMapping(java.lang.String prefix)
           
 SOAPElementAxisImpl (src) getCurElement()
          Get current MessageElement
 java.util.ArrayList getCurrentNSMappings()
          Get the Namespace Mappings.
 int getCurrentRecordPos()
          Get the current position in the record.
 Deserializer (src) getDeserializer(java.lang.Class cls, QName (src)  xmlType)
          Get a Deserializer which can turn a given xml type into a given Java type
 Deserializer (src) getDeserializerForClass(java.lang.Class cls)
          Convenience method to get the Deserializer for a specific java class from its meta data.
 Deserializer (src) getDeserializerForType(QName (src)  xmlType)
          Convenience method to get the Deserializer for a specific xmlType.
 org.xml.sax.Locator getDocumentLocator()
           
 SOAPElementAxisImpl (src) getElementByID(java.lang.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 (src) getEnvelope()
          Get Envelope
 MessageContext (src) getMessageContext()
          Get MessageContext
 java.lang.String getNamespaceURI(java.lang.String prefix)
          Get the Namespace for a particular prefix
 java.lang.Object getObjectByRef(java.lang.String href)
          Gets the MessageElement or actual Object value associated with the href value.
 QName (src) getQNameFromString(java.lang.String qNameStr)
          Construct a QName from a string of the form :
 SAX2EventRecorder (src) getRecorder()
          Get Event Recorder
 int getStartOfMappingsPos()
          Get the start of the mapping position
 QName (src) getTypeFromAttributes(java.lang.String namespace, java.lang.String localName, org.xml.sax.Attributes attrs)
          Create a QName for the type of the element defined by localName and namespace with the specified attributes.
 QName (src) getTypeFromXSITypeAttr(java.lang.String namespace, java.lang.String localName, org.xml.sax.Attributes attrs)
          Create a QName for the type of the element defined by localName and namespace from the XSI type.
 TypeMapping (src) getTypeMapping()
          Get the TypeMapping for this DeserializationContext
 TypeMappingRegistry (src) getTypeMappingRegistry()
          Get the TypeMappingRegistry we're using.
 void ignorableWhitespace(char[] p1, int p2, int p3)
           
 boolean isDoneParsing()
          Return if done parsing document.
 boolean isNil(org.xml.sax.Attributes attrs)
          Convenenience method that returns true if the value is nil (due to the xsi:nil) attribute.
 boolean isProcessingRef()
          Are we in the midst of processing an href target? If so, we shouldn't be pushing the element stack...
 void parse()
          Create a parser and parse the inputSource
 SOAPHandler (src) popElementHandler()
           
 void processingInstruction(java.lang.String p1, java.lang.String p2)
           
 void pushElementHandler(SOAPHandler (src)  handler)
          ************************************************************* Management of sub-handlers (deserializers)
 void pushNewElement(SOAPElementAxisImpl (src)  elem)
          Push the MessageElement into the recorder
 void registerElementByID(java.lang.String id, SOAPElementAxisImpl (src)  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(java.lang.String href, Deserializer (src)  dser)
          During deserialization, an element with an href=#id may be encountered before the element defining id=id is read.
 void registerResolverForID(java.lang.String id, IDResolver (src)  resolver)
          Each id can have its own kind of resolver.
 void replaceElementHandler(SOAPHandler (src)  handler)
          Replace the handler at the top of the stack.
 org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId)
           
 void setCurElement(SOAPElementAxisImpl (src)  el)
          Set current MessageElement
 void setDocumentLocator(org.xml.sax.Locator locator)
           
 void setProcessingRef(boolean ref)
          Indicate if we're in the midst of processing an href target, in which case we shouldn't be pushing the element stack.
 void setRecorder(SAX2EventRecorder (src)  recorder)
          Set Event Recorder
 void skippedEntity(java.lang.String p1)
           
 void startCDATA()
           
 void startDocument()
          ************************************************************* SAX event handlers
 void startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
           
 void startElement(java.lang.String namespace, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)
          startElement is called when an element is read.
 void startEntity(java.lang.String name)
           
 void startPrefixMapping(java.lang.String prefix, java.lang.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 (src)  msgContext

inputSource

protected org.xml.sax.InputSource inputSource

startOfMappingsPos

protected int startOfMappingsPos

haveSeenSchemaNS

protected boolean haveSeenSchemaNS
Constructor Detail

DeserializationContextImpl

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

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

DeserializationContextImpl

public DeserializationContextImpl(org.xml.sax.InputSource is,
                                  MessageContext (src)  ctx,
                                  java.lang.String messageType)
Construct Deserializer

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

DeserializationContextImpl

public DeserializationContextImpl(org.xml.sax.InputSource is,
                                  MessageContext (src)  ctx,
                                  java.lang.String messageType,
                                  SOAPEnvelopeAxisImpl (src)  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 org.xml.sax.SAXException
Create a parser and parse the inputSource

Specified by:
parse in interface DeserializationContext (src)
Throws:
org.xml.sax.SAXException

getCurElement

public SOAPElementAxisImpl (src)  getCurElement()
Get current MessageElement

Specified by:
getCurElement in interface DeserializationContext (src)

setCurElement

public void setCurElement(SOAPElementAxisImpl (src)  el)
Set current MessageElement

Specified by:
setCurElement in interface DeserializationContext (src)

getMessageContext

public MessageContext (src)  getMessageContext()
Get MessageContext

Specified by:
getMessageContext in interface DeserializationContext (src)

getEnvelope

public SOAPEnvelopeAxisImpl (src)  getEnvelope()
Get Envelope

Specified by:
getEnvelope in interface DeserializationContext (src)

getRecorder

public SAX2EventRecorder (src)  getRecorder()
Get Event Recorder

Specified by:
getRecorder in interface DeserializationContext (src)

setRecorder

public void setRecorder(SAX2EventRecorder (src)  recorder)
Set Event Recorder

Specified by:
setRecorder in interface DeserializationContext (src)

getCurrentNSMappings

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

Specified by:
getCurrentNSMappings in interface DeserializationContext (src)

getNamespaceURI

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

Specified by:
getNamespaceURI in interface DeserializationContext (src)

getQNameFromString

public QName (src)  getQNameFromString(java.lang.String qNameStr)
Construct a QName from a string of the form :

Specified by:
getQNameFromString in interface DeserializationContext (src)
Parameters:
qNameStr - is the prefixed name from the xml text
Returns:
QName

getTypeFromXSITypeAttr

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

Specified by:
getTypeFromXSITypeAttr in interface DeserializationContext (src)
Parameters:
namespace - of the element
localName - is the local name of the element
attrs - are the attributes on the element

getTypeFromAttributes

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

Specified by:
getTypeFromAttributes in interface DeserializationContext (src)
Parameters:
namespace - of the element
localName - is the local name of the element
attrs - are the attributes on the element

getDeserializerForClass

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

Specified by:
getDeserializerForClass in interface DeserializationContext (src)
Parameters:
cls - is the Class used to find the deserializer
Returns:
Deserializer

isNil

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

Specified by:
isNil in interface DeserializationContext (src)
Parameters:
attrs - are the element attributes.
Returns:
true if xsi:nil is true

getDeserializer

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

Specified by:
getDeserializer in interface DeserializationContext (src)

getDeserializerForType

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

Specified by:
getDeserializerForType in interface DeserializationContext (src)
Parameters:
xmlType - is QName for a type to deserialize
Returns:
Deserializer

getTypeMapping

public TypeMapping (src)  getTypeMapping()
Get the TypeMapping for this DeserializationContext

Specified by:
getTypeMapping in interface DeserializationContext (src)

getTypeMappingRegistry

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

Specified by:
getTypeMappingRegistry in interface DeserializationContext (src)
Returns:
TypeMapping or null

getElementByID

public SOAPElementAxisImpl (src)  getElementByID(java.lang.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.

Specified by:
getElementByID in interface DeserializationContext (src)
Parameters:
id - is the value of an href attribute
Returns:
MessageElement or null

getObjectByRef

public java.lang.Object getObjectByRef(java.lang.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.

Specified by:
getObjectByRef in interface DeserializationContext (src)
Parameters:
href - is the value of an href attribute (or an Attachment id)
Returns:
MessageElement other Object or null

addObjectById

public void addObjectById(java.lang.String id,
                          java.lang.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.

Specified by:
addObjectById in interface DeserializationContext (src)
Parameters:
id - (id name without the #)
obj - is the deserialized object for this id.

registerFixup

public void registerFixup(java.lang.String href,
                          Deserializer (src)  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.

Specified by:
registerFixup in interface DeserializationContext (src)
Parameters:
href - (#id syntax)
dser - is the deserializer of the element

registerElementByID

public void registerElementByID(java.lang.String id,
                                SOAPElementAxisImpl (src)  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.

Specified by:
registerElementByID in interface DeserializationContext (src)
Parameters:
id - (id name without the #)
elem - is the MessageElement

registerResolverForID

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

Specified by:
registerResolverForID in interface DeserializationContext (src)

getCurrentRecordPos

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

Specified by:
getCurrentRecordPos in interface DeserializationContext (src)

getStartOfMappingsPos

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

Specified by:
getStartOfMappingsPos in interface DeserializationContext (src)

pushNewElement

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

Specified by:
pushNewElement in interface DeserializationContext (src)

pushElementHandler

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

Specified by:
pushElementHandler in interface DeserializationContext (src)

replaceElementHandler

public void replaceElementHandler(SOAPHandler (src)  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.

Specified by:
replaceElementHandler in interface DeserializationContext (src)

popElementHandler

public SOAPHandler (src)  popElementHandler()
Specified by:
popElementHandler in interface DeserializationContext (src)

setProcessingRef

public void setProcessingRef(boolean ref)
Description copied from interface: DeserializationContext (src)
Indicate if we're in the midst of processing an href target, in which case we shouldn't be pushing the element stack.

Specified by:
setProcessingRef in interface DeserializationContext (src)
Parameters:
ref -

isProcessingRef

public boolean isProcessingRef()
Description copied from interface: DeserializationContext (src)
Are we in the midst of processing an href target? If so, we shouldn't be pushing the element stack...

Specified by:
isProcessingRef in interface DeserializationContext (src)
Returns:

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
************************************************************* SAX event handlers

Specified by:
startDocument in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

endDocument

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

Specified by:
endDocument in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

isDoneParsing

public boolean isDoneParsing()
Return if done parsing document.

Specified by:
isDoneParsing in interface DeserializationContext (src)

startPrefixMapping

public void startPrefixMapping(java.lang.String prefix,
                               java.lang.String uri)
                        throws org.xml.sax.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 org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

endPrefixMapping

public void endPrefixMapping(java.lang.String prefix)
                      throws org.xml.sax.SAXException
Specified by:
endPrefixMapping in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator locator)
Specified by:
setDocumentLocator in interface org.xml.sax.ContentHandler

getDocumentLocator

public org.xml.sax.Locator getDocumentLocator()

characters

public void characters(char[] p1,
                       int p2,
                       int p3)
                throws org.xml.sax.SAXException
Specified by:
characters in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

ignorableWhitespace

public void ignorableWhitespace(char[] p1,
                                int p2,
                                int p3)
                         throws org.xml.sax.SAXException
Specified by:
ignorableWhitespace in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

processingInstruction

public void processingInstruction(java.lang.String p1,
                                  java.lang.String p2)
                           throws org.xml.sax.SAXException
Specified by:
processingInstruction in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

skippedEntity

public void skippedEntity(java.lang.String p1)
                   throws org.xml.sax.SAXException
Specified by:
skippedEntity in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

startElement

public void startElement(java.lang.String namespace,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes attributes)
                  throws org.xml.sax.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 org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

endElement

public void endElement(java.lang.String namespace,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
endElement is called at the end tag of an element

Specified by:
endElement in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

startDTD

public void startDTD(java.lang.String name,
                     java.lang.String publicId,
                     java.lang.String systemId)
              throws org.xml.sax.SAXException
Specified by:
startDTD in interface org.xml.sax.ext.LexicalHandler
Throws:
org.xml.sax.SAXException

endDTD

public void endDTD()
            throws org.xml.sax.SAXException
Specified by:
endDTD in interface org.xml.sax.ext.LexicalHandler
Throws:
org.xml.sax.SAXException

startEntity

public void startEntity(java.lang.String name)
                 throws org.xml.sax.SAXException
Specified by:
startEntity in interface org.xml.sax.ext.LexicalHandler
Throws:
org.xml.sax.SAXException

endEntity

public void endEntity(java.lang.String name)
               throws org.xml.sax.SAXException
Specified by:
endEntity in interface org.xml.sax.ext.LexicalHandler
Throws:
org.xml.sax.SAXException

startCDATA

public void startCDATA()
                throws org.xml.sax.SAXException
Specified by:
startCDATA in interface org.xml.sax.ext.LexicalHandler
Throws:
org.xml.sax.SAXException

endCDATA

public void endCDATA()
              throws org.xml.sax.SAXException
Specified by:
endCDATA in interface org.xml.sax.ext.LexicalHandler
Throws:
org.xml.sax.SAXException

comment

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

resolveEntity

public org.xml.sax.InputSource resolveEntity(java.lang.String publicId,
                                             java.lang.String systemId)
Specified by:
resolveEntity in interface org.xml.sax.EntityResolver