Exemple #1
0
  public void parseLine(Model automodel, String line) {
    String[] splitLine = line.split(",");
    trimWhiteSpaceInArray(splitLine);

    try {

      if (splitLine[0].compareToIgnoreCase("model") == 0) {
        automodel.setModelName(splitLine[1]);
      } else if (splitLine[0].compareToIgnoreCase("model price") == 0) {
        automodel.setModelPrice(Double.parseDouble(splitLine[1]));
      } else if (splitLine[0].compareToIgnoreCase("optionsets") == 0
          || splitLine[0].compareToIgnoreCase("option sets") == 0) {
        try {
          automodel.initOptionSets(Integer.parseInt(splitLine[1]));
        } catch (Exception e) { // number not there or not an integer
          automodel.initOptionSets(DEFAULT_GROUP_SZ);
          System.out.println("Error with count of Option sets" + e.getMessage());
        }
      } else if (splitLine[0].compareToIgnoreCase("optionset") == 0) {
        try {
          automodel.addOptionSet(splitLine[1], Integer.parseInt(splitLine[2]));
        } catch (Exception e) { // number not there or not an integer
          automodel.addOptionSet(splitLine[1], DEFAULT_GROUP_SZ);
          System.out.println("Error with count of options" + e.getMessage());
        }
      } else if (splitLine[0].compareToIgnoreCase("option") == 0) {
        automodel.addOptionToLastSet(splitLine[1], Double.parseDouble(splitLine[2]));
      }
    } catch (Exception e) {
      System.out.println("Error parsing Model file." + e.getMessage());
    }
  }