/**
   * Attempt to read load specifications from OS specific shortcut specification file. If fail to
   * read from OS specific shortcut specification file, attempt to load general shortcut
   * specification file.
   *
   * @throws Exception for any problems in reading the specification TODO: If internal flag mapped
   *     installData.isDebug() print out information on substitutedSpec
   */
  private IXMLElement readShortcutSpec() throws Exception {
    IXMLElement spec = null;

    InputStream shortcutSpec = null;
    try {
      shortcutSpec = resources.getInputStream(TargetFactory.getCurrentOSPrefix() + SPEC_FILE_NAME);
    } catch (ResourceNotFoundException resourceNotFound) {
      try {
        shortcutSpec = resources.getInputStream(SPEC_FILE_NAME);
      } catch (ResourceNotFoundException shortcutsNotFound) {
        // Fail on next try block
      }
    }

    try {
      VariableSubstitutor replacer = new VariableSubstitutorImpl(installData.getVariables());
      String substitutedSpec = replacer.substitute(shortcutSpec, SubstitutionType.TYPE_XML);
      IXMLParser parser = new XMLParser();
      spec = parser.parse(substitutedSpec);
    } catch (Exception e) {
      return null;
    }

    shortcutSpec.close();
    return spec;
  }
  private boolean readSpec() {
    InputStream input;
    try {
      input = ResourceManager.getInstance().getInputStream(SPEC_RESOURCE_NAME);
    } catch (Exception e) {
      e.printStackTrace();
      return false;
    }
    IXMLParser parser = new XMLParser();

    try {
      this.spec = parser.parse(input);
    } catch (Exception e) {
      System.out.println("Error parsing XML specification for compilation.");
      e.printStackTrace();
      return false;
    }

    if (!this.spec.hasChildren()) {
      return false;
    }

    this.compilerArgumentsList = new ArrayList<String>();
    this.compilerList = new ArrayList<String>();

    // read <global> information
    IXMLElement global = this.spec.getFirstChildNamed("global");

    // use some default values if no <global> section found
    if (global != null) {

      // get list of compilers
      this.compilerSpec = global.getFirstChildNamed("compiler");

      if (this.compilerSpec != null) {
        readChoices(this.compilerSpec, this.compilerList);
      }

      this.compilerArgumentsSpec = global.getFirstChildNamed("arguments");

      if (this.compilerArgumentsSpec != null) {
        // basicly perform sanity check
        readChoices(this.compilerArgumentsSpec, this.compilerArgumentsList);
      }
    }

    // supply default values if no useful ones where found
    if (this.compilerList.size() == 0) {
      this.compilerList.add("javac");
      this.compilerList.add("jikes");
    }

    if (this.compilerArgumentsList.size() == 0) {
      this.compilerArgumentsList.add("-O -g:none");
      this.compilerArgumentsList.add("-O");
      this.compilerArgumentsList.add("-g");
      this.compilerArgumentsList.add("");
    }

    return true;
  }