typdef.java

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

JAVA
1,231
字号
    private void initialize(NetAgent netAgent,                            int ccsidSbc,                            boolean ccsidSbcSet,                            int ccsidMbc,                            boolean ccsidMbcSet,                            int ccsidDbc,                            boolean ccsidDbcSet,                            String typdefnam) throws DisconnectException {        netAgent_ = netAgent;        ccsidSbc_ = ccsidSbc;        ccsidSbcSet_ = ccsidSbcSet;        ccsidSbcEncoding_ = null;        ccsidMbc_ = ccsidMbc;        ccsidMbcSet_ = ccsidMbcSet;        ccsidMbcEncoding_ = null;        ccsidDbc_ = ccsidDbc;        ccsidDbcSet_ = ccsidDbcSet;        ccsidDbcEncoding_ = null;        setTypdefnam(typdefnam);    }    //-------------------------private and package friendly methods---------------    String getTypdefnam() {        return typdefnam_;    }    void setTypdefnam(String typdefnam) throws DisconnectException {        typdefnam_ = typdefnam;        if (typdefnam_ == null) {            return;        }    }    int getCcsidSbc() {        return ccsidSbc_;    }    void setCcsidSbc(int ccsid) {        ccsidSbc_ = ccsid;        ccsidSbcSet_ = true;        ccsidSbcEncoding_ = null;    }    void clearCcsidSbc() {        ccsidSbc_ = 0;        ccsidSbcSet_ = false;        ccsidSbcEncoding_ = null;    }    boolean isCcsidSbcSet() {        return ccsidSbcSet_;    }    // analyze exception handling some more here    String getCcsidSbcEncoding() throws DisconnectException {        if (ccsidSbcEncoding_ == null) {            ccsidSbcEncoding_ = UTF8ENCODING;        }        return ccsidSbcEncoding_;    }    int getCcsidDbc() {        return ccsidDbc_;    }    void setCcsidDbc(int ccsid) {        ccsidDbc_ = ccsid;        ccsidDbcSet_ = true;        ccsidDbcEncoding_ = null;    }    void clearCcsidDbc() {        ccsidDbc_ = 0;        ccsidDbcSet_ = false;        ccsidDbcEncoding_ = null;    }    boolean isCcsidDbcSet() {        return ccsidDbcSet_;    }    // analyze exception handling some more here    String getCcsidDbcEncoding() throws DisconnectException {        if (ccsidDbcEncoding_ == null) {            ccsidDbcEncoding_ = UTF8ENCODING;        }        return ccsidDbcEncoding_;    }    int getCcsidMbc() {        return ccsidMbc_;    }    void setCcsidMbc(int ccsid) {        ccsidMbc_ = ccsid;        ccsidMbcSet_ = true;        ccsidMbcEncoding_ = null;    }    void clearCcsidMbc() {        ccsidMbc_ = 0;        ccsidMbcSet_ = false;        ccsidMbcEncoding_ = null;    }    boolean isCcsidMbcSet() {        return ccsidMbcSet_;    }    // analyze exception handling some more here    String getCcsidMbcEncoding() throws DisconnectException {        if (ccsidMbcEncoding_ == null) {            ccsidMbcEncoding_ = UTF8ENCODING;        }        return ccsidMbcEncoding_;    }    int getByteOrder() {        return SignedBinary.BIG_ENDIAN;    }    public Object clone() {        try {            return super.clone();        } catch (java.lang.CloneNotSupportedException e) {            return null; // this shouldn't happen since we implement the cloneable interface        }    }    // Populates netCursor descriptors, rename this populateCursorDescriptors()    void updateColumn(NetCursor netCursor,                      int columnIndex,                      int protocolLid,                      int protocolLength) throws DisconnectException {        FdocaSimpleDataArray sda = environmentTables_[protocolLid];        if ((mddOverride_) && (overrideTable_[protocolLid] != null)) {            sda = overrideTable_[protocolLid];        }        if (sda == null) {            netAgent_.accumulateChainBreakingReadExceptionAndThrow(new DisconnectException(netAgent_,                    "Invalid FDOCA LID"));        }        // 2. Set Null indicator based on PROTOCOL Type.        //    Nullable SQL and PROTOCOL types are all odd numbers and the nullable        //    type is one number higher than the related non-nullable type.        netCursor.nullable_[columnIndex] = ((sda.protocolType_ % 2) == 1);        // 3. Update CCSID        //    The typdef object should store the java encoding,        switch (sda.ccsid_) {        case CCSIDSBC:            netCursor.charsetName_[columnIndex] = getCcsidSbcEncoding();            netCursor.ccsid_[columnIndex] = this.ccsidSbc_;            break;        case CCSIDMBC:            if (isCcsidMbcSet() && (ccsidMbc_ != 0)) {                netCursor.charsetName_[columnIndex] = getCcsidMbcEncoding();                netCursor.ccsid_[columnIndex] = ccsidMbc_;            } else {                // if the server didn't return a mixed byte ccsid, set both the                // encoding and the btc reference to null. see CCSIDDBC comment below.                netCursor.charsetName_[columnIndex] = null;                netCursor.ccsid_[columnIndex] = 0;            }            break;        case CCSIDDBC:            if (isCcsidDbcSet() && (ccsidDbc_ != 0)) {                netCursor.charsetName_[columnIndex] = getCcsidDbcEncoding();                netCursor.ccsid_[columnIndex] = this.ccsidDbc_;            } else {                // if the server didn't return a double byte ccsid, set both the                // encoding and the btc reference to null.  later an exception will                // be thrown on the getXXX method.  calling the getCcsidDbcEncoding method                // will throw the exception here and this is not desirable.                netCursor.charsetName_[columnIndex] = null;                netCursor.ccsid_[columnIndex] = 0;            }            break;        default:   // This default case is used for mdd override ccsids.            // In this case the sda.ccsid_ is the actual native ccsid,            // otherwise the sda.ccsid_ is a placeholder:            //  CCSIDMBC, CCSIDDDBC, CCSIDSBC to indicate that            // the actual ccsid is the connection's ccsid (in protocol lingo the connection's typdef ccsid).            netCursor.charsetName_[columnIndex] = UTF8ENCODING;            netCursor.ccsid_[columnIndex] = sda.ccsid_;            break;        }        // 5. Set the length fdoca length.        //    For some types this may be a precision and a scale.        //    this includes FIXED DECIMAL (PROTOCOL type 0x0E, 0X0F),        // retain the high order placeholder for lobs)        // this includes LARGE OBJECT BYTES (PROTOCOL type 0xC8, 0xC9)        //               LARGE OBJECT CHAR SBCS (PROTOCOL type 0xCA, 0xCB)        //               LARGE OBJECT CHAR DBCS (PROTOCOL type 0xCC, 0xCD)        //               LARGE OBJECT CHAR MIXED (PROTOCOL type 0xCE, 0xCF)        // also set the hasLobs_ flag to true        if ((sda.protocolType_ >= 0xC8) && (sda.protocolType_ <= 0xCF)) {            // retain placeholder information            // right now just set the length...            // probably need to accomodate for the high order placeholder bit            netCursor.fdocaLength_[columnIndex] = protocolLength;            netCursor.hasLobs_ = true;        } else {            netCursor.fdocaLength_[columnIndex] = protocolLength;        }        // 6. Set jdbc type.        netCursor.jdbcTypes_[columnIndex] = protocolToJdbcTypes_[sda.protocolType_];        // 7. Get the number of bytes to read for variable length data.        netCursor.typeToUseForComputingDataLength_[columnIndex] = sda.typeToUseForComputingDataLength_;        // 8. Update the maximumRowSize        // Count : column null indicator +        //         column length +        //         posibly a 2-byte length for varchar columns        switch (netCursor.typeToUseForComputingDataLength_[columnIndex]) {        case DECIMALLENGTH:            netCursor.maximumRowSize_ += 1 + 16;            break;        case LOBLENGTH:            netCursor.maximumRowSize_ += 1 + (netCursor.fdocaLength_[columnIndex] & 0x7fff);            break;        default:            netCursor.maximumRowSize_ += 1 + netCursor.fdocaLength_[columnIndex] + 2; // 2 is the length indicator for varchar            break;        }        // 9. Get the character size.        if (sda.characterSize_ == 2) {            netCursor.isGraphic_[columnIndex] = true;        }    }    // Called before the code parses a descriptor    void clearMddOverrides() {        if (mddOverride_ == false) {            return;        }        mddOverride_ = false;        for (int i = 0; i < OVERRIDE_TABLE_SIZE; i++) {            overrideTable_[i] = null;        }    }    // Called after the code parses a descriptor    void setMddOverride(int protocolType,                        int fdocaTripletLid,                        int fdocaFieldType,                        int ccsid,                        int characterSize,                        int mode,                        int length) {        mddOverride_ = true;        if (overrideTable_[fdocaTripletLid] == null) {            overrideTable_[fdocaTripletLid] = new FdocaSimpleDataArray                    (protocolType,                            fdocaFieldType,                            fdocaTypeToRepresentationMap_[fdocaFieldType & 0x7f],                            ccsid,                            characterSize,                            mode,                            length,                            mapFdocaTypeToTypeToUseForComputingDataLength(fdocaFieldType));        } else {            overrideTable_[fdocaTripletLid].update(protocolType,                    fdocaFieldType,                    fdocaTypeToRepresentationMap_[fdocaFieldType & 0x7f],                    ccsid,                    characterSize,                    mode,                    length,                    mapFdocaTypeToTypeToUseForComputingDataLength(fdocaFieldType));        }    }    private int mapFdocaTypeToTypeToUseForComputingDataLength(int fdocaFieldType) {        switch (fdocaFieldType & 0x7f) { // &0x7f masks out the null indicator        case FdocaConstants.FDOCA_TYPE_VARCHAR:        case FdocaConstants.FDOCA_TYPE_VARBYTES:            return Typdef.TWOBYTELENGTH;        case FdocaConstants.FDOCA_TYPE_DECIMAL:        case FdocaConstants.FDOCA_TYPE_NUMERIC_CHAR:            return Typdef.DECIMALLENGTH;        case FdocaConstants.FDOCA_TYPE_LOBBYTES:        case FdocaConstants.FDOCA_TYPE_LOBCHAR:            return Typdef.LOBLENGTH;        case FdocaConstants.FDOCA_TYPE_PSCLBYTE:        case FdocaConstants.FDOCA_TYPE_PSCLCHAR:            return Typdef.ONEBYTELENGTH;        default:            return 0;        }    }}

⌨️ 快捷键说明

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