1 20 21 package org.jivesoftware.smack.packet; 22 23 50 public class XMPPError { 51 52 private int code; 53 private String message; 54 55 60 public XMPPError(int code) { 61 this.code = code; 62 this.message = null; 63 } 64 65 71 public XMPPError(int code, String message) { 72 this.code = code; 73 this.message = message; 74 } 75 76 81 public int getCode() { 82 return code; 83 } 84 85 90 public String getMessage() { 91 return message; 92 } 93 94 99 public String toXML() { 100 StringBuffer buf = new StringBuffer (); 101 buf.append("<error code=\"").append(code).append("\">"); 102 if (message != null) { 103 buf.append(message); 104 } 105 buf.append("</error>"); 106 return buf.toString(); 107 } 108 109 public String toString() { 110 StringBuffer txt = new StringBuffer (); 111 txt.append("(").append(code).append(")"); 112 if (message != null) { 113 txt.append(" ").append(message); 114 } 115 return txt.toString(); 116 } 117 } 118 | Popular Tags |