package org.mbari.vdm.knowledgebase;


//~--- non-JDK imports --------------------------------------------------------

import java.util.MissingResourceException;
import java.util.ResourceBundle;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.mbari.vars.annotation.model.VideoArchiveSet;


/**
* Acquires the deployment location (Shore, Point Lobos, Western Flyer) from a
* properties file, vars.propertes. Attempts to set certain behaviors base on
* location. These behaviors include:
* <ul>
* <li>Initializing the VCR on COM1 and calling the play method so that it
* acquires the time-code when on the ships.</li>
* </ul>
*
* @author brian
*
*/
public class LocaleFactory {

  //~--- static fields ------------------------------------------------------

  private static final Log log = LogFactory.getLog(LocaleFactory.class);

  private static String cameraPlatform;

  private static boolean isInitialized;

  private static String locale;

  //~--- constructors -------------------------------------------------------

  /**
   *
   */
  private LocaleFactory() {
      super();
      // No external instantiation allowed
  }

  //~--- get methods --------------------------------------------------------

  /**
   *
   * @return The name of the camera platform that VARS is configured for. This
   *         is configured by in the vars.properties file. The platforms are
   *         "Ventana" and "Tiburon"
   */
  public static String getCameraPlatform() {
      initialize();

      return cameraPlatform;
  }

  /**
   *
   * @return The location that vars is installed at. This is configured in the
   *         vars.properties file. This is "Shore", "Western Flyer", "Point
   *         Lobos". If none was specified in the vars.properties file then this
   *         returns null.
   */
  public static String getLocale() {
      initialize();

      return locale;
  }

  //~--- methods ------------------------------------------------------------

  /**
   * <p><!-- Method description --></p>
   *
   */
  private static void initialize() {
      if (!isInitialized) {
          if (locale == null) {
              ResourceBundle bundle = ResourceBundle.getBundle("vars");

              try {
                  locale = bundle.getString("deployment.locale");
              } catch (MissingResourceException e) {
                  log.info(
                      "The property 'deployment.locale' was not found in vars.properties");
              }

              if (locale != null) {
                  final String s = locale.toLowerCase();
              }
          }

          isInitialized = true;
      }
  }

}
