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 ProcedureColumnMetaData {
056:
057: private static ResourceBundle rb = ResourceBundle
058: .getBundle(
059: "org.netbeans.modules.visualweb.dataconnectivity.sql.Bundle",
060: Locale.getDefault());
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 PROCEDURE_CAT = new ColIndex(
082: "PROCEDURE_CAT", 0); //NOI18N
083: public static ColIndex PROCEDURE_SCHEM = new ColIndex(
084: "PROCEDURE_SCHEM", 1); //NOI18N
085: public static ColIndex PROCEDURE_NAME = new ColIndex(
086: "PROCEDURE_NAME", 2); //NOI18N
087: public static ColIndex COLUMN_NAME = new ColIndex("COLUMN_NAME", 3); //NOI18N
088: public static ColIndex COLUMN_TYPE = new ColIndex("COLUMN_TYPE", 4); //NOI18N
089: public static ColIndex DATA_TYPE = new ColIndex("DATA_TYPE", 5); //NOI18N
090: public static ColIndex TYPE_NAME = new ColIndex("TYPE_NAME", 6); //NOI18N
091: public static ColIndex PRECISION = new ColIndex("PRECISION", 7); //NOI18N
092: public static ColIndex LENGTH = new ColIndex("LENGTH", 8); //NOI18N
093: public static ColIndex SCALE = new ColIndex("SCALE", 9); //NOI18N
094: public static ColIndex RADIX = new ColIndex("RADIX", 10); //NOI18N
095: public static ColIndex NULLABLE = new ColIndex("NULLABLE", 11); //NOI18N
096: public static ColIndex REMARKS = new ColIndex("REMARKS", 12); //NOI18N
097:
098: private static ColIndex[] metaIndicies = { PROCEDURE_CAT,
099: PROCEDURE_SCHEM, PROCEDURE_NAME, COLUMN_NAME, COLUMN_TYPE,
100: DATA_TYPE, TYPE_NAME, PRECISION, LENGTH, SCALE, RADIX,
101: NULLABLE, REMARKS };
102:
103: private ColumnMetaDataHelper helper = null;
104:
105: ProcedureColumnMetaData(ResultSet resultSet) throws SQLException {
106: helper = new ColumnMetaDataHelper(metaIndicies, resultSet);
107: }
108:
109: public Object getMetaInfo(ColIndex metaIndex) throws SQLException {
110: return helper.getMetaInfo(metaIndex);
111: }
112:
113: public String getMetaInfoAsString(ColIndex metaIndex)
114: throws SQLException {
115: return helper.getMetaInfoAsString(metaIndex);
116: }
117: }
|