private void parseAndAdd(String line,BufferedReader reader) throws IOException {
  try {
    StringTokenizer tokenizer=new StringTokenizer(line," ");
    String tag=tokenizer.nextToken();
    if (tag.equals("CONTINUITY_WEIGHT")) {
      continuityWeight=Integer.parseInt(tokenizer.nextToken());
    }
 else     if (tag.equals("OPTIMAL_COUPLING")) {
      optimalCoupling=Integer.parseInt(tokenizer.nextToken());
    }
 else     if (tag.equals("EXTEND_SELECTIONS")) {
      extendSelections=Integer.parseInt(tokenizer.nextToken());
    }
 else     if (tag.equals("JOIN_METHOD")) {
      joinMethod=Integer.parseInt(tokenizer.nextToken());
    }
 else     if (tag.equals("JOIN_WEIGHTS")) {
      int numWeights=Integer.parseInt(tokenizer.nextToken());
      joinWeights=new int[numWeights];
      for (int i=0; i < numWeights; i++) {
        joinWeights[i]=Integer.parseInt(tokenizer.nextToken());
      }
      joinWeightShift=calcJoinWeightShift(joinWeights);
    }
 else     if (tag.equals("STS")) {
      String name=tokenizer.nextToken();
      if (name.equals("STS")) {
        sts=new SampleSet(tokenizer,reader);
      }
 else {
        mcep=new SampleSet(tokenizer,reader);
      }
    }
 else     if (tag.equals("UNITS")) {
      int type=Integer.parseInt(tokenizer.nextToken());
      int phone=Integer.parseInt(tokenizer.nextToken());
      int start=Integer.parseInt(tokenizer.nextToken());
      int end=Integer.parseInt(tokenizer.nextToken());
      int prev=Integer.parseInt(tokenizer.nextToken());
      int next=Integer.parseInt(tokenizer.nextToken());
      DatabaseClusterUnit unit=new DatabaseClusterUnit(type,phone,start,end,prev,next);
      unitList.add(unit);
    }
 else     if (tag.equals("CART")) {
      String name=tokenizer.nextToken();
      int nodes=Integer.parseInt(tokenizer.nextToken());
      CART cart=new CARTImpl(reader,nodes);
      cartMap.put(name,cart);
      if (defaultCart == null) {
        defaultCart=cart;
      }
    }
 else     if (tag.equals("UNIT_TYPE")) {
      String name=tokenizer.nextToken();
      int start=Integer.parseInt(tokenizer.nextToken());
      int count=Integer.parseInt(tokenizer.nextToken());
      UnitType unitType=new UnitType(name,start,count);
      unitTypesList.add(unitType);
    }
 else {
      throw new Error("Unsupported tag " + tag + " in db line `"+ line+ "'");
    }
  }
 catch (  NoSuchElementException nse) {
    throw new Error("Error parsing db " + nse.getMessage());
  }
catch (  NumberFormatException nfe) {
    throw new Error("Error parsing numbers in db line `" + line + "':"+ nfe.getMessage());
  }
}

private void parseAndAdd ( String line , BufferedReader reader ) throws IOException { try { StringTokenizer tokenizer = new StringTokenizer ( line , " " ) ; String tag = tokenizer . nextToken ( ) ; if ( tag . equals ( "CONTINUITY_WEIGHT" ) ) { continuityWeight = Integer . parseInt ( tokenizer . nextToken ( ) ) ; } else if ( tag . equals ( "OPTIMAL_COUPLING" ) ) { optimalCoupling = Integer . parseInt ( tokenizer . nextToken ( ) ) ; } else if ( tag . equals ( "EXTEND_SELECTIONS" ) ) { extendSelections = Integer . parseInt ( tokenizer . nextToken ( ) ) ; } else if ( tag . equals ( "JOIN_METHOD" ) ) { joinMethod = Integer . parseInt ( tokenizer . nextToken ( ) ) ; } else if ( tag . equals ( "JOIN_WEIGHTS" ) ) { int numWeights = Integer . parseInt ( tokenizer . nextToken ( ) ) ; joinWeights = new int [ numWeights ] ; for ( int i = 0 ; i < numWeights ; i ++ ) { joinWeights [ i ] = Integer . parseInt ( tokenizer . nextToken ( ) ) ; } joinWeightShift = calcJoinWeightShift ( joinWeights ) ; } else if ( tag . equals ( "STS" ) ) { String name = tokenizer . nextToken ( ) ; if ( name . equals ( "STS" ) ) { sts = new SampleSet ( tokenizer , reader ) ; } else { mcep = new SampleSet ( tokenizer , reader ) ; } } else if ( tag . equals ( "UNITS" ) ) { int type = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int phone = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int start = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int end = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int prev = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int next = Integer . parseInt ( tokenizer . nextToken ( ) ) ; DatabaseClusterUnit unit = new DatabaseClusterUnit ( type , phone , start , end , prev , next ) ; unitList . add ( unit ) ; } else if ( tag . equals ( "CART" ) ) { String name = tokenizer . nextToken ( ) ; int nodes = Integer . parseInt ( tokenizer . nextToken ( ) ) ; CART cart = new CARTImpl ( reader , nodes ) ; cartMap . put ( name , cart ) ; if ( defaultCart == null ) { defaultCart = cart ; } } else if ( tag . equals ( "UNIT_TYPE" ) ) { String name = tokenizer . nextToken ( ) ; int start = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int count = Integer . parseInt ( tokenizer . nextToken ( ) ) ; UnitType unitType = new UnitType ( name , start , count ) ; unitTypesList . add ( unitType ) ; } else { throw new Error ( "Unsupported tag " + tag + " in db line `" + line + "'" ) ; } } catch ( NoSuchElementException nse ) { throw new Error ( "Error parsing db " + nse . getMessage ( ) ) ; } catch ( NumberFormatException nfe ) { throw new Error ( "Error parsing numbers in db line `" + line + "':" + nfe . getMessage ( ) ) ; } }
parses and process the given line .
