01: /*
02: * Copyright 2002 (C) TJDO.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the TJDO License version 1.0.
06: * See the terms of the TJDO License in the documentation provided with this software.
07: *
08: * $Id: MissingColumnException.java,v 1.3 2002/11/08 05:06:25 jackknifebarber Exp $
09: */
10:
11: package com.triactive.jdo.store;
12:
13: import java.util.Collection;
14: import java.util.Iterator;
15:
16: /**
17: * A <tt>MissingColumnException</tt> is thrown if an expected column is
18: * not found in the database during schema validation.
19: *
20: * @author <a href="mailto:mmartin5@austin.rr.com">Mike Martin</a>
21: * @version $Revision: 1.3 $
22: *
23: * @see Table
24: * @see Column
25: */
26:
27: public class MissingColumnException extends SchemaValidationException {
28: /**
29: * Constructs a missing column exception.
30: *
31: * @param table The table in which column(s) were missing.
32: * @param columns The collection of Column(s) that were missing.
33: */
34:
35: public MissingColumnException(Table table, Collection columns) {
36: super ("Required columns missing from " + table + ": "
37: + getColumnNameList(columns));
38: }
39:
40: private static String getColumnNameList(Collection columns) {
41: StringBuffer list = new StringBuffer();
42: Iterator i = columns.iterator();
43:
44: while (i.hasNext()) {
45: if (list.length() > 0)
46: list.append(", ");
47:
48: list.append(((Column) i.next()).getName());
49: }
50:
51: return list.toString();
52: }
53: }
|