public class

MXSerializer

extends Object
java.lang.Object
   ↳ com.sforce.ws.parser.MXSerializer

Class Overview

Implementation of XmlSerializer interface from XmlPull V1 API. This implementation is optimzied for performance and low memory footprint.

Implemented features:

  • FEATURE_NAMES_INTERNED - when enabled all returned names (namespaces, prefixes) will be interned and it is required that all names passed as arguments MUST be interned
  • FEATURE_SERIALIZER_ATTVALUE_USE_APOSTROPHE

Implemented properties:

  • PROPERTY_SERIALIZER_INDENTATION
  • PROPERTY_SERIALIZER_LINE_SEPARATOR

Summary

Constants
String PROPERTY_LOCATION
boolean TRACE_ESCAPING
boolean TRACE_SIZING
String XMLNS_URI
String XML_URI
Fields
private static final int BUF_LEN
protected final String FEATURE_NAMES_INTERNED
protected final String FEATURE_SERIALIZER_ATTVALUE_USE_APOSTROPHE
protected final String PROPERTY_SERIALIZER_INDENTATION
protected final String PROPERTY_SERIALIZER_LINE_SEPARATOR
protected boolean attributeUseApostrophe
protected int autoDeclaredPrefixes
protected char[] buf
private boolean checkNamesInterned
protected int depth
protected boolean doIndent
protected String[] elName
protected String[] elNamespace
protected int[] elNamespaceCount
protected boolean finished
protected char[] indentationBuf
protected int indentationJump
protected String indentationString
protected String lineSeparator
protected String location
protected int maxIndentLevel
protected boolean namesInterned
protected int namespaceEnd
protected String[] namespacePrefix
protected String[] namespaceUri
protected int offsetNewLine
protected Writer out
protected boolean pastRoot
protected static final String[] precomputedPrefixes
protected boolean seenBracket
protected boolean seenBracketBracket
protected boolean seenTag
protected boolean setPrefixCalled
protected boolean startTagIncomplete
protected boolean writeIndentation
protected boolean writeLineSepartor
Public Constructors
MXSerializer()
Public Methods
MXSerializer attribute(String namespace, String name, String value)
void cdsect(String text)
void comment(String text)
void docdecl(String text)
void endDocument()
MXSerializer endTag(String namespace, String name)
void entityRef(String text)
void flush()
int getDepth()
boolean getFeature(String name)
String getName()
String getNamespace()
String getPrefix(String namespace, boolean generatePrefix)
Object getProperty(String name)
Writer getWriter()
void ignorableWhitespace(String text)
void processingInstruction(String text)
void setFeature(String name, boolean state)
void setOutput(Writer writer)
void setOutput(OutputStream os, String encoding)
void setPrefix(String prefix, String namespace)
void setProperty(String name, Object value)
void startDocument(String encoding, Boolean standalone)
MXSerializer startTag(String namespace, String name)
MXSerializer text(char[] buf, int start, int len)
MXSerializer text(String text)
Protected Methods
void closeStartTag()
void ensureElementsCapacity()
void ensureNamespacesCapacity()
String lookupOrDeclarePrefix(String namespace)
static String printable(char ch)
static String printable(String s)
simple utility method -- good for debugging
void rebuildIndentationBuf()
For maximum efficiency when writing indents the required output is pre-computed This is internal function that recomputes buffer after user requested chnages.
void reset()
void writeAttributeValue(String value, Writer out)
void writeElementContent(String text, Writer out)
void writeElementContent(char[] buf, int off, int len, Writer out)
void writeIndent()
[Expand]
Inherited Methods
From class java.lang.Object

Constants

protected static final String PROPERTY_LOCATION

Constant Value: "http://xmlpull.org/v1/doc/properties.html#location"

private static final boolean TRACE_ESCAPING

Constant Value: false

private static final boolean TRACE_SIZING

Constant Value: false

protected static final String XMLNS_URI

Constant Value: "http://www.w3.org/2000/xmlns/"

protected static final String XML_URI

Constant Value: "http://www.w3.org/XML/1998/namespace"

Fields

private static final int BUF_LEN

protected final String FEATURE_NAMES_INTERNED

Constant Value: "http://xmlpull.org/v1/doc/features.html#names-interned"

protected final String FEATURE_SERIALIZER_ATTVALUE_USE_APOSTROPHE

Constant Value: "http://xmlpull.org/v1/doc/features.html#serializer-attvalue-use-apostrophe"

protected final String PROPERTY_SERIALIZER_INDENTATION

Constant Value: "http://xmlpull.org/v1/doc/properties.html#serializer-indentation"

protected final String PROPERTY_SERIALIZER_LINE_SEPARATOR

Constant Value: "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator"

protected boolean attributeUseApostrophe

protected int autoDeclaredPrefixes

protected char[] buf

private boolean checkNamesInterned

protected int depth

protected boolean doIndent

protected String[] elName

protected String[] elNamespace

protected int[] elNamespaceCount

protected boolean finished

protected char[] indentationBuf

protected int indentationJump

protected String indentationString

protected String lineSeparator

protected String location

protected int maxIndentLevel

protected boolean namesInterned

protected int namespaceEnd

protected String[] namespacePrefix

protected String[] namespaceUri

protected int offsetNewLine

protected Writer out

protected boolean pastRoot

protected static final String[] precomputedPrefixes

protected boolean seenBracket

protected boolean seenBracketBracket

protected boolean seenTag

protected boolean setPrefixCalled

protected boolean startTagIncomplete

protected boolean writeIndentation

protected boolean writeLineSepartor

Public Constructors

public MXSerializer ()

Public Methods

public MXSerializer attribute (String namespace, String name, String value)

Parameters
namespace
name
value
Throws
IOException

public void cdsect (String text)

Parameters
text
Throws
IOException

public void comment (String text)

Parameters
text
Throws
IOException

public void docdecl (String text)

Parameters
text
Throws
IOException

public void endDocument ()

Throws
IOException

public MXSerializer endTag (String namespace, String name)

Parameters
namespace
name
Throws
IOException

public void entityRef (String text)

Parameters
text
Throws
IOException

public void flush ()

Throws
IOException

public int getDepth ()

public boolean getFeature (String name)

Parameters
name
Throws
IllegalArgumentException

public String getName ()

public String getNamespace ()

public String getPrefix (String namespace, boolean generatePrefix)

Parameters
namespace
generatePrefix

public Object getProperty (String name)

Parameters
name
Throws
IllegalArgumentException

public Writer getWriter ()

public void ignorableWhitespace (String text)

Parameters
text
Throws
IOException

public void processingInstruction (String text)

Parameters
text
Throws
IOException

public void setFeature (String name, boolean state)

Parameters
name
state
Throws
IllegalArgumentException
IllegalStateException

public void setOutput (Writer writer)

Parameters
writer

public void setOutput (OutputStream os, String encoding)

Parameters
os
encoding
Throws
IOException

public void setPrefix (String prefix, String namespace)

Parameters
prefix
namespace
Throws
IOException

public void setProperty (String name, Object value)

Parameters
name
value
Throws
IllegalArgumentException
IllegalStateException

public void startDocument (String encoding, Boolean standalone)

Parameters
encoding
standalone
Throws
IOException

public MXSerializer startTag (String namespace, String name)

Parameters
namespace
name
Throws
IOException

public MXSerializer text (char[] buf, int start, int len)

Parameters
buf
start
len
Throws
IOException

public MXSerializer text (String text)

Parameters
text
Throws
IOException

Protected Methods

protected void closeStartTag ()

Throws
IOException

protected void ensureElementsCapacity ()

protected void ensureNamespacesCapacity ()

protected String lookupOrDeclarePrefix (String namespace)

Parameters
namespace

protected static String printable (char ch)

Parameters
ch

protected static String printable (String s)

simple utility method -- good for debugging

Parameters
s

protected void rebuildIndentationBuf ()

For maximum efficiency when writing indents the required output is pre-computed This is internal function that recomputes buffer after user requested chnages.

protected void reset ()

protected void writeAttributeValue (String value, Writer out)

Parameters
value
out
Throws
IOException

protected void writeElementContent (String text, Writer out)

Parameters
text
out
Throws
IOException

protected void writeElementContent (char[] buf, int off, int len, Writer out)

Parameters
buf
off
len
out
Throws
IOException

protected void writeIndent ()

Throws
IOException