001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: package org.netbeans.modules.visualweb.dataconnectivity.sql;
042:
043: import java.sql.ResultSet;
044: import java.sql.SQLException;
045: import java.util.Locale;
046: import java.util.ResourceBundle;
047:
048: /**
049: *
050: * just in time Column data used by servernavigator and other clients
051: * cached after retrieved
052: *
053: * @author John Kline
054: */
055: public class ColumnMetaData {
056: /*
057:
058: private static ResourceBundle rb = ResourceBundle.getBundle("org.netbeans.modules.visualweb.dataconnectivity.sql.Bundle",
059: Locale.getDefault());
060: */
061:
062: public static class ColIndex implements
063: ColumnMetaDataHelper.MetaIndex {
064: private String name;
065: private int index;
066:
067: private ColIndex(String name, int index) {
068: this .name = name;
069: this .index = index;
070: }
071:
072: public String getName() {
073: return name;
074: };
075:
076: public int getIndex() {
077: return index;
078: };
079: }
080:
081: public static ColIndex TABLE_CAT = new ColIndex("TABLE_CAT", 0);
082: public static ColIndex TABLE_SCHEM = new ColIndex("TABLE_SCHEM", 1);
083: public static ColIndex TABLE_NAME = new ColIndex("TABLE_NAME", 2);
084: public static ColIndex COLUMN_NAME = new ColIndex("COLUMN_NAME", 3);
085: public static ColIndex DATA_TYPE = new ColIndex("DATA_TYPE", 4);
086: public static ColIndex TYPE_NAME = new ColIndex("TYPE_NAME", 5);
087: public static ColIndex COLUMN_SIZE = new ColIndex("COLUMN_SIZE", 6);
088: public static ColIndex BUFFER_LENGTH = new ColIndex(
089: "BUFFER_LENGTH", 7);
090: public static ColIndex DECIMAL_DIGITS = new ColIndex(
091: "DECIMAL_DIGITS", 8);
092: public static ColIndex NUM_PREC_RADIX = new ColIndex(
093: "NUM_PREC_RADIX", 9);
094: public static ColIndex NULLABLE = new ColIndex("NULLABLE", 10);
095: public static ColIndex REMARKS = new ColIndex("REMARKS", 11);
096: public static ColIndex COLUMN_DEF = new ColIndex("COLUMN_DEF", 12);
097: public static ColIndex SQL_DATA_TYPE = new ColIndex(
098: "SQL_DATA_TYPE", 13);
099: public static ColIndex SQL_DATETIME_SUB = new ColIndex(
100: "SQL_DATETIME_SUB", 14);
101: public static ColIndex CHAR_OCTET_LENGTH = new ColIndex(
102: "CHAR_OCTET_LENGTH", 15);
103: public static ColIndex ORDINAL_POSITION = new ColIndex(
104: "ORDINAL_POSITION", 16);
105: public static ColIndex IS_NULLABLE = new ColIndex("IS_NULLABLE", 17);
106: public static ColIndex SCOPE_CATALOG = new ColIndex(
107: "SCOPE_CATALOG", 18);
108: public static ColIndex SCOPE_SCHEMA = new ColIndex("SCOPE_SCHEMA",
109: 19);
110: public static ColIndex SCOPE_TABLE = new ColIndex("SCOPE_TABLE", 20);
111: public static ColIndex SOURCE_DATA_TYPE = new ColIndex(
112: "SOURCE_DATA_TYPE", 21);
113:
114: private static ColIndex[] metaIndicies = { TABLE_CAT, TABLE_SCHEM,
115: TABLE_NAME, COLUMN_NAME, DATA_TYPE, TYPE_NAME, COLUMN_SIZE,
116: BUFFER_LENGTH, DECIMAL_DIGITS, NUM_PREC_RADIX, NULLABLE,
117: REMARKS, COLUMN_DEF, SQL_DATA_TYPE, SQL_DATETIME_SUB,
118: CHAR_OCTET_LENGTH, ORDINAL_POSITION, IS_NULLABLE,
119: SCOPE_CATALOG, SCOPE_SCHEMA, SCOPE_TABLE, SOURCE_DATA_TYPE };
120:
121: private ColumnMetaDataHelper helper = null;
122:
123: ColumnMetaData(ResultSet resultSet) throws SQLException {
124: helper = new ColumnMetaDataHelper(metaIndicies, resultSet);
125: }
126:
127: public Object getMetaInfo(ColIndex metaIndex) throws SQLException {
128: return helper.getMetaInfo(metaIndex);
129: }
130:
131: public String getMetaInfoAsString(ColIndex metaIndex)
132: throws SQLException {
133: return helper.getMetaInfoAsString(metaIndex);
134: }
135: }
|