1 package org.objectweb.celtix.bus.bindings.xml; 2 3 import org.w3c.dom.*; 4 import org.objectweb.celtix.helpers.XMLUtils; 5 6 public class XMLFault { 7 8 private Node faultRoot; 9 10 private String faultString; 12 private Node faultDetail; 13 private Node detailRoot; 14 15 private XMLUtils xmlUtils = new XMLUtils(); 16 17 23 27 public void setFaultString(String str) { 28 this.faultString = str; 29 } 30 31 public void addFaultString(String str) { 32 assert faultRoot != null; 33 34 Text text = xmlUtils.createTextNode(this.faultRoot, str); 35 Node faultStringNode = xmlUtils.createElementNS(this.faultRoot, XMLConstants.XML_FAULT_STRING); 36 faultStringNode.appendChild(text); 37 this.faultRoot.appendChild(faultStringNode); 38 39 this.faultString = str; 40 } 41 42 public void setFaultDetail(Node detail) { 43 this.detailRoot = detail; 44 45 NodeList list = detail.getChildNodes(); 46 for (int i = 0; i < list.getLength(); i++) { 47 Node entry = list.item(i); 48 if (entry.getNodeType() != Node.ELEMENT_NODE) { 49 continue; 50 } 51 this.faultDetail = detail; 52 } 53 } 54 55 public void appendFaultDetail(Node detail) { 56 assert faultRoot != null; 57 assert detailRoot != null; 58 59 this.detailRoot.appendChild(detail); 60 this.faultDetail = detail; 61 } 62 63 public Node addFaultDetail() { 64 assert faultRoot != null; 65 66 this.detailRoot = xmlUtils.createElementNS(this.faultRoot, XMLConstants.XML_FAULT_DETAIL); 67 this.faultRoot.appendChild(this.detailRoot); 68 return this.detailRoot; 69 } 70 71 public String getFaultString() { 72 return this.faultString; 73 } 74 75 public Node getFaultDetail() { 76 return this.faultDetail; 77 } 78 79 public Node getFaultDetailRoot() { 80 return this.detailRoot; 81 } 82 83 public Node getFaultRoot() { 84 return this.faultRoot; 85 } 86 87 protected void setFaultRoot(Node root) { 88 this.faultRoot = root; 89 } 90 91 public void removeChild(Node node) { 92 this.faultRoot.removeChild(node); 93 } 94 95 public boolean hasChildNodes() { 96 return this.faultRoot.hasChildNodes(); 97 } 98 } 99 | Popular Tags |