1 10 package org.mmbase.applications.editwizard; 11 12 import org.w3c.dom.*; 13 import java.util.Date ; 14 15 22 23 public class ConnectorCommand { 24 private String id; 25 private String name; 26 private Document xml; 27 private Document responsexml; 28 29 32 public ConnectorCommand(String aname) throws WizardException { 33 name = aname; 34 id = new Date ().getTime()+""; 35 xml = Utils.parseXML("<"+name+" id=\"" + id + "\"/>"); 36 responsexml = Utils.parseXML("<response/>"); 37 } 38 39 42 public void addCommandNode(Node node) { 43 Node newnode = xml.getDocumentElement().appendChild(xml.importNode(node.cloneNode(true), true)); 44 } 45 46 49 public void addCommandAttr(String name, String value) { 50 Utils.setAttribute(xml.getDocumentElement(), name, value); 51 } 52 53 56 public Document getCommandXML() { 57 return xml; 58 } 59 60 63 public Document getResponseXML() { 64 return responsexml; 65 } 66 67 70 public String getName() { 71 return name; 72 } 73 74 77 public String getId() { 78 return id; 79 } 80 81 84 public void setResponse(Node responsenode) { 85 responsexml = Utils.emptyDocument(); 86 responsexml.appendChild(responsexml.importNode(responsenode.cloneNode(true), true)); 87 } 88 89 92 public boolean hasError() { 93 return (responsexml==null) || 94 (Utils.selectSingleNode(responsexml, "/*/error")!=null); 95 } 96 97 100 public String getError() { 101 return Utils.selectSingleNodeText(responsexml, "/*/error",null); 102 } 103 104 } 105 | Popular Tags |