예제 #1
0
  public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
      throws SAXException {

    try {

      if (qName.equals("species")) {
        params.setParam("Species", atts.getValue("name"));
      } else if (qName.equals("param")) {

        params.setParam(atts.getValue("name"), atts.getValue("value"));
      }
    } catch (ParamError e) {
      errors += e.getMessage() + "\n";
      // throw new SAXException(e.getMessage());
    }
  }
예제 #2
0
  public Params(Params other) {

    // copy values from other
    debug = other.debug;
    verbose = other.verbose;
    ignoreVParams = other.ignoreVParams;
    stopLevel = other.stopLevel;
    Species = other.Species;
    WoodType = other.WoodType;
    Seed = other.Seed;
    Smooth = other.Smooth;

    // create paramDB
    paramDB = new Hashtable();
    levelParams = new LevelParams[4];
    for (int l = 0; l < 4; l++) {
      levelParams[l] = new LevelParams(l, paramDB);
    }
    registerParams();

    // copy param values
    for (Enumeration e = paramDB.elements(); e.hasMoreElements(); ) {
      AbstractParam p = ((AbstractParam) e.nextElement());
      try {
        AbstractParam otherParam = other.getParam(p.name);
        if (!otherParam.empty()) {
          p.setValue(otherParam.getValue());
        } // else use default value
      } catch (ParamError err) {
        System.err.println("Error copying params: " + err.getMessage());
      }
    }
  }
예제 #3
0
 public void parse(LineNumberReader r, Params params) throws Exception {
   String line = r.readLine().trim();
   String param;
   String value;
   while (line != null) {
     if (line != "" && line.charAt(0) != '#') {
       int equ = line.indexOf('=');
       param = line.substring(0, equ).trim();
       value = line.substring(equ + 1).trim();
       if (param.equals("species")) {
         params.setParam("Species", value);
       } else {
         params.setParam(param, value);
       }
       line = r.readLine();
     }
   }
 }