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

📄 gzipinputstream.java

📁 SyncML的java实现类库 funambol公司发布的
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

package com.tinyline.util;

import java.io.IOException;
import java.io.InputStream;

public class GZIPInputStream extends InputStream
{

    public GZIPInputStream(InputStream inputstream, int i1)
        throws IOException
    {
        _fldvoid = new byte[1];
        J = 32768;
        af = 32767;
        ap = new byte[32768];
        v = inputstream;
        a(true);
        W = 0;
        if(i1 <= 0)
        {
            throw new IOException("size <= 0");
        } else
        {
            x = new byte[i1];
            return;
        }
    }

    public GZIPInputStream(InputStream inputstream)
        throws IOException
    {
        this(inputstream, 512);
    }

    public int read(byte abyte0[], int i1, int j1)
        throws IOException
    {
        if(!y)
            _mthnull();
        if(l)
            return -1;
        j1 = _mthfor(abyte0, i1, j1);
        if(_mthbyte())
            _mthchar();
        return j1;
    }

    public int read()
        throws IOException
    {
        return read(_fldvoid, 0, 1) != -1 ? _fldvoid[0] & 0xff : -1;
    }

    public int read(byte abyte0[])
        throws IOException
    {
        return read(abyte0, 0, abyte0.length);
    }

    public void close()
        throws IOException
    {
        v.close();
    }

    public long skip(long l1)
        throws IOException
    {
        if(l1 < 0L)
            throw new IOException("negative skip length");
        byte abyte0[] = new byte[512];
        long l2 = 0L;
        do
        {
            if(l2 >= l1)
                break;
            long l3 = l1 - l2;
            l3 = read(abyte0, 0, l3 >= (long)abyte0.length ? abyte0.length : (int)l3);
            if(l3 == -1L)
            {
                l = true;
                break;
            }
            l2 += l3;
        } while(true);
        return l2;
    }

    public int available()
        throws IOException
    {
        return _mthbyte() ? 0 : 1;
    }

    public synchronized void mark(int i1)
    {
        v.mark(i1);
    }

    public synchronized void reset()
        throws IOException
    {
        v.reset();
    }

    public boolean markSupported()
    {
        return v.markSupported();
    }

    private void _mthnull()
        throws IOException
    {
        int k2;
label0:
        {
            int i1 = v.read();
            if(i1 < 0)
            {
                l = true;
                return;
            }
            int j1 = v.read();
            if(i1 != U[0] || j1 != U[1])
                throw new IOException("Not in GZIP format");
            int j2 = v.read();
            k2 = v.read();
            if(j2 != 8 || (k2 & 0xe0) != 0)
                throw new IOException("Corrupt GZIP header");
            for(int l2 = 0; l2 < 6; l2++)
                if(v.read() < 0)
                    throw new IOException("Corrupt GZIP header");

            if((k2 & 4) == 0)
                break label0;
            int i3 = v.read();
            if(i3 < 0)
                throw new IOException("Corrupt GZIP header");
            int k1 = v.read();
            if(k1 < 0)
                throw new IOException("Corrupt GZIP header");
            i3 += k1 << 8;
            do
            {
                if(i3-- == 0)
                    break label0;
                k1 = v.read();
            } while(k1 >= 0);
            throw new IOException("Corrupt GZIP header");
        }
        int l1;
        if((k2 & 8) != 0)
            while((l1 = v.read()) != 0) 
                if(l1 < 0)
                    throw new IOException("Corrupt GZIP header");
        if((k2 & 0x10) != 0)
            while((l1 = v.read()) != 0) 
                if(l1 < 0)
                    throw new IOException("Corrupt GZIP header");
        if((k2 & 2) != 0)
        {
            for(int j3 = 0; j3 < 2; j3++)
            {
                int i2 = v.read();
                if(i2 < 0)
                    throw new IOException("Corrupt GZIP header");
            }

        }
        y = true;
    }

    private void _mthchar()
        throws IOException
    {
        byte abyte0[] = new byte[8];
        int j1 = _mthcase();
        if(j1 > 8)
            j1 = 8;
        System.arraycopy(x, W - _mthcase(), abyte0, 0, j1);
        int l1;
        for(int k1 = 8 - j1; k1 > 0; k1 -= l1)
        {
            l1 = v.read(abyte0, 8 - k1, k1);
            if(l1 <= 0)
                throw new IOException("Corrupt GZIP trailer");
        }

        int i1 = abyte0[4] & 0xff | (abyte0[5] & 0xff) << 8 | (abyte0[6] & 0xff) << 16 | abyte0[7] << 24;
        if(i1 != a())
        {
            throw new IOException("Corrupt GZIP trailer");
        } else
        {
            l = true;
            return;
        }
    }

    private int _mthfor(byte abyte0[], int i1, int j1)
        throws IOException
    {
        do
        {
            do
            {
                int k1 = _mthdo(abyte0, i1, j1);
                if(k1 > 0)
                    return k1;
                if(_mthlong() || _mthbyte())
                    return -1;
            } while(_fldgoto != _fldint);
            _mthif();
        } while(true);
    }

    private int _mthcase()
    {
        return (_fldint - _fldgoto) + (K >> 3);
    }

    private int _mthnew()
    {
        return al - _mthcase();
    }

    private int _mthtry()
    {
        return _mthlong() ? o : D;
    }

    protected void _mthif()
        throws IOException
    {
        int i1 = 0;
        W = v.read(x, i1, x.length);
        if(W < 0)
            throw new IOException("Unexpected end of ZLIB input stream");
        if(_fldgoto < _fldint)
            throw new IOException("Internal State Error");
        int j1 = i1 + W;
        if(0 > i1 || i1 > j1 || j1 > x.length)
            throw new IOException("Internal State Error");
        if((W & 1) != 0)
        {
            G |= (x[i1++] & 0xff) << K;
            K += 8;
        }
        aA = x;
        _fldgoto = i1;
        _fldint = j1;
        al += W;
    }

    private boolean _mthlong()
    {
        return T == 1 && C == 0;
    }

    private boolean _mthbyte()
    {
        return T == 12 && _fldcase == 0;
    }

    private int a()
    {
        return at;
    }

    private final int _mthdo(int i1)
    {
        if(K < i1)
        {
            if(_fldgoto == _fldint)
                return -1;
            G |= (aA[_fldgoto++] & 0xff | (aA[_fldgoto++] & 0xff) << 8) << K;
            K += 16;
        }
        return G & (1 << i1) - 1;
    }

    private final void _mthif(int i1)
    {
        G >>>= i1;
        K -= i1;
    }

    private void _mthdo()
    {
        G >>= K & 7;
        K &= -8;
    }

    private int a(byte abyte0[], int i1, int j1)
    {
        if(j1 < 0)
            return -1;
        if((K & 7) != 0)
            return -1;
        int k1;
        for(k1 = 0; K > 0 && j1 > 0; k1++)
        {
            abyte0[i1++] = (byte)G;
            G >>>= 8;
            K -= 8;
            j1--;
        }

        if(j1 == 0)
            return k1;
        int l1 = _fldint - _fldgoto;
        if(j1 > l1)
            j1 = l1;
        System.arraycopy(aA, _fldgoto, abyte0, i1, j1);
        _fldgoto += j1;
        if((_fldgoto - _fldint & 1) != 0)
        {
            G = aA[_fldgoto++] & 0xff;
            K = 8;
        }
        return k1 + j1;
    }

    private void a(boolean flag)
    {
        A = flag;
        T = flag ? 2 : 0;
        al = at = 0;
        _fldgoto = _fldint = 0;
        G = K = 0;
        _fldcase = av = 0;
        _fldtry = null;
        r = null;
        H = false;
        D = 1;
    }

    private int _mthdo(byte abyte0[], int i1, int j1)
        throws IOException
    {
        int i3 = 0;
        if(j1 == 0)
            return 0;
        if(0 > i1 || i1 > i1 + j1 || i1 + j1 > abyte0.length)
            throw new IOException("Internal State Error");
        int l2 = 0;
        do
        {
            if(T != 11)
            {
                int k2 = i1;
                int l1 = av;
                int k1 = j1;
                if(k1 > _fldcase)
                    k1 = _fldcase;
                else
                    l1 = (av - _fldcase) + k1 & 0x7fff;
                int j2 = k1;
                int i2 = k1 - l1;
                if(i2 > 0)
                {
                    System.arraycopy(ap, 32768 - i2, abyte0, k2, i2);
                    k2 += i2;
                    k1 = l1;
                }
                System.arraycopy(ap, l1 - k1, abyte0, k2, k1);
                _fldcase -= j2;
                if(_fldcase < 0)
                    throw new IOException("Internal State Error");
                _mthif(abyte0, i1, j2);
                i1 += j2;
                l2 += j2;
                at += j2;
                j1 -= j2;
                if(j1 == 0)
                    return l2;
            }
            i3 = _mthfor();
            if(i3 < 0)
                throw new IOException("Internal State Error");
        } while(i3 == 1 || _fldcase > 0 && T != 11);
        return l2;
    }

    private static final short a(int i1)
    {
        return (short)(j[i1 & 0xf] << 12 | j[i1 >> 4 & 0xf] << 8 | j[i1 >> 8 & 0xf] << 4 | j[i1 >> 12]);
    }

    private static short[] a(byte abyte0[], int i1)
    {
        int ai1[] = new int[16];
        int ai2[] = new int[16];
        for(int l3 = 0; l3 <= 15; l3++)
            ai1[l3] = 0;

        for(int i3 = 0; i3 < i1; i3++)
            ai1[abyte0[i3]]++;

        int j2 = 0;
        int j1 = 512;
        for(int i4 = 1; i4 <= 15; i4++)
        {
            ai2[i4] = j2;
            j2 += ai1[i4] << 16 - i4;
            if(i4 > 9)
            {
                int k4 = j2 & 0xfff80;
                int i5 = ai2[i4] & 0xfff80;
                j1 += k4 - i5 >> 16 - i4;
            }
        }

        short aword0[] = new short[j1];
        if(aword0 == null)
            return aword0;
        int k1 = 512;
        for(int j4 = 15; j4 > 9; j4--)
        {
            int l4 = j2 & 0xfff80;
            j2 -= ai1[j4] << 16 - j4;
            int j5 = j2 & 0xfff80;
            for(int j3 = j5; j3 < l4; j3 += 128)
            {
                aword0[a(j3)] = (short)(-k1 << 4 | j4);
                k1 += 1 << j4 - 9;
            }

        }

        for(int k3 = 0; k3 < i1; k3++)
        {
            byte byte0 = abyte0[k3];
            if(byte0 == 0)
                continue;
            int k2 = ai2[byte0];
            int l2 = a(k2);
            if(byte0 <= 9)
            {
                do
                {
                    aword0[l2] = (short)(k3 << 4 | byte0);
                    l2 += 1 << byte0;
                } while(l2 < 512);
            } else
            {
                int l1 = aword0[l2 & 0x1ff];
                int i2 = 1 << (l1 & 0xf);
                l1 = -(l1 >> 4);
                do
                {
                    aword0[l1 | l2 >> 9] = (short)(k3 << 4 | byte0);
                    l2 += 1 << byte0;
                } while(l2 < i2);
            }
            ai2[byte0] = k2 + (1 << 16 - byte0);
        }

        return aword0;
    }

    private int a(short aword0[])
    {
        int l1 = _mthdo(9);
        if(l1 < 0)
        {
            int j1 = K;
            l1 = _mthdo(j1);
            short word0 = aword0[l1];
            if(word0 >= 0 && (word0 & 0xf) <= j1)
            {
                _mthif(word0 & 0xf);
                return word0 >> 4;
            } else
            {
                return -1;
            }
        }
        short word1;
        if((word1 = aword0[l1]) >= 0)
        {
            _mthif(word1 & 0xf);
            return word1 >> 4;
        }
        int i1 = -(word1 >> 4);
        int k1 = word1 & 0xf;
        if((l1 = _mthdo(k1)) >= 0)
        {
            word1 = aword0[i1 | l1 >> 9];
            _mthif(word1 & 0xf);
            return word1 >> 4;
        }
        k1 = K;
        l1 = _mthdo(k1);
        word1 = aword0[i1 | l1 >> 9];
        if((word1 & 0xf) <= k1)
        {
            _mthif(word1 & 0xf);
            return word1 >> 4;
        } else
        {
            return -1;
        }
    }

    private int _mthfor()
    {
        switch(T)
        {
        case 0: // '\0'
            int i1 = _mthdo(16);
            if(i1 < 0)
                return 0;
            _mthif(16);
            i1 = (i1 << 8 | i1 >> 8) & 0xffff;
            if(i1 % 31 != 0)
                return -3;
            if((i1 & 0xf00) != 2048)
                return -3;
            if((i1 & 0x20) == 0)
            {
                T = 2;
            } else
            {
                T = 1;
                C = 32;
            }

⌨️ 快捷键说明

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