Class KMZDocumentBuilder


  • public class KMZDocumentBuilder
    extends java.lang.Object
    Utility class to create KMZ documents. The builder creates a KMZ archive with one KML file inside the archive. Objects that support export in KML format can be written to the KML file.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected javax.xml.stream.XMLStreamWriter writer  
      protected java.util.zip.ZipOutputStream zipStream  
    • Constructor Summary

      Constructors 
      Constructor Description
      KMZDocumentBuilder​(java.io.OutputStream stream)
      Create a KMZ document using an OutputStream.
    • Field Detail

      • zipStream

        protected java.util.zip.ZipOutputStream zipStream
      • writer

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

      • KMZDocumentBuilder

        public KMZDocumentBuilder​(java.io.OutputStream stream)
                           throws javax.xml.stream.XMLStreamException,
                                  java.io.IOException
        Create a KMZ document using an OutputStream.
        Parameters:
        stream - Stream to receive KMZ output.
        Throws:
        javax.xml.stream.XMLStreamException - If an exception is encountered while writing KML.
        java.io.IOException - If an exception occurs writing to the output stream.
    • Method Detail

      • getMainFileName

        protected java.lang.String getMainFileName()
        Get the name of the KML file inside of the KMZ archive.
        Returns:
        The name of the KML file inside of the KMZ.
      • startDocument

        protected void startDocument()
                              throws javax.xml.stream.XMLStreamException,
                                     java.io.IOException
        Start the KMZ document and write namespace declarations.
        Throws:
        javax.xml.stream.XMLStreamException - If an error is encountered while writing KML.
        java.io.IOException - If an exception occurs writing to the output stream.
      • endDocument

        protected void endDocument()
                            throws javax.xml.stream.XMLStreamException,
                                   java.io.IOException
        End the KMZ document.
        Throws:
        javax.xml.stream.XMLStreamException - If an error is encountered while writing KML.
        java.io.IOException - If an exception occurs writing to the output stream.
      • close

        public void close()
                   throws javax.xml.stream.XMLStreamException,
                          java.io.IOException
        Close the document builder.
        Throws:
        javax.xml.stream.XMLStreamException - If an error is encountered while writing KML.
        java.io.IOException - If an exception occurs closing the output stream.
      • 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.