001: package net.sourceforge.squirrel_sql.mo.sql;
002:
003: import java.sql.ResultSetMetaData;
004: import java.sql.SQLException;
005:
006: import net.sourceforge.squirrel_sql.fw.sql.TableColumnInfo;
007:
008: public class MockResultSetMetaData implements ResultSetMetaData {
009:
010: TableColumnInfo[] _infos = null;
011:
012: public MockResultSetMetaData(TableColumnInfo[] infos) {
013: _infos = infos;
014: }
015:
016: public String getCatalogName(int arg0) throws SQLException {
017: if (_infos == null || _infos.length <= 0) {
018: return null;
019: }
020: return _infos[0].getCatalogName();
021: }
022:
023: public String getColumnClassName(int arg0) throws SQLException {
024: System.err
025: .println("MockResultSetMetaData.getColumnClassName: stub not yet implemented");
026: return null;
027: }
028:
029: public int getColumnCount() throws SQLException {
030: if (_infos == null || _infos.length <= 0) {
031: return 0;
032: }
033: return _infos.length;
034: }
035:
036: public int getColumnDisplaySize(int arg0) throws SQLException {
037: System.err
038: .println("MockResultSetMetaData.getColumnDisplaySize: stub not yet implemented");
039: return 0;
040: }
041:
042: public String getColumnLabel(int arg0) throws SQLException {
043: System.err
044: .println("MockResultSetMetaData.getColumnLabel: stub not yet implemented");
045: return null;
046: }
047:
048: public String getColumnName(int arg0) throws SQLException {
049: if (_infos == null || _infos.length <= 0) {
050: return null;
051: }
052: return _infos[arg0].getColumnName();
053: }
054:
055: public int getColumnType(int arg0) throws SQLException {
056: // Need to adjust param which is 1-based(JDBC) to a 0-based number for
057: // array access
058: int idx = arg0 - 1;
059: if (_infos == null || _infos.length <= 0
060: || idx >= _infos.length) {
061: return 0;
062: }
063: return _infos[idx].getDataType();
064: }
065:
066: public String getColumnTypeName(int arg0) throws SQLException {
067: // Need to adjust param which is 1-based(JDBC) to a 0-based number for
068: // array access
069: int idx = arg0 - 1;
070: if (_infos == null || _infos.length <= 0
071: || idx >= _infos.length) {
072: return null;
073: }
074: return _infos[idx].getTypeName();
075: }
076:
077: public int getPrecision(int arg0) throws SQLException {
078: // Need to adjust param which is 1-based(JDBC) to a 0-based number for
079: // array access
080: int idx = arg0 - 1;
081: if (_infos == null || _infos.length <= 0
082: || idx >= _infos.length) {
083: return 0;
084: }
085: return _infos[arg0].getColumnSize();
086: }
087:
088: public int getScale(int arg0) throws SQLException {
089: // Need to adjust param which is 1-based(JDBC) to a 0-based number for
090: // array access
091: int idx = arg0 - 1;
092: if (_infos == null || _infos.length <= 0
093: || idx >= _infos.length) {
094: return 0;
095: }
096: return _infos[arg0].getDecimalDigits();
097: }
098:
099: public String getSchemaName(int arg0) throws SQLException {
100: if (_infos == null || _infos.length <= 0) {
101: return null;
102: }
103: return _infos[0].getSchemaName();
104: }
105:
106: public String getTableName(int arg0) throws SQLException {
107: System.err
108: .println("MockResultSetMetaData.getTableName: stub not yet implemented");
109: return null;
110: }
111:
112: public boolean isAutoIncrement(int arg0) throws SQLException {
113: System.err
114: .println("MockResultSetMetaData.isAutoIncrement: stub not yet implemented");
115: return false;
116: }
117:
118: public boolean isCaseSensitive(int arg0) throws SQLException {
119: System.err
120: .println("MockResultSetMetaData.isCaseSensitive: stub not yet implemented");
121: return false;
122: }
123:
124: public boolean isCurrency(int arg0) throws SQLException {
125: System.err
126: .println("MockResultSetMetaData.isCurrency: stub not yet implemented");
127: return false;
128: }
129:
130: public boolean isDefinitelyWritable(int arg0) throws SQLException {
131: System.err
132: .println("MockResultSetMetaData.isDefinitelyWritable: stub not yet implemented");
133: return false;
134: }
135:
136: public int isNullable(int arg0) throws SQLException {
137: if (_infos == null || _infos.length <= 0) {
138: return 0;
139: }
140: return _infos[arg0].isNullAllowed();
141: }
142:
143: public boolean isReadOnly(int arg0) throws SQLException {
144: System.err
145: .println("MockResultSetMetaData.isReadOnly: stub not yet implemented");
146: return false;
147: }
148:
149: public boolean isSearchable(int arg0) throws SQLException {
150: System.err
151: .println("MockResultSetMetaData.isSearchable: stub not yet implemented");
152: return false;
153: }
154:
155: public boolean isSigned(int arg0) throws SQLException {
156: System.err
157: .println("MockResultSetMetaData.isSigned: stub not yet implemented");
158: return false;
159: }
160:
161: public boolean isWritable(int arg0) throws SQLException {
162: System.err
163: .println("MockResultSetMetaData.isWritable: stub not yet implemented");
164: return false;
165: }
166:
167: }
|