KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > w3c > css > sac > CSSParseException


1 /*
2  * Copyright (c) 1999 World Wide Web Consortium
3  * (Massachusetts Institute of Technology, Institut National de Recherche
4  * en Informatique et en Automatique, Keio University).
5  * All Rights Reserved. http://www.w3.org/Consortium/Legal/
6  *
7  * The original version of this interface comes from SAX :
8  * http://www.megginson.com/SAX/
9  *
10  * $Id: CSSParseException.java,v 1.1.1.1 2003/12/28 21:23:46 davidsch Exp $
11  */

12 package org.w3c.css.sac;
13
14 /**
15  * Encapsulate a CSS parse error or warning.
16  *
17  * <p>This exception will include information for locating the error
18  * in the original CSS document. Note that although the application
19  * will receive a CSSParseException as the argument to the handlers
20  * in the ErrorHandler interface, the application is not actually
21  * required to throw the exception; instead, it can simply read the
22  * information in it and take a different action.</p>
23  *
24  * <p>Since this exception is a subclass of CSSException, it
25  * inherits the ability to wrap another exception.</p>
26  *
27  * @version $Revision: 1.1.1.1 $
28  * @author Philippe Le Hegaret
29  */

30 public class CSSParseException extends CSSException {
31     
32     private String JavaDoc uri;
33     private int lineNumber;
34     private int columnNumber;
35     
36     /**
37      * Create a new CSSParseException from a message and a Locator.
38      *
39      * <p>This constructor is especially useful when an application is
40      * creating its own exception from within a DocumentHandler
41      * callback.</p>
42      *
43      * @param message The error or warning message.
44      * @param locator The locator object for the error or warning.
45      * @see Locator
46      * @see Parser#setLocale
47      */

48     public CSSParseException(String JavaDoc message, Locator locator) {
49     super(message);
50     this.code = SAC_SYNTAX_ERR;
51     this.uri = locator.getURI();
52     this.lineNumber = locator.getLineNumber();
53     this.columnNumber = locator.getColumnNumber();
54     }
55     
56     
57     /**
58
59      * Wrap an existing exception in a CSSParseException.
60      *
61      * <p>This constructor is especially useful when an application is
62      * creating its own exception from within a DocumentHandler
63      * callback, and needs to wrap an existing exception that is not a
64      * subclass of CSSException.</p>
65      *
66      * @param message The error or warning message, or null to
67      * use the message from the embedded exception.
68      * @param locator The locator object for the error or warning.
69      * @param e Any exception
70      * @see Locator
71      * @see Parser#setLocale
72      */

73     public CSSParseException(String JavaDoc message, Locator locator,
74                  Exception JavaDoc e) {
75     super(SAC_SYNTAX_ERR, message, e);
76     this.uri = locator.getURI();
77     this.lineNumber = locator.getLineNumber();
78     this.columnNumber = locator.getColumnNumber();
79     }
80     
81     
82     /**
83      * Create a new CSSParseException.
84      *
85      * <p>This constructor is most useful for parser writers.</p>
86      *
87      * <p>the parser must resolve the URI fully before creating the exception.</p>
88      *
89      * @param message The error or warning message.
90      * @param uri The URI of the document that generated the error or warning.
91      * @param lineNumber The line number of the end of the text that
92      * caused the error or warning.
93      * @param columnNumber The column number of the end of the text that
94      * cause the error or warning.
95      * @see Parser#setLocale
96      */

97     public CSSParseException(String JavaDoc message, String JavaDoc uri,
98                  int lineNumber, int columnNumber) {
99     super(message);
100     this.code = SAC_SYNTAX_ERR;
101     this.uri = uri;
102     this.lineNumber = lineNumber;
103     this.columnNumber = columnNumber;
104     }
105         
106     /**
107      * Create a new CSSParseException with an embedded exception.
108      *
109      * <p>This constructor is most useful for parser writers who
110      * need to wrap an exception that is not a subclass of
111      * CSSException.</p>
112      *
113      * <p>The parser must resolve the URI fully before creating the
114      * exception.</p>
115      *
116      * @param message The error or warning message, or null to use
117      * the message from the embedded exception.
118      * @param uri The URI of the document that generated
119      * the error or warning.
120      * @param lineNumber The line number of the end of the text that
121      * caused the error or warning.
122      * @param columnNumber The column number of the end of the text that
123      * cause the error or warning.
124      * @param e Another exception to embed in this one.
125      * @see Parser#setLocale
126      */

127     public CSSParseException(String JavaDoc message, String JavaDoc uri,
128                  int lineNumber, int columnNumber, Exception JavaDoc e) {
129     super(SAC_SYNTAX_ERR, message, e);
130     this.uri = uri;
131     this.lineNumber = lineNumber;
132     this.columnNumber = columnNumber;
133     }
134     
135     /**
136      * Get the URI of the document where the exception occurred.
137      *
138      * <p>The URI will be resolved fully.</p>
139      *
140      * @return A string containing the URI, or null
141      * if none is available.
142      * @see Locator#getURI
143      */

144     public String JavaDoc getURI() {
145     return this.uri;
146     }
147     
148     
149     /**
150      * The line number of the end of the text where the exception occurred.
151      *
152      * @return An integer representing the line number, or -1
153      * if none is available.
154      * @see Locator#getLineNumber
155      */

156     public int getLineNumber() {
157     return this.lineNumber;
158     }
159     
160     
161     /**
162      * The column number of the end of the text where the exception occurred.
163      *
164      * <p>The first column in a line is position 1.</p>
165      *
166      * @return An integer representing the column number, or -1
167      * if none is available.
168      * @see Locator#getColumnNumber
169      */

170     public int getColumnNumber() {
171     return this.columnNumber;
172     }
173 }
174
Popular Tags