intial source from ttp://www.sf.net/projects/wdte
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.css.core / src / net / sourceforge / phpeclipse / css / core / parser / SyntaxErrorException.java
1 /*
2  * Copyright (c) 2003-2004 Christopher Lenz and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     Christopher Lenz - initial API and implementation
10  * 
11  * $Id: SyntaxErrorException.java,v 1.1 2004-09-02 18:07:12 jsurfer Exp $
12  */
13
14 package net.sourceforge.phpeclipse.css.core.parser;
15
16 /**
17  * 
18  */
19 public class SyntaxErrorException extends Exception {
20
21         // Instance Variables ------------------------------------------------------
22
23         /**
24          * The line number at which the error was detected in the source.
25          */
26         private int lineNumber;
27
28         /**
29          * The offset into the document.
30          */
31         private int offset;
32
33         /**
34          * The length of the source range affected by the syntax error.
35          */
36         private int length;
37
38         // Constructors ------------------------------------------------------------
39
40         /**
41          * Constructor.
42          */
43         public SyntaxErrorException() {
44                 super();
45         }
46
47         /**
48          * Constructor.
49          * 
50          * @param message the exception message
51          */
52         public SyntaxErrorException(String message) {
53                 super(message);
54         }
55
56         /**
57          * Constructor.
58          * 
59          * @param message the exception message
60          * @param lineNumber the line number
61          * @param offset the offset
62          * @param length the length
63          */
64         public SyntaxErrorException(String message, int lineNumber, int offset,
65                 int length) {
66                 super(message + " (" + lineNumber + ")"); //$NON-NLS-1$ //$NON-NLS-2$
67                 this.lineNumber = lineNumber;
68                 this.offset = offset;
69                 this.length = length;
70         }
71
72         // Public Methods ----------------------------------------------------------
73
74         /**
75          * Returns the length of the offending code
76          * 
77          * @return the length of the offending code
78          */
79         public final int getLength() {
80                 return this.length;
81         }
82
83         /**
84          * Returns the line number at which the error was detected.
85          * 
86          * @return the line number
87          */
88         public final int getLineNumber() {
89                 return this.lineNumber;
90         }
91
92         /**
93          * Returns the offset of the offending code
94          * 
95          * @return the offset of the offending code
96          */
97         public final int getOffset() {
98                 return this.offset;
99         }
100
101 }