Esempio n. 1
0
  /** @param configFile */
  public NameGenerator(String configFile) {

    // Load all configuration variables
    HashMap<String, String> vars = GenUtils.loadConfigFile(configFile);

    Set<String> keys = vars.keySet();
    Iterator it = keys.iterator();
    while (it.hasNext()) {
      String var = (String) it.next();

      // Assign values to configuration variables :
      if (var.equals("WORKSPACE")) { // $NON-NLS-1$
        workspace = vars.get(var);
      } else if (var.equals("ISO3166_1")) { // $NON-NLS-1$
        iso3166_1 = vars.get(var);
      } else if (var.equals("ISO3166_2")) { // $NON-NLS-1$
        iso3166_2 = vars.get(var);
      } else if (var.equals("ISO_FIX")) { // $NON-NLS-1$
        fixFile = vars.get(var);
      } else if (var.equals("TARGET_LIST")) { // $NON-NLS-1$
        targetFile = vars.get(var);
      } else if (var.equals("LEX_DIR")) { // $NON-NLS-1$
        lexDir = vars.get(var);
      } else if (var.equals("PROPERTIES_OUTPUT")) { // $NON-NLS-1$
        outputDir = vars.get(var);
      }
    } // while

    // The workspace variable should end with a slash character
    if (workspace.endsWith("\\") == false) { // $NON-NLS-1$
      workspace += "\\"; // $NON-NLS-1$
    }

    String path = workspace + GenConstants.PARAMS_DIR;

    // Set remaining config vars using WORKSPACE (workspace relative)
    if (iso3166_1 == null) {
      iso3166_1 = path + GenConstants.ISO3166_1_FILE;
    }
    if (iso3166_2 == null) {
      iso3166_2 = path + GenConstants.ISO3166_2_FILE;
    }
    if (fixFile == null) {
      fixFile = path + GenConstants.ISOFIX_FILE;
    }
    if (targetFile == null) {
      targetFile = path + GenConstants.COUNTRIES_LIST;
    }
    if (lexDir == null) {
      lexDir = path + GenConstants.LEX_DIR;
    }
    if (outputDir == null) {
      outputDir = workspace + GenConstants.PROPERTIES_OUTPUT_DIR;
    }

    targetList = null;
    // Set the URL IDs that are relevant for area data.
    initNameURLSet();
    // Set which URLs are active and which ones should be commented out.
    // setURLStatus();

  }