Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/arranger/jarl/script/gsp/GSPException.java


1   package com.arranger.jarl.script.gsp;
2   
3   import java.io.PrintStream;
4   import java.io.PrintWriter;
5   
6   /**
7    * Exception thrown by gsp.
8    */
9   public class GSPException extends Exception {
10      
11      protected int m_line = 0;
12      protected int m_column = 0;
13      protected String m_file = null;
14      protected Throwable m_root = null;
15      
16      public GSPException(String message) {
17          super(message);
18      }
19      
20      public GSPException(Throwable t) {
21          super(t.getMessage());
22          
23          m_root = t;
24      }
25  
26      public GSPException(Throwable t, String fileName) {
27          super(t.getMessage());
28  
29          m_root = t;
30          m_file = fileName;
31      }
32  
33  
34      public GSPException(String message, int line, int column) {
35          super(message);
36          
37          m_line = line;
38          m_column = column;
39      }
40      
41      public GSPException(Throwable t, int line, int column) {
42          super(t.getMessage());
43          
44          m_root = t;
45          m_line = line;
46          m_column = column;
47      }
48      
49      public Throwable getRoot() {
50          return m_root;
51      }
52      
53      public int getLine() {
54          return m_line;
55      }
56      
57      public void setLine(int line) {
58          m_line = line;
59      }
60      
61      public int getColumn() {
62          return m_column;
63      }
64      
65      public void setColumn(int column) {
66          m_column = column;
67      }
68      
69      public String getFile() {
70          return m_file;
71      }
72      
73      public void setFile(String file) {
74          m_file = file;
75      }
76      
77      public String getMessage() {
78          return super.getMessage() + " (" + (m_file != null ? (m_file + ": ")  : "")
79          + "line " + m_line + ", col " + m_column + ")";
80      }
81      
82      public void printStackTrace() {
83          if (m_root != null) {
84              System.err.println(getMessage());
85              m_root.printStackTrace();
86          } else {
87              super.printStackTrace();
88          }
89      }
90      
91      public void printStackTrace(PrintStream s) {
92          if (m_root != null) {
93              s.println(getMessage());
94              m_root.printStackTrace(s);
95          } else {
96              super.printStackTrace(s);
97          }
98      }
99      
100     public void printStackTrace(PrintWriter s) {
101         if (m_root != null) {
102             s.println(getMessage());
103             m_root.printStackTrace(s);
104         } else {
105             super.printStackTrace(s);
106         }
107     }
108 
109     public GSPException updateFileName (String fileName) {
110         if (m_file == null) {
111             m_file = fileName;
112         }
113 
114         return this;
115     }
116 }