KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > triactive > jdo > store > MissingColumnException


1 /*
2  * Copyright 2002 (C) TJDO.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the TJDO License version 1.0.
6  * See the terms of the TJDO License in the documentation provided with this software.
7  *
8  * $Id: MissingColumnException.java,v 1.3 2002/11/08 05:06:25 jackknifebarber Exp $
9  */

10
11 package com.triactive.jdo.store;
12
13 import java.util.Collection JavaDoc;
14 import java.util.Iterator JavaDoc;
15
16
17 /**
18  * A <tt>MissingColumnException</tt> is thrown if an expected column is
19  * not found in the database during schema validation.
20  *
21  * @author <a HREF="mailto:mmartin5@austin.rr.com">Mike Martin</a>
22  * @version $Revision: 1.3 $
23  *
24  * @see Table
25  * @see Column
26  */

27
28 public class MissingColumnException extends SchemaValidationException
29 {
30     /**
31      * Constructs a missing column exception.
32      *
33      * @param table The table in which column(s) were missing.
34      * @param columns The collection of Column(s) that were missing.
35      */

36
37     public MissingColumnException(Table table, Collection JavaDoc columns)
38     {
39         super("Required columns missing from " + table + ": " + getColumnNameList(columns));
40     }
41
42     private static String JavaDoc getColumnNameList(Collection JavaDoc columns)
43     {
44         StringBuffer JavaDoc list = new StringBuffer JavaDoc();
45         Iterator JavaDoc i = columns.iterator();
46
47         while (i.hasNext())
48         {
49             if (list.length() > 0)
50                 list.append(", ");
51
52             list.append(((Column)i.next()).getName());
53         }
54
55         return list.toString();
56     }
57 }
58
Popular Tags