File: CSSParseException.java

package info (click to toggle)
sacjava 1.3%2Bdfsg-5.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 240 kB
  • sloc: java: 480; xml: 31; makefile: 11
file content (173 lines) | stat: -rw-r--r-- 5,792 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/*
 * Copyright (c) 1999 World Wide Web Consortium
 * (Massachusetts Institute of Technology, Institut National de Recherche
 *  en Informatique et en Automatique, Keio University).
 * All Rights Reserved. http://www.w3.org/Consortium/Legal/
 *
 * The original version of this interface comes from SAX :
 * http://www.megginson.com/SAX/
 *
 * $Id: CSSParseException.java,v 1.3 2000/02/15 02:07:34 plehegar Exp $
 */
package org.w3c.css.sac;

/**
 * Encapsulate a CSS parse error or warning.
 *
 * <p>This exception will include information for locating the error
 * in the original CSS document.  Note that although the application
 * will receive a CSSParseException as the argument to the handlers
 * in the ErrorHandler interface, the application is not actually
 * required to throw the exception; instead, it can simply read the
 * information in it and take a different action.</p>
 *
 * <p>Since this exception is a subclass of CSSException, it
 * inherits the ability to wrap another exception.</p>
 *
 * @version $Revision: 1.3 $
 * @author  Philippe Le Hegaret
 */
public class CSSParseException extends CSSException {
    
    private String uri;
    private int lineNumber;
    private int columnNumber;
    
    /**
     * Create a new CSSParseException from a message and a Locator.
     *
     * <p>This constructor is especially useful when an application is
     * creating its own exception from within a DocumentHandler
     * callback.</p>
     *
     * @param message The error or warning message.
     * @param locator The locator object for the error or warning.
     * @see Locator
     * @see Parser#setLocale 
     */
    public CSSParseException(String message, Locator locator) {
	super(message);
	this.code = SAC_SYNTAX_ERR;
	this.uri = locator.getURI();
	this.lineNumber = locator.getLineNumber();
	this.columnNumber = locator.getColumnNumber();
    }
    
    
    /**

     * Wrap an existing exception in a CSSParseException.
     *
     * <p>This constructor is especially useful when an application is
     * creating its own exception from within a DocumentHandler
     * callback, and needs to wrap an existing exception that is not a
     * subclass of CSSException.</p>
     *
     * @param message The error or warning message, or null to
     *                use the message from the embedded exception.
     * @param locator The locator object for the error or warning.
     * @param e Any exception
     * @see Locator
     * @see Parser#setLocale
     */
    public CSSParseException(String message, Locator locator,
			     Exception e) {
	super(SAC_SYNTAX_ERR, message, e);
	this.uri = locator.getURI();
	this.lineNumber = locator.getLineNumber();
	this.columnNumber = locator.getColumnNumber();
    }
    
    
    /**
     * Create a new CSSParseException.
     *
     * <p>This constructor is most useful for parser writers.</p>
     *
     * <p>the parser must resolve the URI fully before creating the exception.</p>
     *
     * @param message The error or warning message.
     * @param uri The URI of the document that generated the error or warning.
     * @param lineNumber The line number of the end of the text that
     *                   caused the error or warning.
     * @param columnNumber The column number of the end of the text that
     *                     cause the error or warning.
     * @see Parser#setLocale
     */
    public CSSParseException(String message, String uri,
			     int lineNumber, int columnNumber) {
	super(message);
	this.code = SAC_SYNTAX_ERR;
	this.uri = uri;
	this.lineNumber = lineNumber;
	this.columnNumber = columnNumber;
    }
        
    /**
     * Create a new CSSParseException with an embedded exception.
     *
     * <p>This constructor is most useful for parser writers who
     * need to wrap an exception that is not a subclass of
     * CSSException.</p>
     *
     * <p>The parser must resolve the URI fully before creating the
     * exception.</p>
     *
     * @param message The error or warning message, or null to use
     *                the message from the embedded exception.
     * @param uri The URI of the document that generated
     *                 the error or warning.
     * @param lineNumber The line number of the end of the text that
     *                   caused the error or warning.
     * @param columnNumber The column number of the end of the text that
     *                     cause the error or warning.
     * @param e Another exception to embed in this one.
     * @see Parser#setLocale 
     */
    public CSSParseException(String message, String uri,
			     int lineNumber, int columnNumber, Exception e) {
	super(SAC_SYNTAX_ERR, message, e);
	this.uri = uri;
	this.lineNumber = lineNumber;
	this.columnNumber = columnNumber;
    }
    
    /**
     * Get the URI of the document where the exception occurred.
     *
     * <p>The URI will be resolved fully.</p>
     *
     * @return A string containing the URI, or null
     *         if none is available.
     * @see Locator#getURI
     */
    public String getURI() {
	return this.uri;
    }
    
    
    /**
     * The line number of the end of the text where the exception occurred.
     *
     * @return An integer representing the line number, or -1
     *         if none is available.
     * @see Locator#getLineNumber
     */
    public int getLineNumber() {
	return this.lineNumber;
    }
    
    
    /**
     * The column number of the end of the text where the exception occurred.
     *
     * <p>The first column in a line is position 1.</p>
     *
     * @return An integer representing the column number, or -1
     *         if none is available.
     * @see Locator#getColumnNumber
     */
    public int getColumnNumber() {
	return this.columnNumber;
    }
}