typdef.java

来自「derby database source code.good for you.」· Java 代码 · 共 1,231 行 · 第 1/4 页

JAVA
1,231
字号
/*   Derby - Class org.apache.derby.client.net.Typdef   Copyright (c) 2001, 2005 The Apache Software Foundation or its licensors, where applicable.   Licensed under the Apache License, Version 2.0 (the "License");   you may not use this file except in compliance with the License.   You may obtain a copy of the License at      http://www.apache.org/licenses/LICENSE-2.0   Unless required by applicable law or agreed to in writing, software   distributed under the License is distributed on an "AS IS" BASIS,   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   See the License for the specific language governing permissions and   limitations under the License.*/package org.apache.derby.client.net;import org.apache.derby.client.am.Cursor;import org.apache.derby.client.am.DisconnectException;import org.apache.derby.client.am.SignedBinary;////  General Notes//  Descriptors are overriden using two distinct mechanisms//  - new TYPDEFNAM and TYPDEFOVR specifications which override environmental//    specifications originally established at connect time.//  - MDD/SDA pairs providing specific field level overrides for user data//    not conforming to the TYPDEFNAM and TYPDEFOVR specifications currently//    in effect.  Grouping triplets then refer to the new SDAs to specify//    the actual representation of the user data.//  - There are two types of early descriptor triplets, the T and the M triplets.//        Early//        ---------------------------//        Environmental   Grp Row Arr//        TTTTTTTTTTTTT   MMMMMMMMMMM//      - The T triplets are established by the TYPDEFNAM and TYPDEFOVR values.//        These can be overridden for any command or reply by specifying//        a new value for TYPDEFNAM and TYPDEFOVR.//      - The M triplets are established by the MGRLVL parameter on EXCSAT.//        They define PROTOCOL information units such as the SQLCA.//        These grouping and structuring triplets cannot be overriden//        Any change would mean a change in what information was exchanged//        rather than just how that information would be represented.//  - There are two types of late descriptor triplets, the O and U triplets.//        Late//        ---------------------------//        Environmental   Grp Row Arr//        OOOOOOOOOOOOO   UUUUUUUUUUU//      - The O triplets provide specific overrides.//      - The U triplets define actual user data, sometimes in combination//        with PROTOCOL information units.  The U triplets reference O triplets//        and both T triplets and M triplets (which in turn reference T triplets).//   - Rules for assigning LIDs to O triplets//      - select LID within range of 1 to 255.//      - select LID which doesn't interfere with references to early triplets//        or O triplets.////  requirements//  - if this object handles overrides, they are only in effect for one//    command or the reply to one command.  Make sure that the correct//    "in effect" overrides are used especially when MDD overrides are present.//  - raise error if no CCSIDMBC or CCSIDDBC has been specified for mixed or//    double byte data.  Return SQLSTATE 57017 with 0 as source CCSID token.//  Possible errors://  - check for valid lid at SQLAM level.//      - if the lid is greater than the max//        supported lid then the descriptor is invalid for the supported SQLAM level.//  Error Checking and Reporting Notes taken from PROTOCOL manual.//    - If the receiver of an FDODSC finds it in error, the error must//      be reported with a DDM message DSCINVRM.  If the descriptor//      passes PROTOCOL validity checks, but the data does not match the//      descriptors, the mismatch must be reported with a DDM message DTAMCHRM.//      so descriptor must be correct and valid and then the data must match//      the descriptor.//    - Possible General Errors//      - 01 FD:OCA Triplet not used in PROTOCOL descriptors or Type code invalid.//      - 02 Triplet Sequence Error: the two possible sequences are://           1.) GDA,(CPT,)RLO<,RLO><== normal case with no overrrides//           2.) MDD,SDA,(MDD,SDA,)MDD,GDA,(CPT,)\//               MDD,RLO<,MDD,RLO>//               where () indicates an optional repeating group and <> indicates//               a field allowed only when arrays are expected.//      - 03 An array description is required, and this one does not//           describe an array (probably too many or too few RLO triplets).//      - 04 A row description is required, and this one does not describe a row//           probably too many or too few RLO triplets.//      - 05 Late Environmental Descriptor just received not supported (probably//           due to non-support of requested overrides).//      - 06 Malformed triplet; missing required parameter.//      - 07 Parameter value not acceptable.//    - Possible MDD Errors//      - 11 MDD present is not recognized as PROTOCOL Descriptor//      - 12 MDD class not recognized as valid PROTOCOL class.//      - 13 MDD type not recognized as valid PROTOCOL type.//    - Possible SDA Errors//      - 21 Representation incompatible with PROTOCOL type (in prior MDD).//      - 22 CCSID not supported//    - Possible GDA/CPT Errors//      - 32 GDA references a LID that is not an SDA or GDA.//      - 33 GDA length override exceeds limits.//      - 34 GDA precision exceeds limits.//      - 35 GDA scale > precision or scale negative//      - 36 GDA length override missing or incompatible with protocol type.//    - Possible RLO Errors//      - 41 RLO references a LID that is not an RLO or GDA//      - 42 RLO fails to reference a required GDA or RLO (for example, QRYDSC//           must include a reference to SQLCAGRP).////  Nullable SQL and PROTOCOL types are all odd numbers and nullable type is//  one number higher than the related non-nullable type////  earlyTTriplets//  late0Triplets//// typdef endpublic class Typdef implements java.lang.Cloneable {    //---------------------navigational members-----------------------------------    //-----------------------------state------------------------------------------    // double byte character set    static final short CCSIDDBC = 1;    // multi-byte character set    static final short CCSIDMBC = 2;    // single byte character set    static final short CCSIDSBC = 3;    // No CCSID    static final short NOCCSID = 0;    // fixed length    static final short FIXEDLENGTH = 0;    // 2-byte variable length    static final short TWOBYTELENGTH = 1;    // 1-byte variable length    static final short ONEBYTELENGTH = 2;    // decimal length    static final short DECIMALLENGTH = 3;    // lob length    static final short LOBLENGTH = 4;    public static final String UTF8ENCODING = "UTF8";    private static final int OVERRIDE_TABLE_SIZE = 0xff;    private static final int[] fdocaTypeToRepresentationMap_ = {        /* 0x00 */ 0,        /* 0x01 */ Cursor.BYTES, /* FDOCA_TYPE_FIXEDBYTES */        /* 0x02 */ Cursor.VARIABLE_STRING, /* FDOCA_TYPE_VARBYTES */        /* 0x03 */ Cursor.NULL_TERMINATED_BYTES, /* FDOCA_TYPE_NTBYTES */        /* 0x04 */ 0,        /* 0x05 */ 0,        /* 0x06 */ 0,        /* 0x07 */ Cursor.VARIABLE_SHORT_STRING, /* FDOCA_TYPE_PSCLBYTE */        /* 0x08 */ 0,        /* 0x09 */ 0,        /* 0x0A */ 0,        /* 0x0B */ 0,        /* 0x0C */ 0,        /* 0x0D */ 0,        /* 0x0E */ 0,        /* 0x0F */ 0,        /* 0x10 */ Cursor.STRING, /* FDOCA_TYPE_FIXEDCHAR */        /* 0x11 */ Cursor.VARIABLE_STRING, /* FDOCA_TYPE_VARCHAR */        /* 0x12 */ 0,        /* 0x13 */ 0,        /* 0x14 */ Cursor.NULL_TERMINATED_STRING, /* FDOCA_TYPE_NTCHAR */        /* 0x15 */ 0,        /* 0x16 */ 0,        /* 0x17 */ 0,        /* 0x18 */ 0,        /* 0x19 */ Cursor.VARIABLE_SHORT_STRING, /* FDOCA_TYPE_PSCLCHAR */        /* 0x1A */ 0,        /* 0x1B */ 0,        /* 0x1C */ 0,        /* 0x1D */ 0,        /* 0x1E */ 0,        /* 0x1F */ 0,        /* 0x20 */ 0,        /* 0x21 */ 0,        /* 0x22 */ 0,        /* 0x23 */ SignedBinary.BIG_ENDIAN, /* FDOCA_TYPE_INTEGER_BE */        /* 0x24 */ SignedBinary.LITTLE_ENDIAN, /* FDOCA_TYPE_INTEGER_LE */        /* 0x25 */ 0,        /* 0x26 */ 0,        /* 0x27 */ 0,        /* 0x28 */ 0,        /* 0x29 */ 0,        /* 0x2A */ 0,        /* 0x2B */ 0,        /* 0x2C */ 0,        /* 0x2D */ 0,        /* 0x2E */ 0,        /* 0x2F */ 0,        /* 0x30 */ org.apache.derby.client.am.Decimal.PACKED_DECIMAL, /* FDOCA_TYPE_DECIMAL */        /* 0x31 */ 0,        /* 0x32 */ 0,        /* 0x33 */ 0,        /* 0x34 */ 0,        /* 0x35 */ 0,        /* 0x36 */ 0,        /* 0x37 */ 0,        /* 0x38 */ 0,        /* 0x39 */ 0,        /* 0x3A */ 0,        /* 0x3B */ 0,        /* 0x3C */ 0,        /* 0x3D */ 0,        /* 0x3E */ 0,        /* 0x3F */ 0,        /* 0x40 */ 0,        /* 0x41 */ 0,        /* 0x42 */ 0,        /* 0x43 */ 0,        /* 0x44 */ 0,        /* 0x45 */ 0,        /* 0x46 */ 0,        /* 0x47 */ 0,        /* 0x48 */ org.apache.derby.client.am.FloatingPoint.IEEE_754_FLOATING_POINT, /* FDOCA_TYPE_FLOAT_IEEE */        /* 0x49 */ 0,        /* 0x4A */ 0,        /* 0x4B */ 0,        /* 0x4C */ 0,        /* 0x4D */ 0,        /* 0x4E */ 0,        /* 0x4F */ 0,        /* 0x50 */ 0, /* FDOCA_TYPE_LOBBYTES */   // is 0 correct        /* 0x51 */ 0, /* FDOCA_TYPE_LOBCHAR */    // is 0 correct        /* 0x52 */ 0,        /* 0x53 */ 0,        /* 0x54 */ 0,        /* 0x55 */ 0,        /* 0x56 */ 0,        /* 0x57 */ 0,        /* 0x58 */ 0,        /* 0x59 */ 0,        /* 0x5A */ 0,        /* 0x5B */ 0,        /* 0x5C */ 0,        /* 0x5D */ 0,        /* 0x5E */ 0,        /* 0x5F */ 0    };    protected static final FdocaSimpleDataArray[] environmentTables_ = {        /* 0x00 Empties */        null,        /* 0x01 Empties */        null,        /* 0x02 4-byte int */        new FdocaSimpleDataArray(0x02, FdocaConstants.FDOCA_TYPE_INTEGER_BE, SignedBinary.BIG_ENDIAN, NOCCSID, 0, 0, 4, FIXEDLENGTH),        /* 0x03 null 4-byte int */        new FdocaSimpleDataArray(0x03, FdocaConstants.FDOCA_TYPE_NINTEGER_BE, SignedBinary.BIG_ENDIAN, NOCCSID, 0, 0, 4, FIXEDLENGTH),        /* 0x04 2-byte int */        new FdocaSimpleDataArray(0x04, FdocaConstants.FDOCA_TYPE_INTEGER_BE, SignedBinary.BIG_ENDIAN, NOCCSID, 0, 0, 2, FIXEDLENGTH),        /* 0x05 null 2-byte int */        new FdocaSimpleDataArray(0x05, FdocaConstants.FDOCA_TYPE_NINTEGER_BE, SignedBinary.BIG_ENDIAN, NOCCSID, 0, 0, 2, FIXEDLENGTH),        /* 0x06 1-byte int */        new FdocaSimpleDataArray(0x06, FdocaConstants.FDOCA_TYPE_INTEGER_BE, SignedBinary.BIG_ENDIAN, NOCCSID, 0, 0, 1, FIXEDLENGTH),        /* 0x07 null 1-byte int */        new FdocaSimpleDataArray(0x07, FdocaConstants.FDOCA_TYPE_NINTEGER_BE, SignedBinary.BIG_ENDIAN, NOCCSID, 0, 0, 1, FIXEDLENGTH),        /* 0x08 16-byte bin float */        new FdocaSimpleDataArray(0x08, FdocaConstants.FDOCA_TYPE_FLOAT_IEEE, org.apache.derby.client.am.FloatingPoint.IEEE_754_FLOATING_POINT, NOCCSID, 0, 0, 16, FIXEDLENGTH),        /* 0x09 null 16-byte bin float */        new FdocaSimpleDataArray(0x09, FdocaConstants.FDOCA_TYPE_NFLOAT_IEEE, org.apache.derby.client.am.FloatingPoint.IEEE_754_FLOATING_POINT, NOCCSID, 0, 0, 16, FIXEDLENGTH),        /* 0x0A 8-byte bin float */        new FdocaSimpleDataArray(0x0A, FdocaConstants.FDOCA_TYPE_FLOAT_IEEE, org.apache.derby.client.am.FloatingPoint.IEEE_754_FLOATING_POINT, NOCCSID, 0, 0, 8, FIXEDLENGTH),        /* 0x0B null 8-byte bin float */        new FdocaSimpleDataArray(0x0B, FdocaConstants.FDOCA_TYPE_NFLOAT_IEEE, org.apache.derby.client.am.FloatingPoint.IEEE_754_FLOATING_POINT, NOCCSID, 0, 0, 8, FIXEDLENGTH),        /* 0x0C 4-byte bin float */        new FdocaSimpleDataArray(0x0C, FdocaConstants.FDOCA_TYPE_FLOAT_IEEE, org.apache.derby.client.am.FloatingPoint.IEEE_754_FLOATING_POINT, NOCCSID, 0, 0, 4, FIXEDLENGTH),        /* 0x0D null 4-byte bin float */        new FdocaSimpleDataArray(0x0D, FdocaConstants.FDOCA_TYPE_NFLOAT_IEEE, org.apache.derby.client.am.FloatingPoint.IEEE_754_FLOATING_POINT, NOCCSID, 0, 0, 4, FIXEDLENGTH),        /* 0x0E Fixed Decimal */        new FdocaSimpleDataArray(0x0E, FdocaConstants.FDOCA_TYPE_DECIMAL, org.apache.derby.client.am.Decimal.PACKED_DECIMAL, NOCCSID, 0, 0, 31, DECIMALLENGTH),        /* 0x0F null Fixed Decimal */        new FdocaSimpleDataArray(0x0F, FdocaConstants.FDOCA_TYPE_NDECIMAL, org.apache.derby.client.am.Decimal.PACKED_DECIMAL, NOCCSID, 0, 0, 31, DECIMALLENGTH),        /* 0x10 empties */        null,        /* 0x11 empties */        null,        /* 0x12 Numeric */        null,        /* 0x13 null Numeric */        null,        /* 0x14 Empties */        null,        /* 0x15 Empties */        null,        /* 0x16 Big int */        new FdocaSimpleDataArray(0x16, FdocaConstants.FDOCA_TYPE_INTEGER_BE, SignedBinary.BIG_ENDIAN, NOCCSID, 0, 0, 8, FIXEDLENGTH),        /* 0x17 null Big int */        new FdocaSimpleDataArray(0x17, FdocaConstants.FDOCA_TYPE_NINTEGER_BE, SignedBinary.BIG_ENDIAN, NOCCSID, 0, 0, 8, FIXEDLENGTH),        /* 0x18 Large Obj Bytes Loc */        new FdocaSimpleDataArray(0x18, FdocaConstants.FDOCA_TYPE_FIXEDBYTES, 0x00, NOCCSID, 0, 0, 4, FIXEDLENGTH),        /* 0x19 null Large Obj Bytes Loc */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?