1 14 15 package mx4j.tools.adaptor.http; 16 17 18 import java.io.IOException ; 19 import javax.xml.parsers.DocumentBuilder ; 20 import javax.xml.parsers.DocumentBuilderFactory ; 21 import javax.xml.parsers.ParserConfigurationException ; 22 23 import org.w3c.dom.Document ; 24 import org.w3c.dom.Element ; 25 26 27 32 33 public class HttpException extends IOException 34 35 { 36 37 40 41 protected int code; 42 43 44 50 51 public HttpException(int code, String description) 52 53 { 54 55 super(description); 56 57 this.code = code; 58 59 } 60 61 62 65 66 public int getCode() 67 68 { 69 70 return code; 71 72 } 73 74 75 public Document getResponseDoc() 76 { 77 78 try 79 80 { 81 82 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 83 84 DocumentBuilder builder = factory.newDocumentBuilder(); 85 86 Document document = builder.newDocument(); 87 88 89 Element root = document.createElement("HttpException"); 90 91 root.setAttribute("code", Integer.toString(code)); 92 93 root.setAttribute("description", getMessage()); 94 95 document.appendChild(root); 96 97 return document; 98 99 } 100 101 catch (ParserConfigurationException e) 102 103 { 104 105 return null; 106 107 } 108 109 } 110 111 } 112 113 | Popular Tags |