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: MissingForeignKeysException.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>MissingForeignKeysException</tt> is thrown if an expected foreign key
18: * is 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: */
25:
26: public class MissingForeignKeysException extends
27: SchemaValidationException {
28: /**
29: * Constructs a missing foreign key(s) exception.
30: *
31: * @param table The table in which foeign key(s) were missing.
32: * @param stmts The statements that would be used to create the missing keys.
33: */
34:
35: public MissingForeignKeysException(Table table, Collection stmts) {
36: super ("Required foreign keys missing from " + table + '\n'
37: + listOnePerLine(stmts));
38: }
39:
40: private static String listOnePerLine(Collection stmts) {
41: StringBuffer list = new StringBuffer();
42: Iterator i = stmts.iterator();
43:
44: while (i.hasNext())
45: list.append(i.next()).append('\n');
46:
47: return list.toString();
48: }
49: }
|