KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > celtix > bus > bindings > xml > XMLMessage


1 package org.objectweb.celtix.bus.bindings.xml;
2
3 import java.io.*;
4 import org.w3c.dom.*;
5
6 import org.objectweb.celtix.helpers.XMLUtils;
7
8 public class XMLMessage {
9
10     private Document root;
11     private XMLUtils xmlUtils = new XMLUtils();
12     private XMLFault xmlFault;
13
14     public XMLMessage() {
15         this.root = xmlUtils.newDocument();
16     }
17     
18     public void writeTo(OutputStream out) throws IOException {
19         xmlUtils.writeTo(this.root, out);
20     }
21
22     public Document getRoot() {
23         return this.root;
24     }
25
26     public void setRoot(Document r) {
27         this.root = r;
28     }
29
30     public void appendChild(Node child) {
31         if (root != null) {
32             root.appendChild(child);
33         }
34     }
35
36     public boolean hasChildNodes() {
37         return this.root.hasChildNodes();
38     }
39
40     public void removeContents() {
41         xmlUtils.removeContents(this.root);
42     }
43
44     public void setFault(XMLFault fault) {
45         this.xmlFault = fault;
46     }
47     
48     // Creates a new XMLFault object and adds it to this XML Message root object.
49
public XMLFault addFault() {
50         xmlFault = new XMLFault();
51         Node faultRoot = xmlUtils.createElementNS(this.root, XMLConstants.XML_FAULT_ROOT);
52         appendChild(faultRoot);
53         xmlFault.setFaultRoot(faultRoot);
54         return xmlFault;
55     }
56     
57     public XMLFault getFault() {
58         return this.xmlFault;
59     }
60
61     public boolean hasFault() {
62         return this.xmlFault != null;
63     }
64
65     public String JavaDoc toString() {
66         return xmlUtils.toString(this.root);
67     }
68 }
69
Popular Tags