Class XmlWriter


  • public class XmlWriter
    extends java.lang.Object
    Correctly formats Strings in XML syntax. Currently only supports ISO-8859-1 encoding of XML.
    • Constructor Summary

      Constructors 
      Constructor Description
      XmlWriter()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void chardata​(java.lang.String text)
      Formats cdata for XML
      void endElement​(java.lang.String elem)
      Formats a closing XML tag
      byte[] getBytes()
      Gets this writer's contents as a byte array (already appends a \n)
      void reset()
      Resets this XmlWriter so it can be used again
      void startElement​(java.lang.String elem)
      Formats an opening XML tag
      java.lang.String toString()
      Gets this writer's contents as string (already appends a \n).
      void write​(java.lang.String text)
      Write the given text.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • XmlWriter

        public XmlWriter()
    • Method Detail

      • reset

        public void reset()
        Resets this XmlWriter so it can be used again
      • write

        public void write​(java.lang.String text)
        Write the given text.
      • toString

        public java.lang.String toString()
        Gets this writer's contents as string (already appends a \n). Consider using getBytes() instead of this one.
        Overrides:
        toString in class java.lang.Object
        Returns:
        All that was written to the internal buffer
        See Also:
        getBytes()
      • getBytes

        public byte[] getBytes()
        Gets this writer's contents as a byte array (already appends a \n)
        Returns:
        All that was written to the internal buffer
        Since:
        TotalCross 1.23
      • startElement

        public void startElement​(java.lang.String elem)
        Formats an opening XML tag
        Parameters:
        elem - The element of the opening tag
      • endElement

        public void endElement​(java.lang.String elem)
        Formats a closing XML tag
        Parameters:
        elem - The element of the closing tag
      • chardata

        public void chardata​(java.lang.String text)
        Formats cdata for XML
        Parameters:
        text - The character data to be formatted