Mercurial > repos > ganjoo > webservice_toolsuite
comparison WebServiceToolWorkflow/lib/SAWADLParser/src/javax/wadls/WADLSException.java @ 0:d5cd409b8a18 default tip
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
| author | ganjoo |
|---|---|
| date | Tue, 07 Jun 2011 18:00:50 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:d5cd409b8a18 |
|---|---|
| 1 /* | |
| 2 * (c) Copyright IBM Corp 2001, 2005 | |
| 3 */ | |
| 4 | |
| 5 package javax.wadls; | |
| 6 | |
| 7 import java.io.*; | |
| 8 | |
| 9 /** | |
| 10 * This class represents a WADLS Exception | |
| 11 * @author Zixin Wu | |
| 12 * | |
| 13 */ | |
| 14 public class WADLSException extends Exception | |
| 15 { | |
| 16 public static final long serialVersionUID = 1; | |
| 17 | |
| 18 public static final String INVALID_WADL = "INVALID_WADL"; | |
| 19 public static final String XSDPARSER_ERROR = "XSDPARSER_ERROR"; | |
| 20 public static final String OTHER_ERROR = "OTHER_ERROR"; | |
| 21 public static final String CONFIGURATION_ERROR = "CONFIGURATION_ERROR"; | |
| 22 public static final String UNBOUND_PREFIX = "UNBOUND_PREFIX"; | |
| 23 public static final String NO_PREFIX_SPECIFIED = "NO_PREFIX_SPECIFIED"; | |
| 24 public static final String PATH_ERROR = "PATH_ERROR"; | |
| 25 public static final String NOT_FOUND_ELE_BY_PATH = "NOT_FOUND_ELE_BY_PATH"; | |
| 26 public static final String NOT_FOUND_SCHEMA = "NOT_FOUND_SCHEMA"; | |
| 27 public static final String NOT_FOUND_ELE_IN_PART = "NOT_FOUND_ELE_IN_PART"; | |
| 28 | |
| 29 private String faultCode = null; | |
| 30 private Throwable targetThrowable = null; | |
| 31 private String location = null; | |
| 32 | |
| 33 public WADLSException(String faultCode, String msg, Throwable t) | |
| 34 { | |
| 35 super(msg); | |
| 36 setFaultCode(faultCode); | |
| 37 setTargetException(t); | |
| 38 } | |
| 39 | |
| 40 public WADLSException(String faultCode, String msg) | |
| 41 { | |
| 42 this(faultCode, msg, null); | |
| 43 } | |
| 44 | |
| 45 public void setFaultCode(String faultCode) | |
| 46 { | |
| 47 this.faultCode = faultCode; | |
| 48 } | |
| 49 | |
| 50 public String getFaultCode() | |
| 51 { | |
| 52 return faultCode; | |
| 53 } | |
| 54 | |
| 55 public void setTargetException(Throwable targetThrowable) | |
| 56 { | |
| 57 this.targetThrowable = targetThrowable; | |
| 58 } | |
| 59 | |
| 60 public Throwable getTargetException() | |
| 61 { | |
| 62 return targetThrowable; | |
| 63 } | |
| 64 | |
| 65 /** | |
| 66 * Set the location using an XPath expression. Used for error messages. | |
| 67 * | |
| 68 * @param location an XPath expression describing the location where | |
| 69 * the exception occurred. | |
| 70 */ | |
| 71 public void setLocation(String location) | |
| 72 { | |
| 73 this.location = location; | |
| 74 } | |
| 75 | |
| 76 /** | |
| 77 * Get the location, if one was set. Should be an XPath expression which | |
| 78 * is used for error messages. | |
| 79 */ | |
| 80 public String getLocation() | |
| 81 { | |
| 82 return location; | |
| 83 } | |
| 84 | |
| 85 public String getMessage() | |
| 86 { | |
| 87 StringBuffer strBuf = new StringBuffer(); | |
| 88 | |
| 89 strBuf.append("WADLSException"); | |
| 90 | |
| 91 if (location != null) | |
| 92 { | |
| 93 try | |
| 94 { | |
| 95 strBuf.append(" (at " + location + ")"); | |
| 96 } | |
| 97 catch (IllegalArgumentException e) | |
| 98 { | |
| 99 } | |
| 100 } | |
| 101 | |
| 102 if (faultCode != null) | |
| 103 { | |
| 104 strBuf.append(": faultCode=" + faultCode); | |
| 105 } | |
| 106 | |
| 107 String thisMsg = super.getMessage(); | |
| 108 String targetMsg = (targetThrowable != null) | |
| 109 ? targetThrowable.getMessage() | |
| 110 : null; | |
| 111 | |
| 112 if (thisMsg != null | |
| 113 && (targetMsg == null || !thisMsg.equals(targetMsg))) | |
| 114 { | |
| 115 strBuf.append(": " + thisMsg); | |
| 116 } | |
| 117 | |
| 118 if (targetMsg != null) | |
| 119 { | |
| 120 strBuf.append(": " + targetMsg); | |
| 121 } | |
| 122 | |
| 123 return strBuf.toString(); | |
| 124 } | |
| 125 | |
| 126 public String toString() | |
| 127 { | |
| 128 StringWriter sw = new StringWriter(); | |
| 129 PrintWriter pw = new PrintWriter(sw); | |
| 130 | |
| 131 pw.print(getMessage() + ": "); | |
| 132 | |
| 133 if (targetThrowable != null) | |
| 134 { | |
| 135 targetThrowable.printStackTrace(pw); | |
| 136 } | |
| 137 | |
| 138 return sw.toString(); | |
| 139 } | |
| 140 } |
