NASA World Wind

gov.nasa.worldwindx.examples.kml
Class KMZDocumentBuilder

java.lang.Object
  extended by gov.nasa.worldwindx.examples.kml.KMZDocumentBuilder

public class KMZDocumentBuilder
extends 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
protected  XMLStreamWriter writer
           
protected  ZipOutputStream zipStream
           
 
Constructor Summary
KMZDocumentBuilder(OutputStream stream)
          Create a KMZ document using an OutputStream.
 
Method Summary
 void close()
          Close the document builder.
protected  void endDocument()
          End the KMZ document.
protected  String getMainFileName()
          Get the name of the KML file inside of the KMZ archive.
protected  void startDocument()
          Start the KMZ document and write namespace declarations.
 void writeObject(Exportable exportable)
          Write an Exportable object to the document.
 void writeObjects(Exportable... exportables)
          Write a list of Exportable objects to the document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

writer

protected XMLStreamWriter writer

zipStream

protected ZipOutputStream zipStream
Constructor Detail

KMZDocumentBuilder

public KMZDocumentBuilder(OutputStream stream)
                   throws XMLStreamException,
                          IOException
Create a KMZ document using an OutputStream.

Parameters:
stream - Stream to receive KMZ output.
Throws:
XMLStreamException - If an exception is encountered while writing KML.
IOException - If an exception occurs writing to the output stream.
Method Detail

close

public void close()
           throws XMLStreamException,
                  IOException
Close the document builder.

Throws:
XMLStreamException - If an error is encountered while writing KML.
IOException - If an exception occurs closing the output stream.

endDocument

protected void endDocument()
                    throws XMLStreamException,
                           IOException
End the KMZ document.

Throws:
XMLStreamException - If an error is encountered while writing KML.
IOException - If an exception occurs writing to the output stream.

getMainFileName

protected 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 XMLStreamException,
                             IOException
Start the KMZ document and write namespace declarations.

Throws:
XMLStreamException - If an error is encountered while writing KML.
IOException - If an exception occurs writing to the output stream.

writeObject

public void writeObject(Exportable exportable)
                 throws 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:
IOException - If an error is encountered while writing KML.

writeObjects

public void writeObjects(Exportable... exportables)
                  throws 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:
IOException - If an error is encountered while writing KML.

NASA World Wind