KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Copyright 2004 (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: SAPDBTypeInfo.java,v 1.1 2004/03/22 04:58:13 jackknifebarber Exp $
9  */

10
11 package com.triactive.jdo.store;
12
13 import java.sql.ResultSet JavaDoc;
14 import java.sql.Types JavaDoc;
15
16
17 /**
18  * Represents the metadata of a SAP DB data type.
19  *
20  * @author <a HREF="mailto:mmartin5@austin.rr.com">Mike Martin</a>
21  * @version $Revision: 1.1 $
22  */

23
24 class SAPDBTypeInfo extends TypeInfo
25 {
26     /**
27      * Constructs a type information object from the current row of the given
28      * result set. The {@link ResultSet} object passed must have been obtained
29      * from a call to DatabaseMetaData.getTypeInfo().
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.getTypeInfo().
35      */

36
37     public SAPDBTypeInfo(ResultSet JavaDoc rs)
38     {
39         super(rs);
40     }
41
42
43     public boolean isCompatibleWith(ColumnInfo colInfo)
44     {
45         if (super.isCompatibleWith(colInfo))
46             return true;
47
48         if (isVarBinaryType(dataType) && isVarBinaryType(colInfo.dataType))
49             return true;
50
51         return false;
52     }
53
54
55     /**
56      * Tests whether or not the given JDBC type is an SAP DB "varbinary" type.
57      * <p>
58      * This method equates VARBINARY and LONGVARBINARY because we currently
59      * discourage use of the former (it doesn't behave as a true binary).
60      */

61
62     private static boolean isVarBinaryType(int type)
63     {
64         switch (type)
65         {
66             case Types.VARBINARY:
67             case Types.LONGVARBINARY:
68                 return true;
69
70             default:
71                 return false;
72         }
73     }
74 }
75
Popular Tags