亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? compresstool.java

?? 非常棒的java數(shù)據(jù)庫(kù)
?? JAVA
字號(hào):
/*
 * Copyright 2004-2008 H2 Group. Licensed under the H2 License, Version 1.0
 * (http://h2database.com/html/license.html).
 * Initial Developer: H2 Group
 */
package org.h2.tools;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.SQLException;
import java.util.zip.DeflaterOutputStream;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import java.util.zip.InflaterInputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;

import org.h2.compress.CompressDeflate;
import org.h2.compress.CompressLZF;
import org.h2.compress.CompressNo;
import org.h2.compress.Compressor;
import org.h2.compress.LZFInputStream;
import org.h2.compress.LZFOutputStream;
import org.h2.constant.ErrorCode;
import org.h2.message.Message;
import org.h2.util.StringUtils;

/**
 * A tool to losslessly compress data, and expand the compressed data again.
 */
public class CompressTool {
    
    private static CompressTool instance = new CompressTool();
    private static byte[] buffer;
    private static final int MAX_BUFFER_SIZE = 64 * 1024 * 1024;
    
    private static byte[] getBuffer(int min) {
        if (min > MAX_BUFFER_SIZE) {
            return new byte[min];
        }
        if (buffer == null || buffer.length < min) {
            buffer = new byte[min];
        }
        return buffer;
    }    
    
    private CompressTool() {
    }
    
    /**
     * Get the singleton.
     * 
     * @return the singleton
     */
    public static CompressTool getInstance() {
        return instance;
    }
    
    /**
     * Compressed the data using the specified algorithm. If no algorithm is
     * supplied, LZF is used
     * 
     * @param in the byte array with the original data
     * @param algorithm the algorithm (LZF, DEFLATE)
     * @return the compressed data
     * @throws SQLException if a error occurs
     */
    public byte[] compress(byte[] in, String algorithm) throws SQLException {
        int len = in.length;
        if (in.length < 5) {
            algorithm = "NO";
        }
        Compressor compress = getCompressor(algorithm);
        byte[] buff = getBuffer((len < 100 ? len + 100 : len) * 2);
        int newLen = compress(in, in.length, compress, buff);
        byte[] out = new byte[newLen];
        System.arraycopy(buff, 0, out, 0, newLen);
        return out;
    }

    /**
     * INTERNAL
     */
    public synchronized int compress(byte[] in, int len, Compressor compress, byte[] out) {
        int newLen = 0;
        out[0] = (byte) compress.getAlgorithm();
        int start = 1 + writeInt(out, 1, len);
        newLen = compress.compress(in, len, out, start);
        if (newLen > len + start || newLen <= 0) {
            out[0] = Compressor.NO;
            System.arraycopy(in, 0, out, start, len);
            newLen = len + start;
        }
        return newLen;
    }
    
    /**
     * Expands the compressed  data.
     * 
     * @param in the byte array with the compressed data
     * @return the uncompressed data
     * @throws SQLException if a error occurs
     */    
    public byte[] expand(byte[] in) throws SQLException {
        int algorithm = in[0];
        Compressor compress = getCompressor(algorithm);
        try {
            int len = readInt(in, 1);
            int start = 1 + getLength(len);
            byte[] buff = new byte[len];
            compress.expand(in, start, in.length - start, buff, 0, len);
            return buff;
        } catch (Throwable e) {
            throw Message.getSQLException(ErrorCode.COMPRESSION_ERROR, null, e);
        }
    }

    /**
     * INTERNAL
     */
    public void expand(byte[] in, byte[] out, int outPos) throws SQLException {
        int algorithm = in[0];
        Compressor compress = getCompressor(algorithm);
        try {
            int len = readInt(in, 1);
            int start = 1 + getLength(len);
            compress.expand(in, start, in.length - start, out, outPos, len);
        } catch (Throwable e) {
            throw Message.getSQLException(ErrorCode.COMPRESSION_ERROR, null, e);
        }
    }

    private int readInt(byte[] buff, int pos) {
        int x = buff[pos++] & 0xff;
        if (x < 0x80) {
            return x;
        }
        if (x < 0xc0) {
            return ((x & 0x3f) << 8) + (buff[pos++] & 0xff);
        }
        if (x < 0xe0) {
            return ((x & 0x1f) << 16) + ((buff[pos++] & 0xff) << 8) + (buff[pos++] & 0xff);
        }
        if (x < 0xf0) {
            return ((x & 0xf) << 24) + ((buff[pos++] & 0xff) << 16) + ((buff[pos++] & 0xff) << 8)
                    + (buff[pos++] & 0xff);
        }
        return ((buff[pos++] & 0xff) << 24) + ((buff[pos++] & 0xff) << 16) + ((buff[pos++] & 0xff) << 8)
                + (buff[pos++] & 0xff);
    }

    private int writeInt(byte[] buff, int pos, int x) {
        if (x < 0) {
            buff[pos++] = (byte) 0xf0;
            buff[pos++] = (byte) (x >> 24);
            buff[pos++] = (byte) (x >> 16);
            buff[pos++] = (byte) (x >> 8);
            buff[pos++] = (byte) x;
            return 5;
        } else if (x < 0x80) {
            buff[pos++] = (byte) x;
            return 1;
        } else if (x < 0x4000) {
            buff[pos++] = (byte) (0x80 | (x >> 8));
            buff[pos++] = (byte) x;
            return 2;
        } else if (x < 0x200000) {
            buff[pos++] = (byte) (0xc0 | (x >> 16));
            buff[pos++] = (byte) (x >> 8);
            buff[pos++] = (byte) x;
            return 3;
        } else if (x < 0x10000000) {
            buff[pos++] = (byte) (0xe0 | (x >> 24));
            buff[pos++] = (byte) (x >> 16);
            buff[pos++] = (byte) (x >> 8);
            buff[pos++] = (byte) x;
            return 4;
        } else {
            buff[pos++] = (byte) 0xf0;
            buff[pos++] = (byte) (x >> 24);
            buff[pos++] = (byte) (x >> 16);
            buff[pos++] = (byte) (x >> 8);
            buff[pos++] = (byte) x;
            return 5;
        }
    }

    private int getLength(int x) {
        if (x < 0) {
            return 5;
        } else if (x < 0x80) {
            return 1;
        } else if (x < 0x4000) {
            return 2;
        } else if (x < 0x200000) {
            return 3;
        } else if (x < 0x10000000) {
            return 4;
        } else {
            return 5;
        }
    }

    private Compressor getCompressor(String algorithm) throws SQLException {
        if (algorithm == null) {
            algorithm = "LZF";
        }
        int idx = algorithm.indexOf(' ');
        String options = null;
        if (idx > 0) {
            options = algorithm.substring(idx + 1);
            algorithm = algorithm.substring(0, idx);
        }
        int a = getCompressAlgorithm(algorithm);
        Compressor compress = getCompressor(a);
        compress.setOptions(options);
        return compress;
    }
    
    /**
     * INTERNAL
     */
    public int getCompressAlgorithm(String algorithm) throws SQLException {
        algorithm = StringUtils.toUpperEnglish(algorithm);
        if ("NO".equals(algorithm)) {
            return Compressor.NO;
        } else if ("LZF".equals(algorithm)) {
            return Compressor.LZF;
        } else if ("DEFLATE".equals(algorithm)) {
            return Compressor.DEFLATE;
        } else {
            throw Message.getSQLException(ErrorCode.UNSUPPORTED_COMPRESSION_ALGORITHM_1, algorithm);
        }
    }

    private Compressor getCompressor(int algorithm) throws SQLException {
        switch (algorithm) {
        case Compressor.NO:
            return new CompressNo();
        case Compressor.LZF:
            return new CompressLZF();
        case Compressor.DEFLATE:
            return new CompressDeflate();
        default:
            throw Message.getSQLException(ErrorCode.UNSUPPORTED_COMPRESSION_ALGORITHM_1, "" + algorithm);
        }
    }

    /**
     * INTERNAL
     */
    public static OutputStream wrapOutputStream(OutputStream out, String compressionAlgorithm, String entryName)
            throws SQLException {
        try {
            if ("GZIP".equals(compressionAlgorithm)) {
                out = new GZIPOutputStream(out);
            } else if ("ZIP".equals(compressionAlgorithm)) {
                ZipOutputStream z = new ZipOutputStream(out);
                z.putNextEntry(new ZipEntry(entryName));
                out = z;
            } else if ("DEFLATE".equals(compressionAlgorithm)) {
                out = new DeflaterOutputStream(out);
            } else if ("LZF".equals(compressionAlgorithm)) {
                out = new LZFOutputStream(out);
            } else if (compressionAlgorithm != null) {
                throw Message.getSQLException(ErrorCode.UNSUPPORTED_COMPRESSION_ALGORITHM_1, compressionAlgorithm);
            }
            return out;
        } catch (IOException e) {
            throw Message.convertIOException(e, null);
        }
    }

    /**
     * INTERNAL
     */
    public static InputStream wrapInputStream(InputStream in, String compressionAlgorithm, String entryName)
            throws SQLException {
        try {
            if ("GZIP".equals(compressionAlgorithm)) {
                in = new GZIPInputStream(in);
            } else if ("ZIP".equals(compressionAlgorithm)) {
                ZipInputStream z = new ZipInputStream(in);
                while (true) {
                    ZipEntry entry = z.getNextEntry();
                    if (entry == null) {
                        return null;
                    }
                    if (entryName.equals(entry.getName())) {
                        break;
                    }
                }
                in = z;
            } else if ("DEFLATE".equals(compressionAlgorithm)) {
                in = new InflaterInputStream(in);
            } else if ("LZF".equals(compressionAlgorithm)) {
                in = new LZFInputStream(in);
            } else if (compressionAlgorithm != null) {
                throw Message.getSQLException(ErrorCode.UNSUPPORTED_COMPRESSION_ALGORITHM_1, compressionAlgorithm);
            }
            return in;
        } catch (IOException e) {
            throw Message.convertIOException(e, null);
        }
    }

}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
在线免费不卡电影| 国产91精品入口| 欧美亚洲国产bt| 亚洲精品国产第一综合99久久| 国产sm精品调教视频网站| 久久久久国产精品麻豆| 国产东北露脸精品视频| 国产精品每日更新在线播放网址| 国产成人精品1024| 国产精品福利av| 91九色02白丝porn| 偷偷要91色婷婷| 日韩一区二区不卡| 国产99精品国产| 亚洲日本成人在线观看| 精品视频1区2区| 久久国产综合精品| 中文字幕精品一区| 欧美亚洲另类激情小说| 久久精品72免费观看| 中文字幕乱码亚洲精品一区| 色哟哟在线观看一区二区三区| 亚洲成人动漫在线免费观看| 91精品国产乱| 成人理论电影网| 亚洲一区二区中文在线| 精品久久国产老人久久综合| 成人午夜电影网站| 图片区小说区区亚洲影院| 国产性色一区二区| 欧美性生活影院| 国产精品影音先锋| 一区二区三区在线视频播放| 91精品国产麻豆| 成人av影视在线观看| 天堂成人国产精品一区| 久久久久久久久久久久久夜| 色偷偷一区二区三区| 精品一区二区在线播放| 一区二区三区不卡视频| 2020日本不卡一区二区视频| 欧美中文字幕一二三区视频| 国产精品1区二区.| 午夜激情一区二区三区| 中文字幕av一区二区三区| 91麻豆精品国产91| 97久久人人超碰| 国产麻豆精品在线| 亚洲成人自拍网| 成人欧美一区二区三区| 26uuu精品一区二区在线观看| 欧美自拍偷拍一区| 成人黄色av电影| 精品午夜久久福利影院| 图片区小说区区亚洲影院| 1区2区3区欧美| 国产日韩三级在线| 91精品综合久久久久久| 91免费版pro下载短视频| 国产91清纯白嫩初高中在线观看| 蜜臀av国产精品久久久久 | 欧美高清激情brazzers| 成人黄色av电影| 国产九色sp调教91| 久久福利资源站| 日韩av中文字幕一区二区三区| 亚洲蜜臀av乱码久久精品蜜桃| 久久九九全国免费| 欧美精品一区二区三区很污很色的| 欧美日韩成人综合天天影院 | 亚洲欧美怡红院| 国产丝袜欧美中文另类| 26uuu精品一区二区| 91精品国产91综合久久蜜臀| 欧美日韩电影一区| 在线不卡a资源高清| 欧美日韩综合色| 欧美日韩精品专区| 欧美日韩性生活| 在线电影欧美成精品| 欧美日韩一区二区三区不卡| 欧美视频一区二区| 欧美三级午夜理伦三级中视频| 91精品福利视频| 欧洲亚洲国产日韩| 欧美日韩一区二区在线视频| 欧美视频第二页| 欧美精品乱码久久久久久| 51久久夜色精品国产麻豆| 5月丁香婷婷综合| 精品成人a区在线观看| 国产亚洲一区二区三区在线观看| 国产午夜精品在线观看| 国产精品乱码人人做人人爱| 中文字幕一区二| 一区二区三区精品在线| 性久久久久久久| 经典三级一区二区| 国产成人免费视频网站| va亚洲va日韩不卡在线观看| 色香蕉久久蜜桃| 欧美一区二区久久久| 国产午夜一区二区三区| 亚洲视频 欧洲视频| 亚洲观看高清完整版在线观看 | 久久av中文字幕片| 国产99久久久国产精品免费看| 99久久精品免费精品国产| 欧美日韩一区二区三区在线| 日韩欧美不卡一区| 中文字幕乱码久久午夜不卡| 亚洲自拍偷拍九九九| 久久国产综合精品| 99久久久久久| 欧美一级国产精品| 日本一二三不卡| 婷婷国产在线综合| 成人一级片在线观看| 欧美日韩中文一区| 精品国产乱码久久久久久久久 | 2欧美一区二区三区在线观看视频| 欧美高清在线精品一区| 亚洲v精品v日韩v欧美v专区| 国产精品综合二区| 欧美日韩久久久| 国产欧美一区二区三区在线老狼| 一二三四区精品视频| 韩国成人福利片在线播放| 色综合激情五月| 国产校园另类小说区| 亚洲成人第一页| 成人福利电影精品一区二区在线观看 | 欧美日韩一区不卡| 国产午夜亚洲精品理论片色戒| 亚洲小说欧美激情另类| 懂色av中文一区二区三区| 欧美日韩情趣电影| 中文字幕一区二区三区乱码在线| 美女www一区二区| 在线精品视频一区二区三四| 久久青草欧美一区二区三区| 亚洲丶国产丶欧美一区二区三区| 成人美女在线视频| 日韩女同互慰一区二区| 亚洲成人av免费| 91美女视频网站| 国产日韩精品一区二区三区| 青青国产91久久久久久| 欧美主播一区二区三区美女| 国产精品久久久久影院老司| 国产综合色产在线精品| 91精品国产综合久久福利软件| 成人毛片老司机大片| 久久久久久久精| 黄色日韩三级电影| 91精品欧美一区二区三区综合在| 一区二区三区中文在线| 99re热视频精品| 国产精品色哟哟网站| 国产一区二区三区在线观看精品| 日韩午夜中文字幕| 日日摸夜夜添夜夜添亚洲女人| 欧美综合在线视频| 一区二区三区欧美在线观看| av网站免费线看精品| 国产精品毛片久久久久久| 国产成人精品1024| 国产女人18水真多18精品一级做| 国产一区二区三区黄视频| 欧美精品一区在线观看| 久久国产精品无码网站| 欧美v国产在线一区二区三区| 免费成人在线播放| 日韩欧美亚洲国产精品字幕久久久| 男男gaygay亚洲| 日韩午夜中文字幕| 国产麻豆精品95视频| 国产亚洲欧美在线| 国产成a人无v码亚洲福利| 亚洲国产激情av| 不卡av在线网| 一区二区三区中文字幕在线观看| 在线免费观看视频一区| 亚洲成人av电影在线| 69堂精品视频| 精品一区二区三区久久久| 久久先锋影音av鲁色资源网| 成人自拍视频在线| 亚洲乱码国产乱码精品精98午夜| 欧美日韩五月天| 蜜臀av性久久久久av蜜臀妖精| 欧美精品一区二区三区蜜桃视频| 成人午夜免费电影| 亚洲最新在线观看| 欧美一区二区视频在线观看| 国产麻豆一精品一av一免费| 国产精品久久久久久久久免费相片 | 舔着乳尖日韩一区| 欧美成人一区二区三区片免费 | fc2成人免费人成在线观看播放|