Class MXSerializer

java.lang.Object
org.xmlpull.renamed.MXSerializer
All Implemented Interfaces:
org.xmlpull.v1.XmlSerializer
Direct Known Subclasses:
ExtMXSerializer

public class MXSerializer extends Object implements org.xmlpull.v1.XmlSerializer
Implementation of XmlSerializer interface from XmlPull V1 API. This implementation is optimized 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
  • Field Details

    • XML_URI

      protected static final String XML_URI
      See Also:
    • XMLNS_URI

      protected static final String XMLNS_URI
      See Also:
    • FEATURE_SERIALIZER_ATTVALUE_USE_APOSTROPHE

      protected final String FEATURE_SERIALIZER_ATTVALUE_USE_APOSTROPHE
      See Also:
    • FEATURE_NAMES_INTERNED

      protected final String FEATURE_NAMES_INTERNED
      See Also:
    • PROPERTY_SERIALIZER_INDENTATION

      protected final String PROPERTY_SERIALIZER_INDENTATION
      See Also:
    • PROPERTY_SERIALIZER_LINE_SEPARATOR

      protected final String PROPERTY_SERIALIZER_LINE_SEPARATOR
      See Also:
    • PROPERTY_LOCATION

      protected static final String PROPERTY_LOCATION
      See Also:
    • namesInterned

      protected boolean namesInterned
    • attributeUseApostrophe

      protected boolean attributeUseApostrophe
    • indentationString

      protected String indentationString
    • lineSeparator

      protected String lineSeparator
    • location

      protected String location
    • out

      protected Writer out
    • autoDeclaredPrefixes

      protected int autoDeclaredPrefixes
    • depth

      protected int depth
    • elNamespace

      protected String[] elNamespace
    • elName

      protected String[] elName
    • elPrefix

      protected String[] elPrefix
    • elNamespaceCount

      protected int[] elNamespaceCount
    • namespaceEnd

      protected int namespaceEnd
    • namespacePrefix

      protected String[] namespacePrefix
    • namespaceUri

      protected String[] namespaceUri
    • finished

      protected boolean finished
    • pastRoot

      protected boolean pastRoot
    • setPrefixCalled

      protected boolean setPrefixCalled
    • startTagIncomplete

      protected boolean startTagIncomplete
    • doIndent

      protected boolean doIndent
    • seenTag

      protected boolean seenTag
    • seenBracket

      protected boolean seenBracket
    • seenBracketBracket

      protected boolean seenBracketBracket
    • buf

      protected char[] buf
    • precomputedPrefixes

      protected static final String[] precomputedPrefixes
    • offsetNewLine

      protected int offsetNewLine
    • indentationJump

      protected int indentationJump
    • indentationBuf

      protected char[] indentationBuf
    • maxIndentLevel

      protected int maxIndentLevel
    • writeLineSepartor

      protected boolean writeLineSepartor
    • writeIndentation

      protected boolean writeIndentation
  • Constructor Details

    • MXSerializer

      public MXSerializer()
  • Method Details

    • reset

      protected void reset()
    • ensureElementsCapacity

      protected void ensureElementsCapacity()
    • ensureNamespacesCapacity

      protected void ensureNamespacesCapacity()
    • setFeature

      public void setFeature(String name, boolean state) throws IllegalArgumentException, IllegalStateException
      Specified by:
      setFeature in interface org.xmlpull.v1.XmlSerializer
      Throws:
      IllegalArgumentException
      IllegalStateException
    • getFeature

      public boolean getFeature(String name) throws IllegalArgumentException
      Specified by:
      getFeature in interface org.xmlpull.v1.XmlSerializer
      Throws:
      IllegalArgumentException
    • rebuildIndentationBuf

      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.
    • writeIndent

      protected void writeIndent() throws IOException
      Throws:
      IOException
    • setProperty

      public void setProperty(String name, Object value) throws IllegalArgumentException, IllegalStateException
      Specified by:
      setProperty in interface org.xmlpull.v1.XmlSerializer
      Throws:
      IllegalArgumentException
      IllegalStateException
    • getProperty

      public Object getProperty(String name) throws IllegalArgumentException
      Specified by:
      getProperty in interface org.xmlpull.v1.XmlSerializer
      Throws:
      IllegalArgumentException
    • getWriter

      public Writer getWriter()
    • setOutput

      public void setOutput(Writer writer)
      Specified by:
      setOutput in interface org.xmlpull.v1.XmlSerializer
    • setOutput

      public void setOutput(OutputStream os, String encoding) throws IOException
      Specified by:
      setOutput in interface org.xmlpull.v1.XmlSerializer
      Throws:
      IOException
    • startDocument

      public void startDocument(String encoding, Boolean standalone) throws IOException
      Specified by:
      startDocument in interface org.xmlpull.v1.XmlSerializer
      Throws:
      IOException
    • endDocument

      public void endDocument() throws IOException
      Specified by:
      endDocument in interface org.xmlpull.v1.XmlSerializer
      Throws:
      IOException
    • setPrefix

      public void setPrefix(String prefix, String namespace) throws IOException
      Specified by:
      setPrefix in interface org.xmlpull.v1.XmlSerializer
      Throws:
      IOException
    • lookupOrDeclarePrefix

      protected String lookupOrDeclarePrefix(String namespace)
    • getPrefix

      public String getPrefix(String namespace, boolean generatePrefix)
      Specified by:
      getPrefix in interface org.xmlpull.v1.XmlSerializer
    • getPrefix

      protected String getPrefix(String namespace, boolean generatePrefix, boolean nonEmpty)
    • getDepth

      public int getDepth()
      Specified by:
      getDepth in interface org.xmlpull.v1.XmlSerializer
    • getNamespace

      public String getNamespace()
      Specified by:
      getNamespace in interface org.xmlpull.v1.XmlSerializer
    • getName

      public String getName()
      Specified by:
      getName in interface org.xmlpull.v1.XmlSerializer
    • startTag

      public org.xmlpull.v1.XmlSerializer startTag(String namespace, String name) throws IOException
      Specified by:
      startTag in interface org.xmlpull.v1.XmlSerializer
      Throws:
      IOException
    • attribute

      public org.xmlpull.v1.XmlSerializer attribute(String namespace, String name, String value) throws IOException
      Specified by:
      attribute in interface org.xmlpull.v1.XmlSerializer
      Throws:
      IOException
    • closeStartTag

      protected void closeStartTag() throws IOException
      Throws:
      IOException
    • writeNamespaceDeclarations

      protected void writeNamespaceDeclarations() throws IOException
      Throws:
      IOException
    • endTag

      public org.xmlpull.v1.XmlSerializer endTag(String namespace, String name) throws IOException
      Specified by:
      endTag in interface org.xmlpull.v1.XmlSerializer
      Throws:
      IOException
    • text

      public org.xmlpull.v1.XmlSerializer text(String text) throws IOException
      Specified by:
      text in interface org.xmlpull.v1.XmlSerializer
      Throws:
      IOException
    • text

      public org.xmlpull.v1.XmlSerializer text(char[] buf, int start, int len) throws IOException
      Specified by:
      text in interface org.xmlpull.v1.XmlSerializer
      Throws:
      IOException
    • cdsect

      public void cdsect(String text) throws IOException
      Specified by:
      cdsect in interface org.xmlpull.v1.XmlSerializer
      Throws:
      IOException
    • entityRef

      public void entityRef(String text) throws IOException
      Specified by:
      entityRef in interface org.xmlpull.v1.XmlSerializer
      Throws:
      IOException
    • processingInstruction

      public void processingInstruction(String text) throws IOException
      Specified by:
      processingInstruction in interface org.xmlpull.v1.XmlSerializer
      Throws:
      IOException
    • comment

      public void comment(String text) throws IOException
      Specified by:
      comment in interface org.xmlpull.v1.XmlSerializer
      Throws:
      IOException
    • docdecl

      public void docdecl(String text) throws IOException
      Specified by:
      docdecl in interface org.xmlpull.v1.XmlSerializer
      Throws:
      IOException
    • ignorableWhitespace

      public void ignorableWhitespace(String text) throws IOException
      Specified by:
      ignorableWhitespace in interface org.xmlpull.v1.XmlSerializer
      Throws:
      IOException
    • flush

      public void flush() throws IOException
      Specified by:
      flush in interface org.xmlpull.v1.XmlSerializer
      Throws:
      IOException
    • writeAttributeValue

      protected void writeAttributeValue(String value, Writer out) throws IOException
      Throws:
      IOException
    • writeElementContent

      protected void writeElementContent(String text, Writer out) throws IOException
      Throws:
      IOException
    • writeElementContent

      protected void writeElementContent(char[] buf, int off, int len, Writer out) throws IOException
      Throws:
      IOException
    • printable

      protected static String printable(String s)
    • printable

      protected static String printable(char ch)