View Javadoc

1   /*
2       Jameleon - An automation testing tool..
3       Copyright (C) 2006 Christian W. Hargraves (engrean@hotmail.com)
4       
5       This library is free software; you can redistribute it and/or
6       modify it under the terms of the GNU Lesser General Public
7       License as published by the Free Software Foundation; either
8       version 2.1 of the License, or (at your option) any later version.
9   
10      This library is distributed in the hope that it will be useful,
11      but WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13      Lesser General Public License for more details.
14  
15      You should have received a copy of the GNU Lesser General Public
16      License along with this library; if not, write to the Free Software
17      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */
19  package net.sf.jameleon.exception;
20  
21  import org.apache.commons.jelly.LocationAware;
22  
23  /***
24   * A RuntimeException that is noted as the script failing. The reason behind a RuntimeException
25   * is so that the test can continue of it is supposed to continue
26   */
27  public class JameleonScriptException extends RuntimeException implements LocationAware{
28  	private static final long serialVersionUID = 1L;
29  
30      protected int lineNumber = -1;
31      protected int columnNumber = -1;
32      protected String scriptFileName;
33      protected String elementTagName;
34  
35      public JameleonScriptException(){
36          super();
37      }
38  
39      public JameleonScriptException(String errorMsg){
40          super(errorMsg);
41      }
42  
43      public JameleonScriptException(Throwable cause){
44          super(cause);
45      }
46  
47      public JameleonScriptException(Throwable cause, LocationAware la){
48          super(cause);
49          copyLocationAwareProperties(la);
50      }
51  
52      public JameleonScriptException(String errorMsg, Throwable cause){
53          super(errorMsg, cause);
54      }
55  
56      public JameleonScriptException(String errorMsg, LocationAware la){
57          super(errorMsg);
58          copyLocationAwareProperties(la);
59      }
60  
61      public JameleonScriptException(String errorMsg, Throwable cause, LocationAware la){
62          super(errorMsg, cause);
63          copyLocationAwareProperties(la);
64      }
65  
66      protected void copyLocationAwareProperties(LocationAware la){
67          setLineNumber(la.getLineNumber());
68          setColumnNumber(la.getColumnNumber());
69          setFileName(la.getFileName());
70          setElementName(la.getElementName());
71      }
72  
73      /*** 
74       * @return the line number of the tag 
75       */
76      public int getLineNumber(){
77          return lineNumber;
78      }
79      
80      /*** 
81       * Sets the line number of the tag 
82       */
83      public void setLineNumber(int lineNumber){
84          this.lineNumber = lineNumber;
85      }
86  
87      /*** 
88       * @return the column number of the tag 
89       */
90      public int getColumnNumber(){
91          return columnNumber;
92      }
93      
94      /*** 
95       * Sets the column number of the tag 
96       */
97      public void setColumnNumber(int columnNumber){
98          this.columnNumber = columnNumber;
99      }
100 
101     /*** 
102      * @return the Jelly file which caused the problem 
103      */
104     public String getFileName(){
105         return scriptFileName;
106     }
107     
108     /*** 
109      * Sets the Jelly file which caused the problem 
110      */
111     public void setFileName(String fileName){
112         this.scriptFileName = fileName;
113     }
114     
115     /*** 
116      * @return the element name which caused the problem
117      */
118     public String getElementName(){
119         return elementTagName;
120     }
121 
122     /*** 
123      * Sets the element name which caused the problem
124      */
125     public void setElementName(String elementName){
126         this.elementTagName = elementName;
127     }
128 
129 }