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 booleanprotected InputSourceprotected static org.apache.commons.logging.Logprotected MessageContextprotected 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 TypeMethodDescriptionvoidaddObjectById(String id, 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 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 elementvoidvoidendPrefixMapping(String prefix) Get current MessageElementGet the Namespace Mappings.intGet the current position in the record.final DeserializergetDeserializer(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 DeserializergetDeserializerForType(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.intGet 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.booleanReturn true if any ids are being tracked by this DeserializationContextvoidignorableWhitespace(char[] p1, int p2, int p3) booleanReturn if done parsing document.booleanisNil(Attributes attrs) Convenenience method that returns true if the value is nil (due to the xsi:nil) attribute.booleanvoidparse()Create a parser and parse the inputSourcevoidprocessingInstruction(String p1, String p2) voidpushElementHandler(SOAPHandler handler) Management of sub-handlers (deserializers)voidpushNewElement(MessageElement elem) Push the MessageElement into the recordervoidregisterElementByID(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=#idmay 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.resolveEntity(String publicId, String systemId) voidSet current MessageElementvoidsetDestinationClass(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(Locator locator) voidsetProcessingRef(boolean ref) voidsetRecorder(SAX2EventRecorder recorder) Set Event RecordervoidskippedEntity(String p1) voidvoidSAX event handlersvoidvoidstartElement(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.Methods inherited from class org.xml.sax.helpers.DefaultHandler
error, fatalError, notationDecl, unparsedEntityDecl, warningMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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
Stringvalue
-
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:
startDocumentin interfaceContentHandler- Overrides:
startDocumentin classDefaultHandler- Throws:
SAXException
-
endDocument
endDocument is invoked at the end of the document.- Specified by:
endDocumentin interfaceContentHandler- Overrides:
endDocumentin 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:
startPrefixMappingin interfaceContentHandler- Overrides:
startPrefixMappingin classDefaultHandler- Throws:
SAXException
-
endPrefixMapping
- Specified by:
endPrefixMappingin interfaceContentHandler- Overrides:
endPrefixMappingin classDefaultHandler- Throws:
SAXException
-
setDocumentLocator
- Specified by:
setDocumentLocatorin interfaceContentHandler- Overrides:
setDocumentLocatorin classDefaultHandler
-
getDocumentLocator
-
characters
- Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin classDefaultHandler- Throws:
SAXException
-
ignorableWhitespace
- Specified by:
ignorableWhitespacein interfaceContentHandler- Overrides:
ignorableWhitespacein classDefaultHandler- Throws:
SAXException
-
processingInstruction
- Specified by:
processingInstructionin interfaceContentHandler- Overrides:
processingInstructionin classDefaultHandler- Throws:
SAXException
-
skippedEntity
- Specified by:
skippedEntityin interfaceContentHandler- Overrides:
skippedEntityin 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:
startElementin interfaceContentHandler- Overrides:
startElementin classDefaultHandler- Throws:
SAXException
-
endElement
endElement is called at the end tag of an element- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classDefaultHandler- Throws:
SAXException
-
startDTD
- Specified by:
startDTDin interfaceLexicalHandler- Throws:
SAXException
-
endDTD
- Specified by:
endDTDin interfaceLexicalHandler- Throws:
SAXException
-
startEntity
- Specified by:
startEntityin interfaceLexicalHandler- Throws:
SAXException
-
endEntity
- Specified by:
endEntityin interfaceLexicalHandler- Throws:
SAXException
-
startCDATA
- Specified by:
startCDATAin interfaceLexicalHandler- Throws:
SAXException
-
endCDATA
- Specified by:
endCDATAin interfaceLexicalHandler- Throws:
SAXException
-
comment
- Specified by:
commentin interfaceLexicalHandler- Throws:
SAXException
-
resolveEntity
- Specified by:
resolveEntityin interfaceEntityResolver- Overrides:
resolveEntityin classDefaultHandler
-