Class KMLDocumentBuilder


  • public class KMLDocumentBuilder
    extends java.lang.Object
    Utility class to create KML documents.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected javax.xml.stream.XMLStreamWriter writer  
    • Constructor Summary

      Constructors 
      Constructor Description
      KMLDocumentBuilder​(java.io.OutputStream stream)
      Create a KML document using an OutputStream.
      KMLDocumentBuilder​(java.io.Writer writer)
      Create a KML document using a Writer.
    • Field Detail

      • writer

        protected javax.xml.stream.XMLStreamWriter writer
    • Constructor Detail

      • KMLDocumentBuilder

        public KMLDocumentBuilder​(java.io.Writer writer)
                           throws javax.xml.stream.XMLStreamException
        Create a KML document using a Writer.
        Parameters:
        writer - Writer to receive KML output.
        Throws:
        javax.xml.stream.XMLStreamException - If an error is encountered while writing KML.
      • KMLDocumentBuilder

        public KMLDocumentBuilder​(java.io.OutputStream stream)
                           throws javax.xml.stream.XMLStreamException
        Create a KML document using an OutputStream.
        Parameters:
        stream - Stream to receive KML output.
        Throws:
        javax.xml.stream.XMLStreamException - If an error is encountered while writing KML.
    • Method Detail

      • startDocument

        protected void startDocument()
                              throws javax.xml.stream.XMLStreamException
        Start the KML document and write namespace declarations.
        Throws:
        javax.xml.stream.XMLStreamException - If an error is encountered while writing KML.
      • endDocument

        protected void endDocument()
                            throws javax.xml.stream.XMLStreamException
        End the KML document.
        Throws:
        javax.xml.stream.XMLStreamException - If an error is encountered while writing KML.
      • close

        public void close()
                   throws javax.xml.stream.XMLStreamException
        Close the document builder.
        Throws:
        javax.xml.stream.XMLStreamException - If an error is encountered while writing KML.
      • writeObject

        public void writeObject​(Exportable exportable)
                         throws java.io.IOException
        Write an Exportable object to the document. If the object does not support export in KML format, it will be ignored.
        Parameters:
        exportable - Object to export in KML.
        Throws:
        java.io.IOException - If an error is encountered while writing KML.
      • writeObjects

        public void writeObjects​(Exportable... exportables)
                          throws java.io.IOException
        Write a list of Exportable objects to the document. If any objects do not support export in KML format, they will be ignored.
        Parameters:
        exportables - List of objects to export in KML.
        Throws:
        java.io.IOException - If an error is encountered while writing KML.