Пример #1
0
  public Vector<GarminLayer> parseLayers() {
    Vector<GarminLayer> layers = new Vector<GarminLayer>();
    String line = null;
    GarminLayer l = null;
    int lineNumber = 0;
    try {
      while ((line = input.readLine()) != null) {
        lineNumber++;
        // remove comments
        int i;
        if ((i = line.indexOf('#')) != -1) line = line.substring(0, i);

        // remove whitespaces
        line = line.trim();

        // continue if it was an empty line or comment
        if (line.equals("")) continue;

        String[] kv = new String[2];
        // read key word and value
        kv = line.split("\\s", 2);
        if (kv[1] == null) {
          System.err.println("Error in Line:" + lineNumber);
          continue;
        }

        String key = kv[0];
        String value = kv[1].trim();

        if (kv[0].equals("Layer") && value.matches("\\w*")) {
          l = new GarminLayer(value);
          layers.add(l);
          continue;
        }

        if (l != null) {
          if (!l.setValue(key, value)) {
            System.err.println("Key-Value-Pair in Index File sucks. Line number:" + lineNumber);
          }
        } else {
          System.err.println("Found text without Layer context. Line number:" + lineNumber);
        }
      }
    } catch (IOException e) {
      System.err.println("Error while parsing layers Index File");
    }
    return layers;
  }
Пример #2
0
 public static GarminLayer makeDummy() {
   GarminLayer l = new GarminLayer("<none>");
   l.setValue("Description", "Show nothing on the map");
   return l;
 }