Package org.apache.axis.encoding
Class DeserializationContext
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- org.apache.axis.encoding.DeserializationContext
-
- All Implemented Interfaces:
DeserializationContext,org.xml.sax.ContentHandler,org.xml.sax.DTDHandler,org.xml.sax.EntityResolver,org.xml.sax.ErrorHandler,org.xml.sax.ext.LexicalHandler
public class DeserializationContext extends org.xml.sax.helpers.DefaultHandler implements DeserializationContext, org.xml.sax.ext.LexicalHandler
This interface describes the AXIS DeserializationContext, note that an AXIS compliant DeserializationContext must extend the org.xml.sax.helpers.DefaultHandler.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanhaveSeenSchemaNSprotected org.xml.sax.InputSourceinputSourceprotected static org.apache.commons.logging.Loglogprotected MessageContextmsgContextprotected intstartOfMappingsPos
-
Constructor Summary
Constructors Constructor Description DeserializationContext(MessageContext ctx, SOAPHandler initialHandler)Construct Deserializer using MessageContext and EnvelopeBuilder handlerDeserializationContext(org.xml.sax.InputSource is, MessageContext ctx, java.lang.String messageType)Construct DeserializerDeserializationContext(org.xml.sax.InputSource is, MessageContext ctx, java.lang.String messageType, SOAPEnvelope env)Construct Deserializer
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddObjectById(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.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(java.lang.String namespace, java.lang.String localName, java.lang.String qName)endElement is called at the end tag of an elementvoidendEntity(java.lang.String name)voidendPrefixMapping(java.lang.String prefix)MessageElementgetCurElement()Get current MessageElementjava.util.ArrayListgetCurrentNSMappings()Get the Namespace Mappings.intgetCurrentRecordPos()Get the current position in the record.DeserializergetDeserializer(java.lang.Class cls, QName xmlType)Get a Deserializer which can turn a given xml type into a given Java typeDeserializergetDeserializerForClass(java.lang.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.java.lang.ClassgetDestinationClass()Allows the destination class to be retrieved so that downstream deserializers like ArrayDeserializer can pick it up when deserializing its components using getDeserializerForClassorg.xml.sax.LocatorgetDocumentLocator()MessageElementgetElementByID(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.java.lang.StringgetEncodingStyle()Returns this context's encoding style.SOAPEnvelopegetEnvelope()Get EnvelopeMessageContextgetMessageContext()Get MessageContextjava.lang.StringgetNamespaceURI(java.lang.String prefix)Get the Namespace for a particular prefixjava.lang.ObjectgetObjectByRef(java.lang.String href)Gets the MessageElement or actual Object value associated with the href value.QNamegetQNameFromString(java.lang.String qNameStr)Construct a QName from a string of the form: SAX2EventRecordergetRecorder()Get Event RecorderSOAPConstantsgetSOAPConstants()returns the soap constants.intgetStartOfMappingsPos()Get the start of the mapping positionQNamegetTypeFromAttributes(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.QNamegetTypeFromXSITypeAttr(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.TypeMappinggetTypeMapping()Get the TypeMapping for this DeserializationContextTypeMappingRegistrygetTypeMappingRegistry()Get the TypeMappingRegistry we're using.booleanhasElementsByID()Return true if any ids are being tracked by this DeserializationContextvoidignorableWhitespace(char[] p1, int p2, int p3)booleanisDoneParsing()Return if done parsing document.booleanisNil(org.xml.sax.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 inputSourceSOAPHandlerpopElementHandler()voidprocessingInstruction(java.lang.String p1, java.lang.String p2)voidpushElementHandler(SOAPHandler handler)Management of sub-handlers (deserializers)voidpushNewElement(MessageElement elem)Push the MessageElement into the recordervoidregisterElementByID(java.lang.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(java.lang.String href, Deserializer dser)During deserialization, an element with an href=#idmay be encountered before the element defining id=id is read. voidregisterResolverForID(java.lang.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.org.xml.sax.InputSourceresolveEntity(java.lang.String publicId, java.lang.String systemId)voidsetCurElement(MessageElement el)Set current MessageElementvoidsetDestinationClass(java.lang.Class destClass)Allows the destination class to be set so that downstream deserializers like ArrayDeserializer can pick it up when deserializing its components using getDeserializerForClassvoidsetDocumentLocator(org.xml.sax.Locator locator)voidsetProcessingRef(boolean ref)voidsetRecorder(SAX2EventRecorder recorder)Set Event RecordervoidskippedEntity(java.lang.String p1)voidstartCDATA()voidstartDocument()SAX event handlersvoidstartDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)voidstartElement(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.voidstartEntity(java.lang.String name)voidstartPrefixMapping(java.lang.String prefix, java.lang.String uri)Record the current set of prefix mappings in the nsMappings table.
-
-
-
Field Detail
-
log
protected static org.apache.commons.logging.Log log
-
msgContext
protected MessageContext msgContext
-
inputSource
protected org.xml.sax.InputSource inputSource
-
startOfMappingsPos
protected int startOfMappingsPos
-
haveSeenSchemaNS
protected boolean haveSeenSchemaNS
-
-
Constructor Detail
-
DeserializationContext
public DeserializationContext(MessageContext ctx, SOAPHandler initialHandler)
Construct Deserializer using MessageContext and EnvelopeBuilder handler- Parameters:
ctx- is the MessageContextinitialHandler- is the EnvelopeBuilder handler
-
DeserializationContext
public DeserializationContext(org.xml.sax.InputSource is, MessageContext ctx, java.lang.String messageType)Construct Deserializer- Parameters:
is- is the InputSourcectx- is the MessageContextmessageType- is the MessageType to construct an EnvelopeBuilder
-
DeserializationContext
public DeserializationContext(org.xml.sax.InputSource is, MessageContext ctx, java.lang.String messageType, SOAPEnvelope env)Construct Deserializer- Parameters:
is- is the InputSourcectx- is the MessageContextmessageType- is the MessageType to construct an EnvelopeBuilderenv- is the SOAPEnvelope to construct an EnvelopeBuilder
-
-
Method Detail
-
deserializing
public void deserializing(boolean isDeserializing)
-
getSOAPConstants
public SOAPConstants getSOAPConstants()
returns the soap constants.
-
parse
public void parse() throws org.xml.sax.SAXExceptionCreate a parser and parse the inputSource- Throws:
org.xml.sax.SAXException
-
getCurElement
public MessageElement getCurElement()
Get current MessageElement
-
setCurElement
public void setCurElement(MessageElement el)
Set current MessageElement
-
getMessageContext
public MessageContext getMessageContext()
Get MessageContext
-
getEncodingStyle
public java.lang.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
Stringvalue
-
getEnvelope
public SOAPEnvelope getEnvelope()
Get Envelope
-
getRecorder
public SAX2EventRecorder getRecorder()
Get Event Recorder
-
setRecorder
public void setRecorder(SAX2EventRecorder recorder)
Set Event Recorder
-
getCurrentNSMappings
public java.util.ArrayList getCurrentNSMappings()
Get the Namespace Mappings. Returns null if none are present.
-
getNamespaceURI
public java.lang.String getNamespaceURI(java.lang.String prefix)
Get the Namespace for a particular prefix
-
getQNameFromString
public QName getQNameFromString(java.lang.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 QName 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.- Parameters:
namespace- of the elementlocalName- is the local name of the elementattrs- are the attributes on the element
-
getTypeFromAttributes
public QName 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.- Parameters:
namespace- of the elementlocalName- is the local name of the elementattrs- are the attributes on the element
-
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.- Parameters:
attrs- are the element attributes.- Returns:
- true if xsi:nil is true
-
getDeserializer
public final Deserializer getDeserializer(java.lang.Class cls, QName xmlType)
Get a Deserializer which can turn a given xml type into a given Java type
-
getDeserializerForClass
public Deserializer getDeserializerForClass(java.lang.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
-
setDestinationClass
public void setDestinationClass(java.lang.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
-
getDestinationClass
public java.lang.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
-
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
-
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 MessageElement 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.- 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.- 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.- Parameters:
id- (id name without the #)obj- is the deserialized object for this id.
-
registerFixup
public void registerFixup(java.lang.String href, Deserializer dser)During deserialization, an element with an href=#idmay 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(java.lang.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
-
registerResolverForID
public void registerResolverForID(java.lang.String id, IDResolver resolver)Each id can have its own kind of resolver. This registers a resolver for the id.
-
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
-
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(MessageElement 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 org.xml.sax.SAXExceptionSAX event handlers- Specified by:
startDocumentin interfaceorg.xml.sax.ContentHandler- Overrides:
startDocumentin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
endDocument
public void endDocument() throws org.xml.sax.SAXExceptionendDocument is invoked at the end of the document.- Specified by:
endDocumentin interfaceorg.xml.sax.ContentHandler- Overrides:
endDocumentin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
isDoneParsing
public boolean isDoneParsing()
Return if done parsing document.
-
startPrefixMapping
public void startPrefixMapping(java.lang.String prefix, java.lang.String uri) throws org.xml.sax.SAXExceptionRecord 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:
startPrefixMappingin interfaceorg.xml.sax.ContentHandler- Overrides:
startPrefixMappingin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
endPrefixMapping
public void endPrefixMapping(java.lang.String prefix) throws org.xml.sax.SAXException- Specified by:
endPrefixMappingin interfaceorg.xml.sax.ContentHandler- Overrides:
endPrefixMappingin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
setDocumentLocator
public void setDocumentLocator(org.xml.sax.Locator locator)
- Specified by:
setDocumentLocatorin interfaceorg.xml.sax.ContentHandler- Overrides:
setDocumentLocatorin classorg.xml.sax.helpers.DefaultHandler
-
getDocumentLocator
public org.xml.sax.Locator getDocumentLocator()
-
characters
public void characters(char[] p1, int p2, int p3) throws org.xml.sax.SAXException- Specified by:
charactersin interfaceorg.xml.sax.ContentHandler- Overrides:
charactersin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
ignorableWhitespace
public void ignorableWhitespace(char[] p1, int p2, int p3) throws org.xml.sax.SAXException- Specified by:
ignorableWhitespacein interfaceorg.xml.sax.ContentHandler- Overrides:
ignorableWhitespacein classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
processingInstruction
public void processingInstruction(java.lang.String p1, java.lang.String p2) throws org.xml.sax.SAXException- Specified by:
processingInstructionin interfaceorg.xml.sax.ContentHandler- Overrides:
processingInstructionin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
skippedEntity
public void skippedEntity(java.lang.String p1) throws org.xml.sax.SAXException- Specified by:
skippedEntityin interfaceorg.xml.sax.ContentHandler- Overrides:
skippedEntityin classorg.xml.sax.helpers.DefaultHandler- 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.SAXExceptionstartElement 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:
startElementin interfaceorg.xml.sax.ContentHandler- Overrides:
startElementin classorg.xml.sax.helpers.DefaultHandler- 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.SAXExceptionendElement is called at the end tag of an element- Specified by:
endElementin interfaceorg.xml.sax.ContentHandler- Overrides:
endElementin classorg.xml.sax.helpers.DefaultHandler- 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:
startDTDin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException
-
endDTD
public void endDTD() throws org.xml.sax.SAXException- Specified by:
endDTDin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException
-
startEntity
public void startEntity(java.lang.String name) throws org.xml.sax.SAXException- Specified by:
startEntityin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException
-
endEntity
public void endEntity(java.lang.String name) throws org.xml.sax.SAXException- Specified by:
endEntityin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException
-
startCDATA
public void startCDATA() throws org.xml.sax.SAXException- Specified by:
startCDATAin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException
-
endCDATA
public void endCDATA() throws org.xml.sax.SAXException- Specified by:
endCDATAin interfaceorg.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:
commentin interfaceorg.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:
resolveEntityin interfaceorg.xml.sax.EntityResolver- Overrides:
resolveEntityin classorg.xml.sax.helpers.DefaultHandler
-
-