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

📄 jco$record.java

📁 SAP这个系统的一个转换器
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                    ((JCO$Table)this).nsureBufferCapacity(num_rows + source.num_rows);
                else
                    ensureBufferCapacity();
                int offset = is_table ? super.boffset[0] + row_length * num_rows : super.boffset[0];
                System.arraycopy(source.data, ((a) (source)).boffset[0], data, offset, source.row_length * source.num_rows);
                offset = is_table ? super.boffset[0] + super.num_odata * num_rows : 0;
                for(int i = 0; i < source.num_rows * ((a) (source)).num_odata; i++)
                    if(source.odata[i] instanceof String)
                        odata[offset + i] = source.odata[i];
                    else
                    if(source.odata[i] instanceof JCO$Record)
                        odata[offset + i] = ((JCO$Record)source.odata[i]).clone();
                    else
                    if(source.odata[i] instanceof byte[])
                        odata[offset + i] = ((byte[])source.odata[i]).clone();
                    else
                        JCO.fireTrace(0, "[JAV-LAYER] JCO.Record.copyFrom() unknown type in " + super.rec_name);

                num_rows = is_table ? num_rows + source.num_rows : 1;
                for(int i = 0; i < super.num_fields; i++)
                    if((((a) (source)).flags[i] & 8) != 0)
                        super.flags[i] |= 8;
                    else
                        super.flags[i] &= 0xf7;

                modified = true;
                return super.num_fields;
            }
        }
        int index[] = new int[((a) (source)).num_fields];
        int irow_save = source.row;
        int jrow_save = row;
        int jnum_rows_save = num_rows;
        boolean modified_save = modified;
        char data_save[] = null;
        Object odata_save[] = null;
        byte opcode_save[] = null;
        byte flags_save[] = null;
        int n;
        try
        {
            int i = 0;
            n = 0;
            for(; i < ((a) (source)).num_fields; i++)
            {
                index[i] = -1;
                for(int j = 0; j < super.num_fields; j++)
                {
                    if(((a) (source)).type[i] != super.type[j] || !((a) (source)).name[i].equals(super.name[j]))
                        continue;
                    index[i] = j;
                    n++;
                    break;
                }

            }

            if(n == 0)
            {
                int l = n;
                return l;
            }
            if(super.flags != null)
            {
                flags_save = new byte[super.flags.length];
                System.arraycopy(super.flags, 0, flags_save, 0, super.flags.length);
            }
            if(data != null)
            {
                data_save = new char[data.length];
                System.arraycopy(data, 0, data_save, 0, data.length);
            }
            if(odata != null)
            {
                odata_save = new Object[odata.length];
                System.arraycopy(((Object) (odata)), 0, ((Object) (odata_save)), 0, odata.length);
            }
            if(opcode != null)
            {
                opcode_save = new byte[opcode.length];
                System.arraycopy(opcode, 0, opcode_save, 0, opcode.length);
            }
            if((rec_type & 4) != 0)
                num_rows += source.num_rows;
            ensureBufferCapacity();
            for(i = 0; i < ((a) (source)).num_fields; i++)
            {
                int j;
                if((j = index[i]) >= 0)
                {
                    row = (rec_type & 4) == 0 ? 0 : jnum_rows_save;
                    int itype = ((a) (source)).type[i];
                    int ioffset = ((a) (source)).boffset[i];
                    int ilength = ((a) (source)).blength[i];
                    int joffset = super.boffset[j] + row * row_length;
                    int jlength = super.blength[j];
                    ilength = Math.min(ilength, jlength);
                    if((((a) (source)).flags[i] & 8) != 0)
                        super.flags[j] |= 8;
                    else
                        super.flags[j] &= 0xf7;
                    for(source.row = 0; source.row < source.num_rows; source.row++)
                    {
                        if(itype == 0)
                        {
                            System.arraycopy(source.data, ioffset, data, joffset, ilength);
                            for(int k = ilength; k < jlength; k++)
                                data[joffset + k] = ' ';

                        } else
                        if(itype == 2)
                            setValue(source.getBigDecimal(i), j);
                        else
                        if(itype == 6)
                            setValue(source.decodeNUM(i), j);
                        else
                        if(itype == 4)
                        {
                            System.arraycopy(source.data, ioffset, data, joffset, ilength);
                            for(int k = ilength; k < jlength; k++)
                                data[joffset + k] = '\0';

                        } else
                        if(itype == 17)
                        {
                            re s = source.getStructure(i);
                            setValue((re)(s != null ? s.clone() : s), j);
                        } else
                        if(itype == 99)
                        {
                            JCO$Table t = source.getTable(i);
                            setValue((setValue)(t != null ? t.clone() : t), j);
                        } else
                        if(itype == 29 || itype == 30)
                            setValue(source.getValue(i), j);
                        else
                            System.arraycopy(source.data, ioffset, data, joffset, ilength);
                        ioffset += source.row_length;
                        joffset += row_length;
                        row++;
                    }

                }
            }

            modified = true;
        }
        catch(on ex)
        {
            row = jrow_save;
            num_rows = jnum_rows_save;
            data = data_save;
            odata = odata_save;
            opcode = opcode_save;
            super.flags = flags_save;
            modified = modified_save;
            source.row = irow_save;
            throw ex;
        }
        finally
        {
            source.row = irow_save;
            row = jrow_save;
        }
        return n;
    }

    public final JCO$Field getField(int index)
    {
        return new JCO$Field(this, index);
    }

    public final String getClassNameOfValue(int index)
    {
        int t = super.type[index];
        switch(t)
        {
        case 0: // '\0'
        case 2: // '\002'
        case 6: // '\006'
        case 29: // '\035'
            return "java.lang.String";

        case 8: // '\b'
        case 9: // '\t'
        case 10: // '\n'
            return "java.lang.Integer";

        case 7: // '\007'
            return "java.lang.Double";

        case 4: // '\004'
        case 30: // '\036'
            return "byte[]";

        case 1: // '\001'
        case 3: // '\003'
            return "java.util.Date";

        case 17: // '\021'
            return "com.sap.mw.jco.JCO.Structure";

        case 99: // 'c'
            return "com.sap.mw.jco.JCO.Table";
        }
        return "java.lang.Object";
    }

    public Object getValue(int index)
    {
        checkRowCapacity();
        int itype = super.type[index];
        if(itype == 0)
            return decodeCHAR(index);
        if(itype == 8 || itype == 10 || itype == 9)
            return new Integer(decodeINT(index));
        if(itype == 7)
            return new Double(decodeFLOAT(index));
        if(itype == 6)
            return decodeNUM(index);
        if(itype == 2)
            return decodeBCD(index);
        if(itype == 1)
            return decodeDATE(index);
        if(itype == 3)
            return decodeTIME(index);
        if(itype == 4)
            return decodeBYTE(index);
        if(itype == 29)
            return decodeSTRING(index);
        if(itype == 30)
            return decodeXSTRING(index);
        if(itype == 17)
            return decodeSTRUCTURE(index);
        if(itype == 99)
            return decodeTABLE(index);
        else
            throw createConversionException(index, "object");
    }

    public String getString(int index)
    {
        checkRowCapacity();
        int itype = super.type[index];
        if(itype == 0 || itype == 99 || itype == 17)
            return decodeCHAR(index);
        if(itype == 8 || itype == 10 || itype == 9)
            return Integer.toString(decodeINT(index));
        if(itype == 7)
            return Double.toString(decodeFLOAT(index));
        if(itype == 6)
            return decodeNUM(index);
        if(itype == 2)
            return decodeBCD(index);
        if(itype == 1)
        {
            String date = decodeCHAR(index);
            if(date != null && date.length() == 8)
            {
                char buffer[] = new char[10];
                date.getChars(0, 4, buffer, 0);
                buffer[4] = '-';
                date.getChars(4, 6, buffer, 5);
                buffer[7] = '-';
                date.getChars(6, 8, buffer, 8);
                return new String(buffer);
            } else
            {
                return date;
            }
        }
        if(itype == 3)
        {
            String time = decodeCHAR(index);
            if(time != null && time.length() == 6)
            {
                char buffer[] = new char[8];
                time.getChars(0, 2, buffer, 0);
                buffer[2] = ':';
                time.getChars(2, 4, buffer, 3);
                buffer[5] = ':';
                time.getChars(4, 6, buffer, 6);
                return new String(buffer);
            } else
            {
                return time;
            }
        }
        if(itype == 4)
            return com.sap.mw.jco.util.Codecs$Hex.encode(decodeBYTE(index));
        if(itype == 29)
            return decodeSTRING(index);
        if(itype == 30)
            return com.sap.mw.jco.util.Codecs$Hex.encode(decodeXSTRING(index));
        else
            throw createConversionException(index, "java.lang.String");
    }

    public char getChar(int index)
    {
        checkRowCapacity();
        boolean conversion_error = false;
        int itype = super.type[index];
        if(itype == 0 || itype == 29)
        {
            String value = itype != 0 ? decodeSTRING(index) : decodeCHAR(index);
            if(value == null || value.length() == 0)
                return ' ';
            if(value.length() == 1)
                return value.charAt(0);
            conversion_error = true;
        } else
        {
            conversion_error = true;
        }
        if(conversion_error)
            throw createConversionException(index, "char");
        else
            return ' ';
    }

    public byte getByte(int index)
    {
        if(super.blength[index] <= 1)
            try
            {
                int itype = super.type[index];
                if(itype == 0 || itype == 29)
                {
                    char c = getChar(index);
                    byte b = (byte)c;
                    if(b == c)
                        return b;
                } else
                {
                    short value = getShort(index);
                    byte casted_value = (byte)value;
                    if(casted_value == value)
                        return casted_value;
                }
            }
            catch(ionException e) { }
        throw createConversionException(index, "byte");
    }

    public final byte getByte(String field_name)
    {
        return getByte(indexOf(field_name));
    }

    public float getFloat(int index)
    {
        try
        {
            double value = getDouble(index);
            return (float)value;
        }
        catch(ionException e)
        {
            throw createConversionException(index, "float");
        }
    }

    public final float getFloat(String field_name)
    {
        return getFloat(indexOf(field_name));
    }

    public short getShort(int index)
    {
        checkRowCapacity();
        boolean conversion_error = false;
        int itype = super.type[index];
        if(itype == 8 || itype == 10 || itype == 9)
        {
            int value = decodeINT(index);
            short casted_value = (short)value;
            if(casted_value != value)
                throw createConversionException(index, "short");
            else
                return casted_value;
        }
        if((itype == 4 || itype == 30) && super.length[index] <= 2)
        {
            byte b[] = itype != 4 ? decodeXSTRING(index) : decodeBYTE(index);
            short value = 0;
            for(int i = 0; i < b.length; i++)
                value = (short)(value << 8 | b[i] & 0xff);

            return value;
        }
        if(itype == 6)
            try

⌨️ 快捷键说明

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