001: /*
002:
003: Derby - Class org.apache.derby.iapi.types.DTSClassInfo
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to you under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derby.iapi.types;
023:
024: import org.apache.derby.iapi.services.io.StoredFormatIds;
025: import org.apache.derby.iapi.services.io.FormatableInstanceGetter;
026:
027: public class DTSClassInfo extends FormatableInstanceGetter {
028:
029: public Object getNewInstance() {
030:
031: // Does not handle StoredFormatIds.SQL_DECIMAL_ID as
032: // different implementations are required for different VMs.
033:
034: switch (fmtId) {
035: /* Wrappers */
036: case StoredFormatIds.SQL_BIT_ID:
037: return new SQLBit();
038: case StoredFormatIds.SQL_BOOLEAN_ID:
039: return new SQLBoolean();
040: case StoredFormatIds.SQL_CHAR_ID:
041: return new SQLChar();
042: case StoredFormatIds.SQL_DATE_ID:
043: return new SQLDate();
044: case StoredFormatIds.SQL_DOUBLE_ID:
045: return new SQLDouble();
046: case StoredFormatIds.SQL_INTEGER_ID:
047: return new SQLInteger();
048: case StoredFormatIds.SQL_LONGINT_ID:
049: return new SQLLongint();
050: case StoredFormatIds.SQL_NATIONAL_CHAR_ID:
051: return new SQLNationalChar();
052: case StoredFormatIds.SQL_NATIONAL_LONGVARCHAR_ID:
053: return new SQLNationalLongvarchar();
054: case StoredFormatIds.SQL_NATIONAL_VARCHAR_ID:
055: return new SQLNationalVarchar();
056: case StoredFormatIds.SQL_REAL_ID:
057: return new SQLReal();
058: case StoredFormatIds.SQL_REF_ID:
059: return new SQLRef();
060: case StoredFormatIds.SQL_SMALLINT_ID:
061: return new SQLSmallint();
062: case StoredFormatIds.SQL_TIME_ID:
063: return new SQLTime();
064: case StoredFormatIds.SQL_TIMESTAMP_ID:
065: return new SQLTimestamp();
066: case StoredFormatIds.SQL_TINYINT_ID:
067: return new SQLTinyint();
068: case StoredFormatIds.SQL_VARCHAR_ID:
069: return new SQLVarchar();
070: case StoredFormatIds.SQL_LONGVARCHAR_ID:
071: return new SQLLongvarchar();
072: case StoredFormatIds.SQL_VARBIT_ID:
073: return new SQLVarbit();
074: case StoredFormatIds.SQL_LONGVARBIT_ID:
075: return new SQLLongVarbit();
076: case StoredFormatIds.SQL_USERTYPE_ID_V3:
077: return new UserType();
078: case StoredFormatIds.SQL_BLOB_ID:
079: return new SQLBlob();
080: case StoredFormatIds.SQL_CLOB_ID:
081: return new SQLClob();
082: case StoredFormatIds.SQL_NCLOB_ID:
083: return new SQLNClob();
084: case StoredFormatIds.XML_ID:
085: return new XML();
086:
087: /* Type ids */
088: case StoredFormatIds.BIT_TYPE_ID:
089: case StoredFormatIds.BOOLEAN_TYPE_ID:
090: case StoredFormatIds.CHAR_TYPE_ID:
091: case StoredFormatIds.DATE_TYPE_ID:
092: case StoredFormatIds.DECIMAL_TYPE_ID:
093: case StoredFormatIds.DOUBLE_TYPE_ID:
094: case StoredFormatIds.INT_TYPE_ID:
095: case StoredFormatIds.LONGINT_TYPE_ID:
096: case StoredFormatIds.LONGVARBIT_TYPE_ID:
097: case StoredFormatIds.LONGVARCHAR_TYPE_ID:
098: case StoredFormatIds.NATIONAL_CHAR_TYPE_ID:
099: case StoredFormatIds.NATIONAL_LONGVARCHAR_TYPE_ID:
100: case StoredFormatIds.NATIONAL_VARCHAR_TYPE_ID:
101: case StoredFormatIds.REAL_TYPE_ID:
102: case StoredFormatIds.REF_TYPE_ID:
103: case StoredFormatIds.SMALLINT_TYPE_ID:
104: case StoredFormatIds.TIME_TYPE_ID:
105: case StoredFormatIds.TIMESTAMP_TYPE_ID:
106: case StoredFormatIds.TINYINT_TYPE_ID:
107: case StoredFormatIds.USERDEFINED_TYPE_ID_V3:
108: case StoredFormatIds.VARBIT_TYPE_ID:
109: case StoredFormatIds.VARCHAR_TYPE_ID:
110: case StoredFormatIds.BLOB_TYPE_ID:
111: case StoredFormatIds.CLOB_TYPE_ID:
112: case StoredFormatIds.NCLOB_TYPE_ID:
113: case StoredFormatIds.XML_TYPE_ID:
114: return new TypeId(fmtId);
115: default:
116: return null;
117: }
118:
119: }
120: }
|