KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > ecore > xmi > XMIException


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2002-2004 IBM Corporation and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  * $Id: XMIException.java,v 1.2 2005/06/08 06:16:07 nickb Exp $
16  */

17 package org.eclipse.emf.ecore.xmi;
18
19
20 import java.io.PrintStream JavaDoc;
21 import java.io.PrintWriter JavaDoc;
22
23 import org.eclipse.emf.ecore.resource.Resource;
24
25
26 public class XMIException extends Exception JavaDoc implements Resource.Diagnostic
27 {
28   protected String JavaDoc location;
29   protected int line;
30   protected int column;
31   protected Exception JavaDoc exception;
32
33   public XMIException(String JavaDoc message)
34   {
35     super(message);
36   }
37
38   public XMIException(Exception JavaDoc exception)
39   {
40     super(exception.getMessage());
41     this.exception = exception;
42   }
43
44   public XMIException(String JavaDoc message, Exception JavaDoc exception)
45   {
46     super(message);
47     this.exception = exception;
48   }
49
50   public XMIException(String JavaDoc message, String JavaDoc 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 JavaDoc message, Exception JavaDoc exception, String JavaDoc 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 JavaDoc exception, String JavaDoc 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 JavaDoc getMessage()
77   {
78     String JavaDoc result = super.getMessage();
79     if (line != 0)
80     {
81       result += " (" + location + ", " + line + ", " + column + ")";
82     }
83     return result;
84   }
85
86   public String JavaDoc 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 JavaDoc 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 JavaDoc 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 JavaDoc 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