KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xquark > mapper > StorageException


1 /*
2  * This file belongs to the XQuark distribution.
3  * Copyright (C) 2003 Universite de Versailles Saint-Quentin.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307.
18  * You can also get it at http://www.gnu.org/licenses/lgpl.html
19  *
20  * For more information on this software, see http://www.xquark.org.
21  */

22
23 /*
24  * StorageException.java
25  *
26  * Created on 18 avril 2001, 13:05
27  */

28
29 package org.xquark.mapper;
30
31 import org.xml.sax.Locator JavaDoc;
32
33 /**
34  * This exception replaces RepositoryException at storage time when XML document
35  * location information is available.
36  *
37  */

38 public class StorageException extends RepositoryException implements Locator JavaDoc
39 {
40 private static final String JavaDoc RCSRevision = "$Revision: 1.1 $";
41 private static final String JavaDoc RCSName = "$Name: $";
42     private int line;
43     private int column;
44     private String JavaDoc systemID;
45     private String JavaDoc publicID;
46     
47     /**
48      * Constructor.
49      * @param code the code featuring the kind of error
50      * (see RepositoryException constants).
51      * @param message A litteral message bringing precisions on the error.
52      */

53     public StorageException(int code, String JavaDoc message)
54     {
55         super(code, message);
56     }
57     
58     /**
59      * Constructor.
60      * @param exception base RepositoryException.
61      */

62     public StorageException(RepositoryException exception)
63     {
64         super(exception.getCode(), exception.getMessage(), exception.getException());
65     }
66     
67     /**
68      * Constructor.
69      * @param exception base RepositoryException.
70      * @param locator SAX locator for identifying last parsing position when
71      * exception occured.
72      */

73     public StorageException(RepositoryException exception, Locator JavaDoc locator)
74     {
75         this(exception);
76         setLocator(locator);
77     }
78     
79     /** Constructor for application exceptions encapsulating an underlying exception.
80      * @param code the code featuring the kind of error
81      * (see RepositoryException constants).
82      * @param message A litteral message bringing precisions on the error.
83      * @param underlyingException the original Exception that carried out this
84      * exception.
85      */

86     public StorageException(int code, String JavaDoc message, Exception JavaDoc underlyingException)
87     {
88         super(code, message, underlyingException);
89     }
90     /** Constructor for application exceptions encapsulating an underlying exception.
91      * @param code the code featuring the kind of error
92      * (see RepositoryException constants).
93      * @param message A litteral message bringing precisions on the error.
94      * @param underlyingException the original Exception that carried out this
95      * exception.
96      * @param locator SAX locator for identifying last parsing position when
97      * exception occured.
98      */

99     public StorageException(int code, String JavaDoc message, Exception JavaDoc underlyingException, Locator JavaDoc locator)
100     {
101         super(code, message, underlyingException);
102         setLocator(locator);
103     }
104     
105     /** Set parsing document locator for exception.
106      * @param locator SAX locator for identifying last parsing position when
107      * exception occured.
108      */

109     public void setLocator(Locator JavaDoc locator)
110     {
111         line = locator.getLineNumber();
112         column = locator.getColumnNumber();
113         systemID = locator.getSystemId();
114         publicID = locator.getPublicId();
115     }
116     
117     /**
118      * Return the public identifier for the parsed document.
119      *
120      * <p>The return value is the public identifier of the document
121      * entity or of the external parsed entity in which the markup
122      * triggering the exception appears.</p>
123      *
124      * @return A string containing the public identifier, or
125      * null if none is available.
126      * @see #getSystemId
127      */

128     public String JavaDoc getPublicId()
129     {
130         return publicID;
131     }
132     
133     /**
134      * Return the system identifier for the parsed document.
135      *
136      * <p>The return value is the system identifier of the document
137      * entity or of the external parsed entity in which the markup
138      * triggering the exception appears.</p>
139      *
140      * @return A string containing the system identifier, or null
141      * if none is available.
142      * @see #getPublicId
143      */

144     public String JavaDoc getSystemId()
145     {
146         return systemID;
147     }
148     
149     /**
150      * Return the line number where the exception occurs.
151      *
152      * <p><strong>Warning:</strong> The return value from the method
153      * is intended only as an approximation for the sake of error
154      * reporting; it is not intended to provide sufficient information
155      * to edit the character content of the original XML document.</p>
156      *
157      * <p>The return value is an approximation of the line number
158      * in the document entity or external parsed entity where the
159      * markup triggering the exception appears.</p>
160      *
161      * @return The line number, or -1 if none is available.
162      * @see #getColumnNumber
163      */

164     public int getLineNumber()
165     {
166         return line;
167     }
168     
169     /**
170      * Return the column number where the exception occurs.
171      *
172      * <p><strong>Warning:</strong> The return value from the method
173      * is intended only as an approximation for the sake of error
174      * reporting; it is not intended to provide sufficient information
175      * to edit the character content of the original XML document.</p>
176      *
177      * <p>The return value is an approximation of the column number
178      * in the document entity or external parsed entity where the
179      * markup triggering the event appears.</p>
180      *
181      * @return The column number, or -1 if none is available.
182      * @see #getLineNumber
183      */

184     public int getColumnNumber()
185     {
186         return column;
187     }
188     
189 }
190
Popular Tags