KickJava   Java API By Example, From Geeks To Geeks.

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


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: PostgreSQLForeignKeyInfo.java,v 1.1 2003/01/30 05:29:10 jackknifebarber Exp $
9  */

10
11 package com.triactive.jdo.store;
12
13 import java.sql.ResultSet JavaDoc;
14
15
16 /**
17  * Represents the metadata of a table's foreign key column in PostgreSQL.
18  *
19  * @author <a HREF="mailto:mmartin5@austin.rr.com">Mike Martin</a>
20  * @version $Revision: 1.1 $
21  */

22
23 class PostgreSQLForeignKeyInfo extends ForeignKeyInfo
24 {
25     /**
26      * Constructs a foreign key information object from the current row of the
27      * given result set.
28      * The {@link ResultSet} object passed must have been obtained from a call
29      * to DatabaseMetaData.getImportedKeys() or DatabaseMetaData.getExportedKeys().
30      *
31      * <p>This method only retrieves the values from the current row; the caller
32      * is required to advance to the next row with {@link ResultSet#next}.
33      *
34      * @param rs The result set returned from DatabaseMetaData.get??portedKeys().
35      */

36
37     public PostgreSQLForeignKeyInfo(ResultSet JavaDoc rs)
38     {
39         super(rs);
40
41         /*
42          * The PostgreSQL drivers sometimes produce some truly funky metadata.
43          * In this case, the FK_NAME column has been known to have miscellaneous
44          * other strings dangling off the end of it separated by "\000", as in
45          *
46          * WIDGET_FK1\000WIDGET\000BLAH ...
47          *
48          * instead of:
49          *
50          * WIDGET_FK1
51          */

52         int firstBackslashIdx = fkName.indexOf('\\');
53
54         if (firstBackslashIdx > 0)
55             fkName = fkName.substring(0, firstBackslashIdx);
56     }
57 }
58
Popular Tags