KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > chaperon > process > ParseException


1 /*
2  * Copyright (C) Chaperon. All rights reserved.
3  * -------------------------------------------------------------------------
4  * This software is published under the terms of the Apache Software License
5  * version 1.1, a copy of which has been included with this distribution in
6  * the LICENSE file.
7  */

8
9 package net.sourceforge.chaperon.process;
10
11 import org.xml.sax.Locator JavaDoc;
12 import org.xml.sax.SAXException JavaDoc;
13
14 public class ParseException extends SAXException JavaDoc
15 {
16   private String JavaDoc symbol;
17   private String JavaDoc text;
18   private String JavaDoc lineSnippet = null;
19   private boolean location = false;
20   private String JavaDoc source;
21   private int lineNumber;
22   private int columnNumber;
23
24   public ParseException(String JavaDoc message)
25   {
26     super(message);
27   }
28
29   public ParseException(String JavaDoc message, String JavaDoc symbol, String JavaDoc text, Locator JavaDoc locator)
30   {
31     super(message);
32
33     this.symbol = symbol;
34     this.text = text;
35
36     if (locator!=null)
37     {
38       this.source = locator.getSystemId();
39       this.lineNumber = locator.getLineNumber();
40       this.columnNumber = locator.getColumnNumber();
41       location = true;
42     }
43   }
44
45   public ParseException(String JavaDoc message, String JavaDoc symbol, String JavaDoc text, String JavaDoc lineSnippet,
46                         Locator JavaDoc locator)
47   {
48     this(message, symbol, text, locator);
49
50     this.lineSnippet = lineSnippet;
51   }
52
53   public ParseException(String JavaDoc message, String JavaDoc symbol, String JavaDoc text, String JavaDoc lineSnippet,
54                         String JavaDoc source, int lineNumber, int columnNumber)
55   {
56     super(message);
57
58     this.symbol = symbol;
59     this.text = text;
60
61     this.lineSnippet = lineSnippet;
62     this.source = source;
63     this.lineNumber = lineNumber;
64     this.columnNumber = columnNumber;
65   }
66
67   public String JavaDoc getSymbol()
68   {
69     return symbol;
70   }
71
72   public String JavaDoc getText()
73   {
74     return text;
75   }
76
77   public String JavaDoc getLineSnippet()
78   {
79     return lineSnippet;
80   }
81
82   public boolean isLocalized()
83   {
84     return location;
85   }
86
87   public String JavaDoc getSource()
88   {
89     return source;
90   }
91
92   public int getLineNumber()
93   {
94     return lineNumber;
95   }
96
97   public int getColumnNumber()
98   {
99     return columnNumber;
100   }
101
102   public String JavaDoc toString()
103   {
104     if (location)
105       return getMessage()+"["+lineNumber+":"+columnNumber+"]";
106
107     return getMessage();
108   }
109 }
110
Popular Tags