KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > applications > editwizard > ConnectorCommand


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

10 package org.mmbase.applications.editwizard;
11
12 import org.w3c.dom.*;
13 import java.util.Date JavaDoc;
14
15 /**
16  * EditWizard
17  * @javadoc
18  * @author Kars Veling
19  * @since MMBase-1.6
20  * @version $Id: ConnectorCommand.java,v 1.6 2002/10/25 12:57:24 pierre Exp $
21  */

22
23 public class ConnectorCommand {
24     private String JavaDoc id;
25     private String JavaDoc name;
26     private Document xml;
27     private Document responsexml;
28
29     /**
30      * @javadoc
31      */

32     public ConnectorCommand(String JavaDoc aname) throws WizardException {
33         name = aname;
34         id = new Date JavaDoc().getTime()+"";
35         xml = Utils.parseXML("<"+name+" id=\"" + id + "\"/>");
36         responsexml = Utils.parseXML("<response/>");
37     }
38
39     /**
40      * @javadoc
41      */

42     public void addCommandNode(Node node) {
43         Node newnode = xml.getDocumentElement().appendChild(xml.importNode(node.cloneNode(true), true));
44     }
45
46     /**
47      * @javadoc
48      */

49     public void addCommandAttr(String JavaDoc name, String JavaDoc value) {
50         Utils.setAttribute(xml.getDocumentElement(), name, value);
51     }
52
53     /**
54      * @javadoc
55      */

56     public Document getCommandXML() {
57         return xml;
58     }
59
60     /**
61      * @javadoc
62      */

63     public Document getResponseXML() {
64         return responsexml;
65     }
66
67     /**
68      * @javadoc
69      */

70     public String JavaDoc getName() {
71         return name;
72     }
73
74     /**
75      * @javadoc
76      */

77     public String JavaDoc getId() {
78         return id;
79     }
80
81     /**
82      * @javadoc
83      */

84     public void setResponse(Node responsenode) {
85         responsexml = Utils.emptyDocument();
86         responsexml.appendChild(responsexml.importNode(responsenode.cloneNode(true), true));
87     }
88
89     /**
90      * @javadoc
91      */

92     public boolean hasError() {
93         return (responsexml==null) ||
94                 (Utils.selectSingleNode(responsexml, "/*/error")!=null);
95     }
96
97     /**
98      * @javadoc
99      */

100     public String JavaDoc getError() {
101         return Utils.selectSingleNodeText(responsexml, "/*/error",null);
102     }
103
104 }
105
Popular Tags