<commit_before>package mil.emp3.api.utils.kmz;

import java.io.File;
import mil.emp3.api.interfaces.IEmpExportToTypeCallBack;
import mil.emp3.api.interfaces.IFeature;
import mil.emp3.api.interfaces.IMap;
import mil.emp3.api.interfaces.IOverlay;

/**
 * Exports Map, Overlay, or Feature to a KMZ file.
 * @author <NAME>
 */

public final class EmpKMZExporter
{
    private static final String KMZExportDirectory = "KMZExport";

    /**
     * Private to prevent from calling this class
     * in a non-static fashion
     */
    private EmpKMZExporter()
    {

    }

    /**
     * This exports the map's overlays, and features displayed on the map
     * to a KMZ file given the directory where the KMZ file should be stored as
     * well as the desired name of the KMZ file.
     * @param map the map that contains the overlays and feature data to be exported.
     * @param extendedData whether or not extended data should be exported.
     * @param callback the callback which will provide the KMZ file created when the thread is finished or report a failure
     * @param temporaryDirectoryLocation the temporary directory location( it is highly recommended to use
     *                                   Context.getExternalFilesDir() as the temporary location).
     *                                   The contents of this directory will be removed after export.
     * @param kmzFileName  the name of the exported KMZ File Name (i.e. kmz_file_export.kmz or kmz_file_export).
     */
    public static void exportToKMZ(final IMap                           map,
                                   final boolean                        extendedData,
                                   final IEmpExportToTypeCallBack<File> callback,
                                   final String                         temporaryDirectoryLocation,
                                   final String                         kmzFileName)
    {

        if ((null == map)                        ||
            (null == temporaryDirectoryLocation) ||
            (null == callback)                   ||
            (null == kmzFileName))
        {
            throw new IllegalArgumentException("Parameters can't be null.");
        }

        if(temporaryDirectoryLocation.isEmpty())
        {
            throw new IllegalArgumentException("The temporaryDirectoryLocation cannot be an empty string.");
        }

        if(kmzFileName.isEmpty())
        {
            throw new IllegalArgumentException("The kmzFileName cannot be an empty string.");
        }

        KMZExportThread kmzExportThread = new KMZExportThread(map,
                                                              extendedData,
                                                              callback,
                                                              temporaryDirectoryLocation,
                                                              kmzFileName);
        kmzExportThread.run();
        kmzExportThread.start();
    }

    /**
     * This exports the overlay specified that is displayed on the map
     * to a KMZ file given the directory where the KMZ file should be stored as
     * well as the desired name of the KMZ file.
     * @param map the map that contains the overlay to be exported.
     * @param overlay the overlay to be exported.
     * @param extendedData whether or not extended data should be exported
     * @param callback the callback which will provide the KMZ file created when the thread is finished or report a failure
     * @param temporaryDirectoryLocation the temporary directory location( it is highly recommended to use
     *                                   Context.getExternalFilesDir() as the temporary location).
     *                                   The contents of this directory will be removed after export.
     * @param kmzFileName the name of the exported KMZ File Name (i.e. kmz_file_export.kmz or kmz_file_export).
     */
    public static void exportToKMZ(final IMap                           map,
                                   final IOverlay                       overlay,
                                   final boolean                        extendedData,
                                   final IEmpExportToTypeCallBack<File> callback,
                                   final String                         temporaryDirectoryLocation,
                                   final String                         kmzFileName)
    {


        if ((null == map)                        ||
            (null == overlay)                    ||
            (null == temporaryDirectoryLocation) ||
            (null == callback)                   ||
            (null == kmzFileName))
        {
            throw new IllegalArgumentException("Parameters can't be null.");
        }

        if(temporaryDirectoryLocation.isEmpty())
        {
            throw new IllegalArgumentException("The temporaryDirectoryLocation cannot be an empty string.");
        }

        if(kmzFileName.isEmpty())
        {
            throw new IllegalArgumentException("The kmzFileName cannot be an empty string.");
        }
   
        KMZExportThread kmzExportThread = new KMZExportThread(map,
                                                              overlay,
                                                              extendedData,
                                                              callback,
                                                              temporaryDirectoryLocation,
                                                              kmzFileName);
        kmzExportThread.run();
        kmzExportThread.start();
    }

    /**
     * This exports the feature specified that is displayed on the map
     * to a KMZ file given the directory where the KMZ file should be stored as
     * well as the desired name of the KMZ file.
     * @param map the map that contains the overlay to be exported.
     * @param feature the feature to be exported.
     * @param extendedData whether or not extended data should be exported
     * @param callback the callback which will provide the KMZ file created when the thread is finished or report a failure
     * @param temporaryDirectoryLocation the temporary directory location( it is highly recommended to use
     *                                   Context.getExternalFilesDir() as the temporary location).
     *                                   The contents of this directory will be removed after export.
     * @param kmzFileName the name of the exported KMZ File Name (i.e. kmz_file_export.kmz or kmz_file_export).
     */
    public static void exportToKMZ(final IMap                           map,
                                   final IFeature                       feature,
                                   final boolean                        extendedData,
                                   final IEmpExportToTypeCallBack<File> callback,
                                   final String                         temporaryDirectoryLocation,
                                   final String                         kmzFileName)
    {

        if ((null == map)                        ||
            (null == feature)                    ||
            (null == temporaryDirectoryLocation) ||
            (null == callback)                   ||
            (null == kmzFileName))
        {
            throw new IllegalArgumentException("Parameters can't be null.");
        }

        if(temporaryDirectoryLocation.isEmpty())
        {
            throw new IllegalArgumentException("The temporaryDirectoryLocation cannot be an empty string.");
        }

        if(kmzFileName.isEmpty())
        {
            throw new IllegalArgumentException("The kmzFileName cannot be an empty string.");
        }

        KMZExportThread kmzExportThread = new KMZExportThread(map,
                                                              feature,
                                                              extendedData,
                                                              callback,
                                                              temporaryDirectoryLocation,
                                                              kmzFileName);
        kmzExportThread.run();
        kmzExportThread.start();
    }
}<commit_msg>#243 fixing the threading issue<commit_after>package mil.emp3.api.utils.kmz;

import java.io.File;
import mil.emp3.api.interfaces.IEmpExportToTypeCallBack;
import mil.emp3.api.interfaces.IFeature;
import mil.emp3.api.interfaces.IMap;
import mil.emp3.api.interfaces.IOverlay;

/**
 * Exports Map, Overlay, or Feature to a KMZ file.
 * @author <NAME>
 */

public final class EmpKMZExporter
{
    private static final String KMZExportDirectory = "KMZExport";

    /**
     * Private to prevent from calling this class
     * in a non-static fashion
     */
    private EmpKMZExporter()
    {

    }

    /**
     * This exports the map's overlays, and features displayed on the map
     * to a KMZ file given the directory where the KMZ file should be stored as
     * well as the desired name of the KMZ file.
     * @param map the map that contains the overlays and feature data to be exported.
     * @param extendedData whether or not extended data should be exported.
     * @param callback the callback which will provide the KMZ file created when the thread is finished or report a failure
     * @param temporaryDirectoryLocation the temporary directory location( it is highly recommended to use
     *                                   Context.getExternalFilesDir() as the temporary location).
     *                                   The contents of this directory will be removed after export.
     * @param kmzFileName  the name of the exported KMZ File Name (i.e. kmz_file_export.kmz or kmz_file_export).
     */
    public static void exportToKMZ(final IMap                           map,
                                   final boolean                        extendedData,
                                   final IEmpExportToTypeCallBack<File> callback,
                                   final String                         temporaryDirectoryLocation,
                                   final String                         kmzFileName)
    {

        if ((null == map)                        ||
            (null == temporaryDirectoryLocation) ||
            (null == callback)                   ||
            (null == kmzFileName))
        {
            throw new IllegalArgumentException("Parameters can't be null.");
        }

        if(temporaryDirectoryLocation.isEmpty())
        {
            throw new IllegalArgumentException("The temporaryDirectoryLocation cannot be an empty string.");
        }

        if(kmzFileName.isEmpty())
        {
            throw new IllegalArgumentException("The kmzFileName cannot be an empty string.");
        }

        KMZExportThread kmzExportThread = new KMZExportThread(map,
                                                              extendedData,
                                                              callback,
                                                              temporaryDirectoryLocation,
                                                              kmzFileName);
        kmzExportThread.run();
    }

    /**
     * This exports the overlay specified that is displayed on the map
     * to a KMZ file given the directory where the KMZ file should be stored as
     * well as the desired name of the KMZ file.
     * @param map the map that contains the overlay to be exported.
     * @param overlay the overlay to be exported.
     * @param extendedData whether or not extended data should be exported
     * @param callback the callback which will provide the KMZ file created when the thread is finished or report a failure
     * @param temporaryDirectoryLocation the temporary directory location( it is highly recommended to use
     *                                   Context.getExternalFilesDir() as the temporary location).
     *                                   The contents of this directory will be removed after export.
     * @param kmzFileName the name of the exported KMZ File Name (i.e. kmz_file_export.kmz or kmz_file_export).
     */
    public static void exportToKMZ(final IMap                           map,
                                   final IOverlay                       overlay,
                                   final boolean                        extendedData,
                                   final IEmpExportToTypeCallBack<File> callback,
                                   final String                         temporaryDirectoryLocation,
                                   final String                         kmzFileName)
    {


        if ((null == map)                        ||
            (null == overlay)                    ||
            (null == temporaryDirectoryLocation) ||
            (null == callback)                   ||
            (null == kmzFileName))
        {
            throw new IllegalArgumentException("Parameters can't be null.");
        }

        if(temporaryDirectoryLocation.isEmpty())
        {
            throw new IllegalArgumentException("The temporaryDirectoryLocation cannot be an empty string.");
        }

        if(kmzFileName.isEmpty())
        {
            throw new IllegalArgumentException("The kmzFileName cannot be an empty string.");
        }
   
        KMZExportThread kmzExportThread = new KMZExportThread(map,
                                                              overlay,
                                                              extendedData,
                                                              callback,
                                                              temporaryDirectoryLocation,
                                                              kmzFileName);
        kmzExportThread.run();
    }

    /**
     * This exports the feature specified that is displayed on the map
     * to a KMZ file given the directory where the KMZ file should be stored as
     * well as the desired name of the KMZ file.
     * @param map the map that contains the overlay to be exported.
     * @param feature the feature to be exported.
     * @param extendedData whether or not extended data should be exported
     * @param callback the callback which will provide the KMZ file created when the thread is finished or report a failure
     * @param temporaryDirectoryLocation the temporary directory location( it is highly recommended to use
     *                                   Context.getExternalFilesDir() as the temporary location).
     *                                   The contents of this directory will be removed after export.
     * @param kmzFileName the name of the exported KMZ File Name (i.e. kmz_file_export.kmz or kmz_file_export).
     */
    public static void exportToKMZ(final IMap                           map,
                                   final IFeature                       feature,
                                   final boolean                        extendedData,
                                   final IEmpExportToTypeCallBack<File> callback,
                                   final String                         temporaryDirectoryLocation,
                                   final String                         kmzFileName)
    {

        if ((null == map)                        ||
            (null == feature)                    ||
            (null == temporaryDirectoryLocation) ||
            (null == callback)                   ||
            (null == kmzFileName))
        {
            throw new IllegalArgumentException("Parameters can't be null.");
        }

        if(temporaryDirectoryLocation.isEmpty())
        {
            throw new IllegalArgumentException("The temporaryDirectoryLocation cannot be an empty string.");
        }

        if(kmzFileName.isEmpty())
        {
            throw new IllegalArgumentException("The kmzFileName cannot be an empty string.");
        }

        KMZExportThread kmzExportThread = new KMZExportThread(map,
                                                              feature,
                                                              extendedData,
                                                              callback,
                                                              temporaryDirectoryLocation,
                                                              kmzFileName);
        kmzExportThread.run();
    }
}
{'fraction_non_alphanumeric': 0.05318956689356063, 'fraction_numerical': 0.0007830853563038371, 'mean_word_length': 1.2671036460467022, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 112, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5936980', 'n_tokens_mistral': 3424, 'n_tokens_neox': 3248, 'n_words': 1243}