Example #1
0
 /** Build a new Switch from a configuration file */
 public Switch(String name, File fich) {
   super();
   ports = new OurPort[MAX_PORT];
   LineNumberReader lnr;
   String line = "";
   list = new ArrayList(CAPACITY);
   if ((lnr = SyntaxAnalyz.find(fich, "switch", name)) != null) {
     try {
       this.name = name;
       for (line = lnr.readLine(); line != null && !line.startsWith("["); line = lnr.readLine()) {
         if (line.startsWith("admin-port:")) this.admin_port = SyntaxAnalyz.readAdminPort(line);
         else if (line.startsWith("priority:")) this.priority = SyntaxAnalyz.readPriority(line);
         else if (line.startsWith("MAC-address:")) this.mac_address = SyntaxAnalyz.readMac(line);
         else if (line.startsWith("port-")) addPorts(line);
       }
     } catch (IOException e) {
       System.err.println("probleme d'E/S dans la construnction du switch " + name);
     }
     runAdmin();
   } else
     System.err.println(
         "Switch <" + name + "> introuvable dans le fichier <" + fich.getAbsolutePath() + ">");
 }