⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sapchartonucbyteconverter.java

📁 SAP这个系统的一个转换器
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   SAPCharToNUCByteConverter.java

package com.sap.mw.jco.util;

import com.sap.mw.jco.JCO;

// Referenced classes of package com.sap.mw.jco.util:
//            BasicSAPConverter, SAPCharToByteConverter

public class SAPCharToNUCByteConverter extends BasicSAPConverter
    implements SAPCharToByteConverter
{

    protected SAPCharToNUCByteConverter(String charEncoding)
    {
        super(charEncoding);
        charLength1ToByteOffset = null;
        charLength1ToByte = null;
        charLength1ToByteLength3 = null;
        charLength2ToByteOffset1 = null;
        charLength2ToByteOffset2 = null;
        charLength2ToByteOffset3 = null;
        charLength2ToByte = null;
        charLength2ToByteLength3 = null;
        if(charEncoding.startsWith("SAP"))
            charEncoding = charEncoding.substring(3);
        if(nativeInitialize(charEncoding) != 0)
        {
            throw new com.sap.mw.jco.JCO.Exception(134, "JCO_ERROR_INITIALIZATION", "Could not initialize SAPCharToByteConverter for codepage " + charEncoding + ".");
        } else
        {
            initialize();
            return;
        }
    }

    protected native int nativeInitialize(String s);

    protected void initialize()
    {
        if(charLength1ToByteOffset != null && charLength1ToByte != null)
        {
            int offset = charLength1ToByteOffset[0];
            int i;
            for(i = 32; i < 127; i++)
                if(charLength1ToByte[(offset | i) * 3] != 1 || charLength1ToByte[(offset | i) * 3 + 1] != i)
                    break;

            if(i == 127)
                super.codepageType = 1;
            else
                super.codepageType = 2;
        }
    }

    protected void setByteArray(byte type, String version, byte array[])
    {
        switch(type)
        {
        case 1: // '\001'
        case 4: // '\004'
        case 5: // '\005'
        case 6: // '\006'
            break;

        case 2: // '\002'
            if("1.0".equals(version))
            {
                charLength1ToByte = array;
                return;
            }
            break;

        case 3: // '\003'
            if("1.0".equals(version))
            {
                charLength1ToByteLength3 = array;
                return;
            }
            break;

        case 7: // '\007'
            if("1.0".equals(version))
            {
                charLength2ToByte = array;
                return;
            }
            break;

        case 8: // '\b'
            if("1.0".equals(version))
            {
                charLength2ToByteLength3 = array;
                return;
            }
            break;

        default:
            return;
        }
        throw new com.sap.mw.jco.JCO.Exception(134, "JCO_ERROR_INITIALIZATION", "Could not initialize SAPCharToByteConverter for codepage " + super.charEncoding + ". SAP Java Connector runtime archive version " + version + " is required.");
    }

    protected void setCharArray(byte type, String version, char array[])
    {
        switch(type)
        {
        case 1: // '\001'
            if("1.0".equals(version))
            {
                charLength1ToByteOffset = array;
                return;
            }
            break;

        case 2: // '\002'
        case 3: // '\003'
        case 5: // '\005'
        case 6: // '\006'
        case 7: // '\007'
        case 8: // '\b'
            break;

        case 4: // '\004'
            if("1.0".equals(version))
            {
                charLength2ToByteOffset1 = array;
                return;
            }
            break;

        default:
            return;
        }
        throw new com.sap.mw.jco.JCO.Exception(134, "JCO_ERROR_INITIALIZATION", "Could not initialize SAPCharToByteConverter for codepage " + super.charEncoding + ". SAP Java Connector runtime archive version " + version + " is required.");
    }

    protected void setIntArray(byte type, String version, int array[])
    {
        switch(type)
        {
        case 1: // '\001'
        case 2: // '\002'
        case 3: // '\003'
        case 4: // '\004'
        case 7: // '\007'
        case 8: // '\b'
            break;

        case 5: // '\005'
            if("1.0".equals(version))
            {
                charLength2ToByteOffset2 = array;
                return;
            }
            break;

        case 6: // '\006'
            if("1.0".equals(version))
            {
                charLength2ToByteOffset3 = array;
                return;
            }
            break;

        default:
            return;
        }
        throw new com.sap.mw.jco.JCO.Exception(134, "JCO_ERROR_INITIALIZATION", "Could not initialize SAPCharToByteConverter for codepage " + super.charEncoding + ". SAP Java Connector runtime archive version " + version + " is required.");
    }

    protected void setLongArray(byte type, String version, long array[])
    {
        switch(type)
        {
        default:
            return;

        case 1: // '\001'
        case 2: // '\002'
        case 3: // '\003'
        case 4: // '\004'
        case 5: // '\005'
        case 6: // '\006'
        case 7: // '\007'
        case 8: // '\b'
            throw new com.sap.mw.jco.JCO.Exception(134, "JCO_ERROR_INITIALIZATION", "Could not initialize SAPCharToByteConverter for codepage " + super.charEncoding + ". SAP Java Connector runtime archive version " + version + " is required.");
        }
    }

    protected void setShortArray(byte type, String version, short array[])
    {
        switch(type)
        {
        default:
            return;

        case 1: // '\001'
        case 2: // '\002'
        case 3: // '\003'
        case 4: // '\004'
        case 5: // '\005'
        case 6: // '\006'
        case 7: // '\007'
        case 8: // '\b'
            throw new com.sap.mw.jco.JCO.Exception(134, "JCO_ERROR_INITIALIZATION", "Could not initialize SAPCharToByteConverter for codepage " + super.charEncoding + ". SAP Java Connector runtime archive version " + version + " is required.");
        }
    }

    public int convert(char in[], int inBeginIndex, int inEndIndex, byte out[], int outBeginIndex, int outEndIndex)
    {
        if(in == null)
            return 0;
        if(inBeginIndex < 0)
            return 0;
        if(inBeginIndex >= in.length)
            return 0;
        if(inEndIndex >= in.length)
            inEndIndex = in.length - 1;
        if(inBeginIndex > inEndIndex)
            return 0;
        if(out == null)
            return 0;
        if(outBeginIndex < 0)
            return 0;
        if(outBeginIndex >= out.length)
            return 0;
        if(outEndIndex >= out.length)
            outEndIndex = out.length - 1;
        if(outBeginIndex > outEndIndex)
            return 0;
        int inIndex = inBeginIndex;
        int outIndex = outBeginIndex;
        while(inIndex <= inEndIndex && outIndex <= outEndIndex) 
        {
            int tabIndex;
            int numBytes;
            if(in[inIndex] >= '\uD800')
                if(in[inIndex] <= '\uDBFF')
                {
                    if(inIndex < inEndIndex && in[inIndex + 1] >= '\uDC00' && in[inIndex + 1] <= '\uDFFF')
                    {
                        tabIndex = (charLength2ToByteOffset3[charLength2ToByteOffset2[charLength2ToByteOffset1[in[inIndex] >> 8] | in[inIndex] & 0xff] | in[inIndex + 1] >> 8] | in[inIndex + 1] & 0xff) * 3;
                        numBytes = charLength2ToByte[tabIndex];
                        if((outIndex + numBytes) - 1 > outEndIndex)
                            break;
                        switch(numBytes)
                        {
                        case 1: // '\001'
                            out[outIndex++] = charLength2ToByte[++tabIndex];
                            break;

⌨️ 快捷键说明

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