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: PostgreSQLForeignKeyInfo.java,v 1.1 2003/01/30 05:29:10 jackknifebarber Exp $
09: */
10:
11: package com.triactive.jdo.store;
12:
13: import java.sql.ResultSet;
14:
15: /**
16: * Represents the metadata of a table's foreign key column in PostgreSQL.
17: *
18: * @author <a href="mailto:mmartin5@austin.rr.com">Mike Martin</a>
19: * @version $Revision: 1.1 $
20: */
21:
22: class PostgreSQLForeignKeyInfo extends ForeignKeyInfo {
23: /**
24: * Constructs a foreign key information object from the current row of the
25: * given result set.
26: * The {@link ResultSet} object passed must have been obtained from a call
27: * to DatabaseMetaData.getImportedKeys() or DatabaseMetaData.getExportedKeys().
28: *
29: * <p>This method only retrieves the values from the current row; the caller
30: * is required to advance to the next row with {@link ResultSet#next}.
31: *
32: * @param rs The result set returned from DatabaseMetaData.get??portedKeys().
33: */
34:
35: public PostgreSQLForeignKeyInfo(ResultSet rs) {
36: super (rs);
37:
38: /*
39: * The PostgreSQL drivers sometimes produce some truly funky metadata.
40: * In this case, the FK_NAME column has been known to have miscellaneous
41: * other strings dangling off the end of it separated by "\000", as in
42: *
43: * WIDGET_FK1\000WIDGET\000BLAH ...
44: *
45: * instead of:
46: *
47: * WIDGET_FK1
48: */
49: int firstBackslashIdx = fkName.indexOf('\\');
50:
51: if (firstBackslashIdx > 0)
52: fkName = fkName.substring(0, firstBackslashIdx);
53: }
54: }
|