org.apache.axis.encoding

Class DeserializationContext

Implemented Interfaces:
DeserializationContext, LexicalHandler

public class DeserializationContext
extends DefaultHandler
implements DeserializationContext, LexicalHandler

This interface describes the AXIS DeserializationContext, note that an AXIS compliant DeserializationContext must extend the org.xml.sax.helpers.DefaultHandler.

Field Summary

protected boolean
haveSeenSchemaNS
protected InputSource
inputSource
protected static Log
log
protected MessageContext
msgContext
protected int
startOfMappingsPos

Constructor Summary

DeserializationContext(InputSource is, MessageContext ctx, String messageType)
Construct Deserializer
DeserializationContext(InputSource is, MessageContext ctx, String messageType, SOAPEnvelope env)
Construct Deserializer
DeserializationContext(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
endDTD()
void
endDocument()
endDocument is invoked at the end of the document.
void
endElement(String namespace, String localName, String qName)
endElement is called at the end tag of an element
void
endEntity(java.lang.String name)
void
endPrefixMapping(String prefix)
MessageElement
getCurElement()
Get current MessageElement
ArrayList
getCurrentNSMappings()
Get the Namespace Mappings.
int
getCurrentRecordPos()
Get the current position in the record.
Deserializer
getDeserializer(Class cls, 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(QName xmlType)
Convenience method to get the Deserializer for a specific xmlType.
Class
getDestinationClass()
Allows the destination class to be retrieved so that downstream deserializers like ArrayDeserializer can pick it up when deserializing its components using getDeserializerForClass
Locator
getDocumentLocator()
MessageElement
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.
String
getEncodingStyle()
Returns this context's encoding style.
SOAPEnvelope
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.
QName
getQNameFromString(String qNameStr)
Construct a QName from a string of the form :
SAX2EventRecorder
getRecorder()
Get Event Recorder
SOAPConstants
getSOAPConstants()
returns the soap constants.
int
getStartOfMappingsPos()
Get the start of the mapping position
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.
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.
boolean
hasElementsByID()
Return true if any ids are being tracked by this DeserializationContext
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(MessageElement elem)
Push the MessageElement into the recorder
void
registerElementByID(String id, MessageElement 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(MessageElement el)
Set current MessageElement
void
setDestinationClass(Class destClass)
Allows the destination class to be set so that downstream deserializers like ArrayDeserializer can pick it up when deserializing its components using getDeserializerForClass
void
setDocumentLocator(Locator locator)
void
setProcessingRef(boolean ref)
void
setRecorder(SAX2EventRecorder recorder)
Set Event Recorder
void
skippedEntity(String p1)
void
startCDATA()
void
startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
void
startDocument()
SAX event handlers
void
startElement(String namespace, String localName, String qName, Attributes attributes)
startElement is called when an element is read.
void
startEntity(java.lang.String name)
void
startPrefixMapping(String prefix, String uri)
Record the current set of prefix mappings in the nsMappings table.

Field Details

haveSeenSchemaNS

protected boolean haveSeenSchemaNS


inputSource

protected InputSource inputSource


log

protected static Log log


msgContext

protected MessageContext msgContext


startOfMappingsPos

protected int startOfMappingsPos

Constructor Details

DeserializationContext

public DeserializationContext(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


DeserializationContext

public DeserializationContext(InputSource is,
                              MessageContext ctx,
                              String messageType,
                              SOAPEnvelope 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


DeserializationContext

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

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

Method Details

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.


characters

public void characters(char[] p1,
                       int p2,
                       int p3)
            throws SAXException


comment

public void comment(char[] ch,
                    int start,
                    int length)
            throws SAXException


deserializing

public void deserializing(boolean isDeserializing)


endCDATA

public void endCDATA()
            throws SAXException


endDTD

public void endDTD()
            throws SAXException


endDocument

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


endElement

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


endEntity

public void endEntity(java.lang.String name)
            throws SAXException


endPrefixMapping

public void endPrefixMapping(String prefix)
            throws SAXException


getCurElement

public MessageElement getCurElement()
Get current MessageElement


getCurrentNSMappings

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


getCurrentRecordPos

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


getDeserializer

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


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


getDeserializerForType

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

Parameters:
xmlType - is QName for a type to deserialize

Returns:
Deserializer


getDestinationClass

public Class getDestinationClass()
Allows the destination class to be retrieved so that downstream deserializers like ArrayDeserializer can pick it up when deserializing its components using getDeserializerForClass

Returns:
the Class of the component to be deserialized


getDocumentLocator

public Locator getDocumentLocator()


getElementByID

public MessageElement 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


getEncodingStyle

public String getEncodingStyle()
Returns this context's encoding style. If we've got a message context then we'll get the style from that; otherwise we'll return a default.

Returns:
a String value


getEnvelope

public SOAPEnvelope getEnvelope()
Get Envelope


getMessageContext

public MessageContext getMessageContext()
Get MessageContext


getNamespaceURI

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


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


getQNameFromString

public 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


getRecorder

public SAX2EventRecorder getRecorder()
Get Event Recorder


getSOAPConstants

public SOAPConstants getSOAPConstants()
returns the soap constants.


getStartOfMappingsPos

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


getTypeFromAttributes

public 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


getTypeFromXSITypeAttr

public 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


getTypeMapping

public TypeMapping getTypeMapping()
Get the TypeMapping for this DeserializationContext


getTypeMappingRegistry

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

Returns:
TypeMapping or null


hasElementsByID

public boolean hasElementsByID()
Return true if any ids are being tracked by this DeserializationContext

Returns:
true if any ides are being tracked by this DeserializationContext


ignorableWhitespace

public void ignorableWhitespace(char[] p1,
                                int p2,
                                int p3)
            throws SAXException


isDoneParsing

public boolean isDoneParsing()
Return if done parsing document.


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


isProcessingRef

public boolean isProcessingRef()


parse

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


popElementHandler

public SOAPHandler popElementHandler()


processingInstruction

public void processingInstruction(String p1,
                                  String p2)
            throws SAXException


pushElementHandler

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


pushNewElement

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


registerElementByID

public void registerElementByID(String id,
                                MessageElement 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


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


registerResolverForID

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


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.


resolveEntity

public InputSource resolveEntity(String publicId,
                                 String systemId)


setCurElement

public void setCurElement(MessageElement el)
Set current MessageElement


setDestinationClass

public void setDestinationClass(Class destClass)
Allows the destination class to be set so that downstream deserializers like ArrayDeserializer can pick it up when deserializing its components using getDeserializerForClass

Parameters:
destClass - is the Class of the component to be deserialized


setDocumentLocator

public void setDocumentLocator(Locator locator)


setProcessingRef

public void setProcessingRef(boolean ref)


setRecorder

public void setRecorder(SAX2EventRecorder recorder)
Set Event Recorder


skippedEntity

public void skippedEntity(String p1)
            throws SAXException


startCDATA

public void startCDATA()
            throws SAXException


startDTD

public void startDTD(java.lang.String name,
                     java.lang.String publicId,
                     java.lang.String systemId)
            throws SAXException


startDocument

public void startDocument()
            throws SAXException
SAX event handlers


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).


startEntity

public void startEntity(java.lang.String name)
            throws SAXException


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.)


Copyright B) 2005 Apache Web Services Project. All Rights Reserved.