if(ComponentDescription.parsePriority(children[i].getPriority()) != ComponentDescription.PRIORITY_COMPONENT) { writer.print("(" + children[i].getPriority() + ")"); } writer.print(" = ");
  private void writeNodeFile(File configDir, ComponentData nc) throws IOException {    if (nc.childCount() == 0) {      // node has no agents or binders. skip it      return;    }    Object[] parameters = nc.getParameters();    String configFileName = nc.getName() + ".ini";    if (parameters.length > 0)      configFileName = (String)parameters[0];    if (! configFileName.endsWith(".ini"))      configFileName = configFileName + ".ini";    PrintWriter writer =       new PrintWriter(new FileWriter(new File(configDir, configFileName)));       try {      // loop over children      // if there are binder or such, do those      ComponentData[] children = nc.getChildren();      for (int i = 0; i < nc.childCount(); i++) {        if (children[i] instanceof AgentComponentData) {          continue;        } else if (children[i].getType().equals(ComponentData.NODE) ||                    children[i].getType().equals(ComponentData.SOCIETY) ||                    children[i].getType().equals(ComponentData.AGENT)) {          if(log.isErrorEnabled()) {            log.error("Got unexpected child of Node type: " + children[i].getType());          }        } else {          if(log.isDebugEnabled()) {            log.debug("writeNodeFile: [ "+configFileName+                      " ] Type is: " + children[i].getType());          }          // What is the prefix line I write here?          if (children[i].getType().equals(ComponentData.NODEBINDER)) {            writer.print("Node.AgentManager.Binder = ");	  } else if (children[i].getType().equals(ComponentData.AGENTBINDER)) {	    writer.print("Node.AgentManager.Agent.PluginManager.Binder = ");	  } else {	    if (log.isDebugEnabled()) {	      log.debug("writeNodeFile writing component of type: " + children[i].getType() + ", and name " + children[i].getName());	    }	    writer.print(children[i].getType() + " = ");            // This assumes the type is always the prefix.          }          writeChildLine(writer, children[i]);          // Could one of these guys have children?          writeChildrenOfComp(writer, configDir, children[i]);          // write out any leaf components          writeLeafData(configDir, children[i]);        }      } // end of loop over children      writer.println("[ Clusters ]");      children = nc.getChildren();      // Get the name if the initializer plugin.      for(int i=0; i < nc.childCount(); i++) {        if(children[i] instanceof AgentComponentData) {          AgentComponentData agent = (AgentComponentData)children[i];          ComponentData[] plugins = agent.getChildren();          for(int j=0; j < plugins.length; j++) {            ComponentData aa = plugins[j];            if(aa.getName().equals("org.cougaar.tools.csmart.runtime.plugin.MetricsInitializerPlugin")) {              metricsInitializer = agent.getName().toString();              break;            }          }        }      }      for (int i = 0; i < nc.childCount(); i++) {        if (children[i] instanceof AgentComponentData) {          writer.print("cluster = ");          writeChildLine(writer, children[i]);          // Write the children of this agent if there are any          // write the leaf components of this agent          writeAgentFile(configDir, (AgentComponentData)children[i]);        } else if (children[i].getType().equals(ComponentData.NODEBINDER)) {        } else {          //  	} else if (!children[i].getType().equals(ComponentData.NODEBINDER)           //                     || !children[i].getType().equals(ComponentData.AGENTBINDER)) {          if(log.isInfoEnabled()) {            log.info("Got a child of a Node that wasn't an Agent or Node Binder Type: "                      + children[i].getType());          }        }      }      writer.println();      writer.println("[ AlpProcess ]");      writer.println();      writer.println("[ Policies ]");      writer.println();      writer.println("[ Permission ]");      writer.println();      writer.println("[ AuthorizedOperation ]");    } catch (Exception e) {      if(log.isErrorEnabled()) {        log.error("Error writing config file: ", e);      }    }    finally {      writer.close();    }      } // end of writeNodeFile