View Javadoc
1   /*
2    *
3    * The DbUnit Database Testing Framework
4    * Copyright (C)2002-2004, DbUnit.org
5    *
6    * This library is free software; you can redistribute it and/or
7    * modify it under the terms of the GNU Lesser General Public
8    * License as published by the Free Software Foundation; either
9    * version 2.1 of the License, or (at your option) any later version.
10   *
11   * This library is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14   * Lesser General Public License for more details.
15   *
16   * You should have received a copy of the GNU Lesser General Public
17   * License along with this library; if not, write to the Free Software
18   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19   *
20   */
21  
22  package org.dbunit.dataset;
23  
24  
25  /**
26   * Thrown to indicate that a database column has been accessed that does not
27   * exist. 
28   * 
29   * @author Manuel Laflamme
30   * @version $Revision$
31   * @since Feb 17, 2002
32   */
33  public class NoSuchColumnException extends DataSetException
34  {
35      /**
36       * @deprecated since 2.3.0. Prefer constructor taking a table/columnName as argument
37       */
38      public NoSuchColumnException()
39      {
40      }
41      
42      /**
43       * @deprecated since 2.3.0. Prefer constructor taking a table/columnName as argument
44       */
45      public NoSuchColumnException(String msg)
46      {
47          super(msg);
48      }
49  
50      /**
51       * Creates an exception using the given table name + column name
52       * @param tableName table in which the column was not found. Can be null
53       * @param columnName the column that was not found
54       * @since 2.3.0
55       */
56      public NoSuchColumnException(String tableName, String columnName)
57      {
58          this(tableName, columnName, null);
59      }
60  
61      /**
62       * Creates an exception using the given table name + column name
63       * @param tableName table in which the column was not found. Can be null
64       * @param columnName the column that was not found
65       * @param msg Additional message to append to the exception text
66       * @since 2.3.0
67       */
68      public NoSuchColumnException(String tableName, String columnName, String msg)
69      {
70          super(buildText(tableName, columnName, msg));
71      }
72  
73  	/**
74  	 * @param msg
75  	 * @param e
76       * @deprecated since 2.3.0. Prefer constructor taking a table/columnName as argument
77  	 */
78  	public NoSuchColumnException(String msg, Throwable e)
79      {
80          super(msg, e);
81      }
82  
83      /**
84       * @param e
85       * @deprecated since 2.3.0. Prefer constructor taking a table/columnName as argument
86       */
87      public NoSuchColumnException(Throwable e)
88      {
89          super(e);
90      }
91      
92      
93      private static String buildText(String tableName, String columnName, String message) {
94      	StringBuffer sb = new StringBuffer();
95      	if(tableName != null){
96      		sb.append(tableName).append(".");
97      	}
98      	sb.append(columnName);
99      	if(message != null) {
100     		sb.append(" - ").append(message);
101     	}
102 		return sb.toString();
103 	}
104 
105 }
106 
107 
108 
109 
110