1 17 package org.eclipse.emf.ecore.xmi; 18 19 20 import java.io.PrintStream ; 21 import java.io.PrintWriter ; 22 23 import org.eclipse.emf.ecore.resource.Resource; 24 25 26 public class XMIException extends Exception implements Resource.Diagnostic 27 { 28 protected String location; 29 protected int line; 30 protected int column; 31 protected Exception exception; 32 33 public XMIException(String message) 34 { 35 super(message); 36 } 37 38 public XMIException(Exception exception) 39 { 40 super(exception.getMessage()); 41 this.exception = exception; 42 } 43 44 public XMIException(String message, Exception exception) 45 { 46 super(message); 47 this.exception = exception; 48 } 49 50 public XMIException(String message, String location, int line, int column) 51 { 52 super(message); 53 this.location = location; 54 this.line = line; 55 this.column = column; 56 } 57 58 public XMIException(String message, Exception exception, String location, int line, int column) 59 { 60 super(message); 61 this.exception = exception; 62 this.location = location; 63 this.line = line; 64 this.column = column; 65 } 66 67 public XMIException(Exception exception, String location, int line, int column) 68 { 69 super(exception.getMessage()); 70 this.exception = exception; 71 this.location = location; 72 this.line = line; 73 this.column = column; 74 } 75 76 public String getMessage() 77 { 78 String result = super.getMessage(); 79 if (line != 0) 80 { 81 result += " (" + location + ", " + line + ", " + column + ")"; 82 } 83 return result; 84 } 85 86 public String getLocation() 87 { 88 return location; 89 } 90 91 public int getLine() 92 { 93 return line; 94 } 95 96 public int getColumn() 97 { 98 return column; 99 } 100 101 public Exception getWrappedException() 102 { 103 return exception; 104 } 105 106 public void printStackTrace() 107 { 108 if (exception != null) 109 { 110 exception.printStackTrace(); 111 } 112 else 113 { 114 super.printStackTrace(); 115 } 116 } 117 118 public void printStackTrace(PrintStream printStream) 119 { 120 if (exception != null) 121 { 122 exception.printStackTrace(printStream); 123 } 124 else 125 { 126 super.printStackTrace(printStream); 127 } 128 } 129 130 public void printStackTrace(PrintWriter printWriter) 131 { 132 if (exception != null) 133 { 134 exception.printStackTrace(printWriter); 135 } 136 else 137 { 138 super.printStackTrace(printWriter); 139 } 140 } 141 } 142 | Popular Tags |