org.apache.axis.encoding

Class DeserializationContext

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 booleanhaveSeenSchemaNS
protected InputSourceinputSource
protected static Loglog
protected MessageContextmsgContext
protected intstartOfMappingsPos
Constructor Summary
DeserializationContext(MessageContext ctx, SOAPHandler initialHandler)
Construct Deserializer using MessageContext and EnvelopeBuilder handler
DeserializationContext(InputSource is, MessageContext ctx, String messageType)
Construct Deserializer
DeserializationContext(InputSource is, MessageContext ctx, String messageType, SOAPEnvelope env)
Construct Deserializer
Method Summary
voidaddObjectById(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 #).
voidcharacters(char[] p1, int p2, int p3)
voidcomment(char[] ch, int start, int length)
voiddeserializing(boolean isDeserializing)
voidendCDATA()
voidendDocument()
endDocument is invoked at the end of the document.
voidendDTD()
voidendElement(String namespace, String localName, String qName)
endElement is called at the end tag of an element
voidendEntity(String name)
voidendPrefixMapping(String prefix)
MessageElementgetCurElement()
Get current MessageElement
ArrayListgetCurrentNSMappings()
Get the Namespace Mappings.
intgetCurrentRecordPos()
Get the current position in the record.
DeserializergetDeserializer(Class cls, QName xmlType)
Get a Deserializer which can turn a given xml type into a given Java type
DeserializergetDeserializerForClass(Class cls)
Convenience method to get the Deserializer for a specific java class from its meta data.
DeserializergetDeserializerForType(QName xmlType)
Convenience method to get the Deserializer for a specific xmlType.
ClassgetDestinationClass()
Allows the destination class to be retrieved so that downstream deserializers like ArrayDeserializer can pick it up when deserializing its components using getDeserializerForClass
LocatorgetDocumentLocator()
MessageElementgetElementByID(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.
StringgetEncodingStyle()
Returns this context's encoding style.
SOAPEnvelopegetEnvelope()
Get Envelope
MessageContextgetMessageContext()
Get MessageContext
StringgetNamespaceURI(String prefix)
Get the Namespace for a particular prefix
ObjectgetObjectByRef(String href)
Gets the MessageElement or actual Object value associated with the href value.
QNamegetQNameFromString(String qNameStr)
Construct a QName from a string of the form :
SAX2EventRecordergetRecorder()
Get Event Recorder
SOAPConstantsgetSOAPConstants()
returns the soap constants.
intgetStartOfMappingsPos()
Get the start of the mapping position
QNamegetTypeFromAttributes(String namespace, String localName, Attributes attrs)
Create a QName for the type of the element defined by localName and namespace with the specified attributes.
QNamegetTypeFromXSITypeAttr(String namespace, String localName, Attributes attrs)
Create a QName for the type of the element defined by localName and namespace from the XSI type.
TypeMappinggetTypeMapping()
Get the TypeMapping for this DeserializationContext
TypeMappingRegistrygetTypeMappingRegistry()
Get the TypeMappingRegistry we're using.
booleanhasElementsByID()
Return true if any ids are being tracked by this DeserializationContext
voidignorableWhitespace(char[] p1, int p2, int p3)
booleanisDoneParsing()
Return if done parsing document.
booleanisNil(Attributes attrs)
Convenenience method that returns true if the value is nil (due to the xsi:nil) attribute.
booleanisProcessingRef()
voidparse()
Create a parser and parse the inputSource
SOAPHandlerpopElementHandler()
voidprocessingInstruction(String p1, String p2)
voidpushElementHandler(SOAPHandler handler)
Management of sub-handlers (deserializers)
voidpushNewElement(MessageElement elem)
Push the MessageElement into the recorder
voidregisterElementByID(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.
voidregisterFixup(String href, Deserializer dser)
During deserialization, an element with an href=#id may be encountered before the element defining id=id is read.
voidregisterResolverForID(String id, IDResolver resolver)
Each id can have its own kind of resolver.
voidreplaceElementHandler(SOAPHandler handler)
Replace the handler at the top of the stack.
InputSourceresolveEntity(String publicId, String systemId)
voidsetCurElement(MessageElement el)
Set current MessageElement
voidsetDestinationClass(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
voidsetDocumentLocator(Locator locator)
voidsetProcessingRef(boolean ref)
voidsetRecorder(SAX2EventRecorder recorder)
Set Event Recorder
voidskippedEntity(String p1)
voidstartCDATA()
voidstartDocument()
SAX event handlers
voidstartDTD(String name, String publicId, String systemId)
voidstartElement(String namespace, String localName, String qName, Attributes attributes)
startElement is called when an element is read.
voidstartEntity(String name)
voidstartPrefixMapping(String prefix, String uri)
Record the current set of prefix mappings in the nsMappings table.

Field Detail

haveSeenSchemaNS

protected boolean haveSeenSchemaNS

inputSource

protected InputSource inputSource

log

protected static Log log

msgContext

protected MessageContext msgContext

startOfMappingsPos

protected int startOfMappingsPos

Constructor Detail

DeserializationContext

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

Parameters: ctx is the MessageContext initialHandler is the EnvelopeBuilder handler

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

Method Detail

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)

comment

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

deserializing

public void deserializing(boolean isDeserializing)

endCDATA

public void endCDATA()

endDocument

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

endDTD

public void endDTD()

endElement

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

endEntity

public void endEntity(String name)

endPrefixMapping

public void endPrefixMapping(String prefix)

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)

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()
Create a parser and parse the inputSource

popElementHandler

public SOAPHandler popElementHandler()

processingInstruction

public void processingInstruction(String p1, String p2)

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)

startCDATA

public void startCDATA()

startDocument

public void startDocument()
SAX event handlers

startDTD

public void startDTD(String name, String publicId, String systemId)

startElement

public void startElement(String namespace, String localName, String qName, Attributes attributes)
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(String name)

startPrefixMapping

public void startPrefixMapping(String prefix, String uri)
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.