Package org.apache.axis.encoding
Class DeserializationContext
java.lang.Object
org.xml.sax.helpers.DefaultHandler
org.apache.axis.encoding.DeserializationContext
- All Implemented Interfaces:
DeserializationContext
,ContentHandler
,DTDHandler
,EntityResolver
,ErrorHandler
,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
FieldsModifier and TypeFieldDescriptionprotected boolean
protected InputSource
protected static org.apache.commons.logging.Log
protected MessageContext
protected int
-
Constructor Summary
ConstructorsConstructorDescriptionDeserializationContext
(MessageContext ctx, SOAPHandler initialHandler) Construct Deserializer using MessageContext and EnvelopeBuilder handlerDeserializationContext
(InputSource is, MessageContext ctx, String messageType) Construct DeserializerDeserializationContext
(InputSource is, MessageContext ctx, String messageType, SOAPEnvelope env) Construct Deserializer -
Method Summary
Modifier and TypeMethodDescriptionvoid
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 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 elementvoid
void
endPrefixMapping
(String prefix) Get current MessageElementGet the Namespace Mappings.int
Get the current position in the record.final Deserializer
getDeserializer
(Class cls, QName xmlType) Get a Deserializer which can turn a given xml type into a given Java typeConvenience method to get the Deserializer for a specific java class from its meta data.final Deserializer
getDeserializerForType
(QName xmlType) Convenience method to get the Deserializer for a specific xmlType.Allows the destination class to be retrieved so that downstream deserializers like ArrayDeserializer can pick it up when deserializing its components using getDeserializerForClassgetElementByID
(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.Returns this context's encoding style.Get EnvelopeGet MessageContextgetNamespaceURI
(String prefix) Get the Namespace for a particular prefixgetObjectByRef
(String href) Gets the MessageElement or actual Object value associated with the href value.getQNameFromString
(String qNameStr) Construct a QName from a string of the form: Get Event Recorderreturns the soap constants.int
Get the start of the mapping positiongetTypeFromAttributes
(String namespace, String localName, Attributes attrs) Create a QName for the type of the element defined by localName and namespace with the specified attributes.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.Get the TypeMapping for this DeserializationContextGet the TypeMappingRegistry we're using.boolean
Return true if any ids are being tracked by this DeserializationContextvoid
ignorableWhitespace
(char[] p1, int p2, int p3) boolean
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
void
parse()
Create a parser and parse the inputSourcevoid
processingInstruction
(String p1, String p2) void
pushElementHandler
(SOAPHandler handler) Management of sub-handlers (deserializers)void
pushNewElement
(MessageElement elem) Push the MessageElement into the recordervoid
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=#idmay 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.resolveEntity
(String publicId, String systemId) void
Set current MessageElementvoid
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 getDeserializerForClassvoid
setDocumentLocator
(Locator locator) void
setProcessingRef
(boolean ref) void
setRecorder
(SAX2EventRecorder recorder) Set Event Recordervoid
skippedEntity
(String p1) void
void
SAX event handlersvoid
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
Methods inherited from interface org.xml.sax.ContentHandler
declaration
-
Field Details
-
log
protected static org.apache.commons.logging.Log log -
msgContext
-
inputSource
-
startOfMappingsPos
protected int startOfMappingsPos -
haveSeenSchemaNS
protected boolean haveSeenSchemaNS
-
-
Constructor Details
-
DeserializationContext
Construct Deserializer using MessageContext and EnvelopeBuilder handler- Parameters:
ctx
- is the MessageContextinitialHandler
- is the EnvelopeBuilder handler
-
DeserializationContext
Construct Deserializer- Parameters:
is
- is the InputSourcectx
- is the MessageContextmessageType
- is the MessageType to construct an EnvelopeBuilder
-
DeserializationContext
public DeserializationContext(InputSource is, MessageContext ctx, 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 Details
-
deserializing
public void deserializing(boolean isDeserializing) -
getSOAPConstants
returns the soap constants. -
parse
Create a parser and parse the inputSource- Throws:
SAXException
-
getCurElement
Get current MessageElement -
setCurElement
Set current MessageElement -
getMessageContext
Get MessageContext -
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
Get Envelope -
getRecorder
Get Event Recorder -
setRecorder
Set Event Recorder -
getCurrentNSMappings
Get the Namespace Mappings. Returns null if none are present. -
getNamespaceURI
Get the Namespace for a particular prefix -
getQNameFromString
Construct a QName from a string of the form: - Parameters:
qNameStr
- is the prefixed name from the xml text- Returns:
- QName
-
getTypeFromXSITypeAttr
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
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
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
Get a Deserializer which can turn a given xml type into a given Java type -
getDeserializerForClass
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
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
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
Convenience method to get the Deserializer for a specific xmlType.- Parameters:
xmlType
- is QName for a type to deserialize- Returns:
- Deserializer
-
getTypeMapping
Get the TypeMapping for this DeserializationContext -
getTypeMappingRegistry
Get the TypeMappingRegistry we're using.- Returns:
- TypeMapping or null
-
getElementByID
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
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
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
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
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
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
Push the MessageElement into the recorder -
pushElementHandler
Management of sub-handlers (deserializers) -
replaceElementHandler
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
-
setProcessingRef
public void setProcessingRef(boolean ref) -
isProcessingRef
public boolean isProcessingRef() -
startDocument
SAX event handlers- Specified by:
startDocument
in interfaceContentHandler
- Overrides:
startDocument
in classDefaultHandler
- Throws:
SAXException
-
endDocument
endDocument is invoked at the end of the document.- Specified by:
endDocument
in interfaceContentHandler
- Overrides:
endDocument
in classDefaultHandler
- Throws:
SAXException
-
isDoneParsing
public boolean isDoneParsing()Return if done parsing document. -
startPrefixMapping
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 interfaceContentHandler
- Overrides:
startPrefixMapping
in classDefaultHandler
- Throws:
SAXException
-
endPrefixMapping
- Specified by:
endPrefixMapping
in interfaceContentHandler
- Overrides:
endPrefixMapping
in classDefaultHandler
- Throws:
SAXException
-
setDocumentLocator
- Specified by:
setDocumentLocator
in interfaceContentHandler
- Overrides:
setDocumentLocator
in classDefaultHandler
-
getDocumentLocator
-
characters
- Specified by:
characters
in interfaceContentHandler
- Overrides:
characters
in classDefaultHandler
- Throws:
SAXException
-
ignorableWhitespace
- Specified by:
ignorableWhitespace
in interfaceContentHandler
- Overrides:
ignorableWhitespace
in classDefaultHandler
- Throws:
SAXException
-
processingInstruction
- Specified by:
processingInstruction
in interfaceContentHandler
- Overrides:
processingInstruction
in classDefaultHandler
- Throws:
SAXException
-
skippedEntity
- Specified by:
skippedEntity
in interfaceContentHandler
- Overrides:
skippedEntity
in classDefaultHandler
- 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 interfaceContentHandler
- Overrides:
startElement
in classDefaultHandler
- Throws:
SAXException
-
endElement
endElement is called at the end tag of an element- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classDefaultHandler
- Throws:
SAXException
-
startDTD
- Specified by:
startDTD
in interfaceLexicalHandler
- Throws:
SAXException
-
endDTD
- Specified by:
endDTD
in interfaceLexicalHandler
- Throws:
SAXException
-
startEntity
- Specified by:
startEntity
in interfaceLexicalHandler
- Throws:
SAXException
-
endEntity
- Specified by:
endEntity
in interfaceLexicalHandler
- Throws:
SAXException
-
startCDATA
- Specified by:
startCDATA
in interfaceLexicalHandler
- Throws:
SAXException
-
endCDATA
- Specified by:
endCDATA
in interfaceLexicalHandler
- Throws:
SAXException
-
comment
- Specified by:
comment
in interfaceLexicalHandler
- Throws:
SAXException
-
resolveEntity
- Specified by:
resolveEntity
in interfaceEntityResolver
- Overrides:
resolveEntity
in classDefaultHandler
-