org.apache.axis.encoding
Class SerializationContext

java.lang.Object
  |
  +--org.apache.axis.encoding.SerializationContext

public class SerializationContext
extends java.lang.Object

Manage a serialization, including keeping track of namespace mappings and element stacks. WARNING : HIGHLY PRELIMINARY!!!

Author:
Glen Daniels (gdaniels@macromedia.com)

Field Summary
 NSStack nsStack
           
 
Constructor Summary
SerializationContext(java.io.Writer writer)
           
SerializationContext(java.io.Writer writer, MessageContext msgContext)
           
 
Method Summary
 void endElement()
           
 void endPrefix(java.lang.String prefix)
           
 Message getCurrentMessage()
          Return the current message
 java.lang.String getPrefixForURI(java.lang.String uri)
          Get a prefix for a namespace URI.
 java.lang.String getPrefixForURI(java.lang.String uri, java.lang.String defaultPrefix)
          Get a prefix for the given namespace URI.
 boolean getPretty()
           
 QName getQNameForClass(java.lang.Class cls)
           
 TypeMappingRegistry getTypeMappingRegistry()
          Obtain a copy of the TypeMappingRegistry we're using
 boolean isPrimitive(java.lang.Object value)
          Classes which are known to not require multi-ref.
 void outputMultiRefs()
           
 java.lang.String qName2String(QName qName)
           
 void registerPrefixForURI(java.lang.String prefix, java.lang.String uri)
           
 void serialize(QName qName, org.xml.sax.Attributes attributes, java.lang.Object value)
           
 void setDoMultiRefs(boolean shouldDo)
          Set whether we are doing multirefs
 void setPretty(boolean pretty)
           
 void setSendDecl(boolean sendDecl)
          Set whether or not we should write XML declarations
 boolean shouldSendXSIType()
          Set whether or not to write xsi:type attributes
 void startElement(QName qName, org.xml.sax.Attributes attributes)
           
 void writeChars(char[] p1, int p2, int p3)
           
 void writeDOMElement(org.w3c.dom.Element el)
          Output a DOM representation to a SerializationContext
 void writeElement(QName qName, org.xml.sax.Attributes attributes)
          Convenience method for writing an element with no structure inside it.
 void writeSafeString(java.lang.String string)
           
 void writeString(java.lang.String string)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nsStack

public NSStack nsStack
Constructor Detail

SerializationContext

public SerializationContext(java.io.Writer writer)

SerializationContext

public SerializationContext(java.io.Writer writer,
                            MessageContext msgContext)
Method Detail

getPretty

public boolean getPretty()

setPretty

public void setPretty(boolean pretty)

setDoMultiRefs

public void setDoMultiRefs(boolean shouldDo)
Set whether we are doing multirefs

setSendDecl

public void setSendDecl(boolean sendDecl)
Set whether or not we should write XML declarations

shouldSendXSIType

public boolean shouldSendXSIType()
Set whether or not to write xsi:type attributes

getTypeMappingRegistry

public TypeMappingRegistry getTypeMappingRegistry()
Obtain a copy of the TypeMappingRegistry we're using

getPrefixForURI

public java.lang.String getPrefixForURI(java.lang.String uri)
Get a prefix for a namespace URI. This method will ALWAYS return a valid prefix - if the given URI is already mapped in this serialization, we return the previous prefix. If it is not mapped, we will add a new mapping and return a generated prefix of the form "ns".

getCurrentMessage

public Message getCurrentMessage()
Return the current message

getPrefixForURI

public java.lang.String getPrefixForURI(java.lang.String uri,
                                        java.lang.String defaultPrefix)
Get a prefix for the given namespace URI. If one has already been defined in this serialization, use that. Otherwise, map the passed default prefix to the URI, and return that. If a null default prefix is passed, use one of the form "ns"

registerPrefixForURI

public void registerPrefixForURI(java.lang.String prefix,
                                 java.lang.String uri)

endPrefix

public void endPrefix(java.lang.String prefix)

qName2String

public java.lang.String qName2String(QName qName)

getQNameForClass

public QName getQNameForClass(java.lang.Class cls)

isPrimitive

public boolean isPrimitive(java.lang.Object value)
Classes which are known to not require multi-ref. As multi-ref requires additional parsing overhead and not all implementations support this, only use this function when there is a possibility of circular references.

serialize

public void serialize(QName qName,
                      org.xml.sax.Attributes attributes,
                      java.lang.Object value)
               throws java.io.IOException

outputMultiRefs

public void outputMultiRefs()
                     throws java.io.IOException

startElement

public void startElement(QName qName,
                         org.xml.sax.Attributes attributes)
                  throws java.io.IOException

writeElement

public void writeElement(QName qName,
                         org.xml.sax.Attributes attributes)
                  throws java.io.IOException
Convenience method for writing an element with no structure inside it. (this could be optimzed later to share logic with startElement())
Parameters:
qName - the qualified name of the new element
attributes - any attributes which should be written on the element
Throws:
java.io.IOException - if there is any trouble

endElement

public void endElement()
                throws java.io.IOException

writeChars

public void writeChars(char[] p1,
                       int p2,
                       int p3)
                throws java.io.IOException

writeString

public void writeString(java.lang.String string)
                 throws java.io.IOException

writeSafeString

public void writeSafeString(java.lang.String string)
                     throws java.io.IOException

writeDOMElement

public void writeDOMElement(org.w3c.dom.Element el)
                     throws java.io.IOException
Output a DOM representation to a SerializationContext


Copyright © 2001 Apache XML Project. All Rights Reserved.