org.idoox.xmlrpc.encoding
Interface EncodingTokenWriter


public interface EncodingTokenWriter

Marshalls the input EncodingTokens into a MessagePart object.

Since:
4.0
Component:
Core

Method Summary
 void flush()
          Flushes buffered data to the underlying message and forces this message to send itself.
 void init(Configurable config)
          initializes the encoding tokenizer
 void setEncoding(java.lang.String encodingURI)
          Serializer can set other encoding.
 void setMessage(Message messagePart)
          sets a message to which the data will be serialized
 void setPrefixForNamespace(java.lang.String prefix, java.lang.String namespaceURI)
          sets prefix for namespace.
 void setTokenWriter(TokenWriter writer)
          sets the output token writer
 void writeArrayEnd()
          writes end of an array
 void writeArrayStart(QName name, QName type, int[] dimensions, int[] arrayPos, java.lang.String id)
          writes start of a array
 void writeElement(org.w3c.dom.Element element)
          writes raw element.
 void writeNil(QName name, int[] arrayPos)
          writes nil value
 void writePrimitive(QName name, QName typeName, java.lang.String value, int[] arrayPos, java.lang.String id)
          writes a primitive type
 void writeQName(QName name, QName type, QName value, int[] arrayPos, java.lang.String id)
          writes a primitive qname type
 void writeReference(QName name, int[] arrayPos, java.lang.String idref)
          writes a reference to a part of the message
 void writeSoapReference(java.lang.String referenceNamespaceURI, java.lang.String referenceLocalName, QName name, int[] arrayPos, java.lang.String idref)
          writes required reference to a part of the message
 void writeStructureEnd()
          writes end of a structure
 void writeStructureStart(QName name, QName typeName, int[] arrayPos, java.lang.String id)
          writes start of a structure
 

Method Detail

setEncoding

public void setEncoding(java.lang.String encodingURI)
                 throws NoSuchEncodingException
Serializer can set other encoding. The first written entity will be encoded according to the new encoding.

Parameters:
encodingURI - identifies encoding
Throws:
NoSuchEncodingException - if there is no such encoding

setMessage

public void setMessage(Message messagePart)
                throws MessageCreatingException
sets a message to which the data will be serialized

Parameters:
messagePart - the message part
Throws:
MessageCreatingException - if the message can not be set

flush

public void flush()
           throws java.io.IOException
Flushes buffered data to the underlying message and forces this message to send itself.

Throws:
java.io.IOException - if there is an io exception

setTokenWriter

public void setTokenWriter(TokenWriter writer)
                    throws MessageCreatingException
sets the output token writer

Parameters:
writer - the writer to be written to
Throws:
MessageCreatingException - if the token writer could not be set

writePrimitive

public void writePrimitive(QName name,
                           QName typeName,
                           java.lang.String value,
                           int[] arrayPos,
                           java.lang.String id)
                    throws MessageCreatingException
writes a primitive type

Parameters:
name - the name under which the primitive is written
typeName - the type under which the primitive is written
value - the written value
arrayPos - position of this item in an array or null if not in array
id - if not null, the ID of the value (for use with references)
Throws:
MessageCreatingException - if there was error during writing

writeElement

public void writeElement(org.w3c.dom.Element element)
                  throws MessageCreatingException
writes raw element.

Throws:
MessageCreatingException

writeQName

public void writeQName(QName name,
                       QName type,
                       QName value,
                       int[] arrayPos,
                       java.lang.String id)
                throws MessageCreatingException
writes a primitive qname type

Parameters:
name - the name under which the primitive is written
type - the type under which the primitive is written
value - the written value, the appropriate ns prefix will be added automatically to the local part
arrayPos - position of this item in an array or null if not in array
id - if not null, the ID of the value (for use with references)
Throws:
MessageCreatingException - if there was error during writing

writeStructureStart

public void writeStructureStart(QName name,
                                QName typeName,
                                int[] arrayPos,
                                java.lang.String id)
                         throws MessageCreatingException
writes start of a structure

Parameters:
name - the name under which the structure is written
typeName - the type under which the structure is written
arrayPos - position of this item in an array or null if not in array
id - if not null, the ID of the value (for use with references)
Throws:
MessageCreatingException - if there was error during writing

writeStructureEnd

public void writeStructureEnd()
                       throws MessageCreatingException
writes end of a structure

Throws:
MessageCreatingException - if there was error during writing

writeArrayStart

public void writeArrayStart(QName name,
                            QName type,
                            int[] dimensions,
                            int[] arrayPos,
                            java.lang.String id)
                     throws MessageCreatingException
writes start of a array

Parameters:
name - the name under which the array is writter
type - the type under which the array is writter
dimensions - the dimensions of the array
arrayPos - position of this item in an array or null if not in array
id - if not null, the ID of the value (for use with references)
Throws:
MessageCreatingException - if there was error during writing

writeArrayEnd

public void writeArrayEnd()
                   throws MessageCreatingException
writes end of an array

Throws:
MessageCreatingException - if there was error during writing

writeReference

public void writeReference(QName name,
                           int[] arrayPos,
                           java.lang.String idref)
                    throws MessageCreatingException
writes a reference to a part of the message

Parameters:
name - the name under which the reference is writter
arrayPos - position of this item in an array or null if not in array
idref - the referenced ID
Throws:
MessageCreatingException - if there was error during writing

writeSoapReference

public void writeSoapReference(java.lang.String referenceNamespaceURI,
                               java.lang.String referenceLocalName,
                               QName name,
                               int[] arrayPos,
                               java.lang.String idref)
                        throws MessageCreatingException
writes required reference to a part of the message

Parameters:
referenceNamespaceURI - namespace URI of the reference attribute
referenceLocalName - localname of the reference attribute
name - the name under which the reference is writter
arrayPos - position of this item in an array or null if not in array
idref - the referenced ID
Throws:
MessageCreatingException - if there was error during writing

setPrefixForNamespace

public void setPrefixForNamespace(java.lang.String prefix,
                                  java.lang.String namespaceURI)
                           throws MessageCreatingException
sets prefix for namespace. This function is usable when serializing a lot of members in the same namespace or when you want an explicit prefix. In this case call this function directly after writeStructureStart or writeArrayStart.

Parameters:
prefix - the prefix being mapped
namespaceURI - the namespaceURI being mapped
Throws:
MessageCreatingException - when the prefix can not be mapped
    writeStructureStart();
    setPrefixForNamespace("x", "uri:a");
    writePrimitive({uri:a}b)
    writePrimitive({uri:a}c)
    writePrimitive({uri:a}f)
    writeStructureEnd()
 
is output as
   
     

   

writeNil

public void writeNil(QName name,
                     int[] arrayPos)
              throws MessageCreatingException
writes nil value

Parameters:
name - the name under which the nil is written
arrayPos - position of this item in an array or null if not in array
Throws:
MessageCreatingException - if there was error during writing

init

public void init(Configurable config)
initializes the encoding tokenizer

Parameters:
config - the configuration of the tokenizer