KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > jdbc > EmbedResultSetMetaData40


1 /*
2
3    Derby - Class org.apache.derby.impl.jdbc.EmbedResultSetMetaData40
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21 package org.apache.derby.impl.jdbc;
22
23 import java.sql.SQLException JavaDoc;
24
25 import org.apache.derby.iapi.reference.SQLState;
26 import org.apache.derby.iapi.sql.ResultColumnDescriptor;
27
28 public class EmbedResultSetMetaData40 extends EmbedResultSetMetaData {
29     
30     public EmbedResultSetMetaData40(ResultColumnDescriptor[] columnInfo) {
31         super(columnInfo);
32     }
33     
34     /**
35      * Returns false unless <code>interfaces</code> is implemented
36      *
37      * @param interfaces a Class defining an interface.
38      * @return true if this implements the interface or
39      * directly or indirectly wraps an object
40      * that does.
41      * @throws java.sql.SQLException if an error occurs while determining
42      * whether this is a wrapper for an object
43      * with the given interface.
44      */

45     public boolean isWrapperFor(Class JavaDoc<?> interfaces) throws SQLException JavaDoc {
46         return interfaces.isInstance(this);
47     }
48     
49     /**
50      * Returns <code>this</code> if this class implements the interface
51      *
52      * @param interfaces a Class defining an interface
53      * @return an object that implements the interface
54      * @throws java.sql.SQLExption if no object if found that implements the
55      * interface
56      */

57    public <T> T unwrap(java.lang.Class JavaDoc<T> interfaces)
58                             throws SQLException JavaDoc{
59         //Derby does not implement non-standard methods on
60
//JDBC objects
61
//hence return this if this class implements the interface
62
//or throw an SQLException
63
try {
64             return interfaces.cast(this);
65         } catch (ClassCastException JavaDoc cce) {
66             throw Util.generateCsSQLException(SQLState.UNABLE_TO_UNWRAP,
67                     interfaces);
68         }
69     }
70 }
71
Popular Tags