element.setAttribute(NAME_ATTR, data.getName());
if(element != null) { if(data != null && data.getName() != null) { element.setAttribute(NAME_ATTR, data.getName()); } else { element.setAttribute(NAME_ATTR, ""); } }
  private void addChildToDocument(Document doc, ComponentData data, Element parent) {    Element element = null;    if(data.getType().equals(ComponentData.HOST)) {      element = doc.createElement(HOST_NODE);    } else if(data.getType().equals(ComponentData.NODE)) {      element = doc.createElement(NODE_NODE);    } else if(data.getType().equals(ComponentData.AGENT)) {      element = doc.createElement(AGENT_NODE);    }    element.setAttribute(NAME_ATTR, data.getName());    // For now, don't walk below Agent.  This will    // need to change when we implement ability to    // Generate a complete XML file from ComponentData.    if(!data.getType().equals(ComponentData.AGENT)) {      ComponentData[] children = data.getChildren();      for(int i=0; i < children.length; i++) {        addChildToDocument(doc, children[i], element);      }    }    parent.appendChild(element);  }