Class StateElementWriter

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private org.w3c.dom.Document document  
      private org.w3c.dom.Element element  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      (package private) StateElementWriter​(java.lang.String rootName)
      Create a writer with a new XML document.
      (package private) StateElementWriter​(org.w3c.dom.Document document)
      Create a writer with an existing XML document.
      private StateElementWriter​(org.w3c.dom.Document document, org.w3c.dom.Element element)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      IWritableState createChild​(java.lang.String type)
      Creates a new child node.
      void putString​(java.lang.String key, java.lang.String value)
      Stores a named attribute value.
      java.lang.String toString()
      Get the XML document as a string.
      void write​(java.io.Writer writer)
      Print the XML document to a writer.
      • Methods inherited from class java.lang.Object

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

      • document

        private final org.w3c.dom.Document document
      • element

        private final org.w3c.dom.Element element
    • Constructor Detail

      • StateElementWriter

        StateElementWriter​(java.lang.String rootName)
                    throws java.io.IOException
        Create a writer with a new XML document.
        Parameters:
        rootName - the name of the XML root element
        Throws:
        java.io.IOException - if there is a problem creating the XML document
      • StateElementWriter

        StateElementWriter​(org.w3c.dom.Document document)
        Create a writer with an existing XML document.
        Parameters:
        document - XML document to write to
      • StateElementWriter

        private StateElementWriter​(org.w3c.dom.Document document,
                                   org.w3c.dom.Element element)
    • Method Detail

      • createChild

        public IWritableState createChild​(java.lang.String type)
        Description copied from interface: IWritableState
        Creates a new child node. Multiple nodes of the same type are permitted.
        Specified by:
        createChild in interface IWritableState
        Parameters:
        type - node type
        Returns:
        a new child node
      • putString

        public void putString​(java.lang.String key,
                              java.lang.String value)
        Description copied from interface: IWritableState
        Stores a named attribute value. Multiple values with the same key is not supported. If called multiple times with the same key then only the latest value should be kept.
        Specified by:
        putString in interface IWritableState
        Parameters:
        key - attribute key
        value - attribute value
      • write

        public void write​(java.io.Writer writer)
        Print the XML document to a writer.
        Parameters:
        writer - writer to print the XML document to
      • toString

        public java.lang.String toString()
        Get the XML document as a string.
        Overrides:
        toString in class java.lang.Object
        Returns:
        the XML document as a string