Class KMLFile

  • All Implemented Interfaces:
    KMLDoc

    public class KMLFile
    extends java.lang.Object
    implements KMLDoc
    Implements the KMLDoc interface for KML files located within a computer's file system.

    Note: This class does not resolve references to files in KMZ archives. For example, it does not resolve references like this: ../other.kmz/file.png.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.io.File kmlFile
      The File reference specified to the constructor.
    • Constructor Summary

      Constructors 
      Constructor Description
      KMLFile​(java.io.File file)
      Construct a KMLFile instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.io.InputStream getKMLStream()
      Returns an InputStream to the KML file.
      java.lang.String getSupportFilePath​(java.lang.String path)
      Returns an absolute path or URL to a file indicated by a path relative to the KML file's location.
      java.io.InputStream getSupportFileStream​(java.lang.String path)
      Returns an InputStream to a file indicated by a path relative to the KML file's location.
      java.io.File getZipFile()
      Returns the File specified to the constructor.
      • Methods inherited from class java.lang.Object

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

      • kmlFile

        protected java.io.File kmlFile
        The File reference specified to the constructor.
    • Constructor Detail

      • KMLFile

        public KMLFile​(java.io.File file)
        Construct a KMLFile instance.
        Parameters:
        file - path to the KML file.
        Throws:
        java.lang.IllegalArgumentException - if the specified file is null.
    • Method Detail

      • getZipFile

        public java.io.File getZipFile()
        Returns the File specified to the constructor.
        Returns:
        the file specified to the constructor.
      • getKMLStream

        public java.io.InputStream getKMLStream()
                                         throws java.io.IOException
        Returns an InputStream to the KML file.
        Specified by:
        getKMLStream in interface KMLDoc
        Returns:
        an input stream positioned to the start of the KML file.
        Throws:
        java.io.IOException - if an error occurs attempting to create the input stream.
      • getSupportFileStream

        public java.io.InputStream getSupportFileStream​(java.lang.String path)
                                                 throws java.io.IOException
        Returns an InputStream to a file indicated by a path relative to the KML file's location.
        Specified by:
        getSupportFileStream in interface KMLDoc
        Parameters:
        path - the path of the requested file.
        Returns:
        an input stream positioned to the start of the file, or null if the file does not exist.
        Throws:
        java.io.IOException - if an error occurs while attempting to query or open the file.
      • getSupportFilePath

        public java.lang.String getSupportFilePath​(java.lang.String path)
        Description copied from interface: KMLDoc
        Returns an absolute path or URL to a file indicated by a path relative to the KML file's location.
        Specified by:
        getSupportFilePath in interface KMLDoc
        Parameters:
        path - the path of the requested file.
        Returns:
        an absolute path or URL to the file, or null if the file does not exist.