001: package net.sourceforge.squirrel_sql.fw.sql.dbobj.adapter;
002:
003: /*
004: * Copyright (C) 2004 Colin Bell
005: * colbell@users.sourceforge.net
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2.1 of the License, or (at your option) any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this library; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: */
021: import java.sql.DatabaseMetaData;
022:
023: import net.sourceforge.squirrel_sql.fw.sql.dbobj.BestRowIdentifier;
024: import net.sourceforge.squirrel_sql.fw.util.StringManager;
025: import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
026:
027: /**
028: * View of a <tt>BestRowIdentifier</tt> object to be displayed.
029: *
030: * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
031: */
032: public class BestRowIdentifierAdapter {
033: /** Internationalized strings for this class. */
034: private static final StringManager s_stringMgr = StringManagerFactory
035: .getStringManager(BestRowIdentifierAdapter.class);
036:
037: /**
038: * Property names for this bean.
039: */
040: public interface IPropertyNames {
041: String COLUMN_NAME = "columnName";
042: String PRECISION = "precision";
043: String PSEUDO = "pseudoColumn";
044: String SCALE = "scale";
045: String SCOPE = "scope";
046: String SQL_DATA_TYPE = "sqlDataType";
047: String TYPE_NAME = "typeName";
048: }
049:
050: private final BestRowIdentifier _viewObj;
051:
052: public BestRowIdentifierAdapter(BestRowIdentifier obj) {
053: if (obj == null) {
054: throw new IllegalArgumentException(
055: "BestRowIdentifier == null");
056: }
057: _viewObj = obj;
058: }
059:
060: public String getColumnName() {
061: return _viewObj.getColumnName();
062: }
063:
064: public short getSQLDataType() {
065: return _viewObj.getSQLDataType();
066: }
067:
068: public String getTypeName() {
069: return _viewObj.getTypeName();
070: }
071:
072: public int getPrecision() {
073: return _viewObj.getPrecision();
074: }
075:
076: public short getScale() {
077: return _viewObj.getScale();
078: }
079:
080: public String getScope() {
081: final int scope = _viewObj.getScope();
082: switch (scope) {
083: case DatabaseMetaData.bestRowTemporary:
084: return s_stringMgr
085: .getString("BestRowIdentifierAdapter.temporary");
086: case DatabaseMetaData.bestRowTransaction:
087: return s_stringMgr
088: .getString("BestRowIdentifierAdapter.transaction");
089: case DatabaseMetaData.bestRowSession:
090: return s_stringMgr
091: .getString("BestRowIdentifierAdapter.session");
092: default:
093: return s_stringMgr
094: .getString("BestRowIdentifierAdapter.unknown");
095: }
096: }
097:
098: public String getPseudoColumn() {
099: final short value = _viewObj.getPseudoColumn();
100: switch (value) {
101: case DatabaseMetaData.bestRowPseudo:
102: return s_stringMgr
103: .getString("BestRowIdentifierAdapter.pseudo");
104: case DatabaseMetaData.bestRowNotPseudo:
105: return s_stringMgr
106: .getString("BestRowIdentifierAdapter.notPseudo");
107: case DatabaseMetaData.bestRowUnknown:
108: return s_stringMgr
109: .getString("BestRowIdentifierAdapter.unknownPseudo");
110: default:
111: return s_stringMgr
112: .getString("BestRowIdentifierAdapter.unknown");
113: }
114: }
115:
116: }
|