请选择 进入手机版 | 继续访问电脑版
  • 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CompressionException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中io.netty.handler.codec.compression.CompressionException的典型用法代码示例。如果您正苦于以下问题:Java CompressionException类的具体用法?Java CompressionException怎么用?Java CompressionException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CompressionException类属于io.netty.handler.codec.compression包,在下文中一共展示了CompressionException类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: encode

import io.netty.handler.codec.compression.CompressionException; //导入依赖的package包/类
private void encode(ByteBuf compressed) {
    try {
        byte[] out = new byte[(int) Math.ceil(z.next_in.length * 1.001) + 12];
        z.next_out = out;
        z.next_out_index = 0;
        z.avail_out = out.length;

        int resultCode = z.deflate(JZlib.Z_SYNC_FLUSH);
        if (resultCode != JZlib.Z_OK) {
            throw new CompressionException("compression failure: " + resultCode);
        }

        if (z.next_out_index != 0) {
            compressed.writeBytes(out, 0, z.next_out_index);
        }
    } finally {
        // Deference the external references explicitly to tell the VM that
        // the allocated byte arrays are temporary so that the call stack
        // can be utilized.
        // I'm not sure if the modern VMs do this optimization though.
        z.next_in = null;
        z.next_out = null;
    }
}
 
开发者ID:kyle-liu,项目名称:netty4study,代码行数:25,代码来源:SpdyHeaderBlockJZlibEncoder.java


示例2: SpdyHeaderBlockJZlibEncoder

import io.netty.handler.codec.compression.CompressionException; //导入依赖的package包/类
SpdyHeaderBlockJZlibEncoder(
        SpdyVersion version, int compressionLevel, int windowBits, int memLevel) {
    super(version);
    if (compressionLevel < 0 || compressionLevel > 9) {
        throw new IllegalArgumentException(
                "compressionLevel: " + compressionLevel + " (expected: 0-9)");
    }
    if (windowBits < 9 || windowBits > 15) {
        throw new IllegalArgumentException(
                "windowBits: " + windowBits + " (expected: 9-15)");
    }
    if (memLevel < 1 || memLevel > 9) {
        throw new IllegalArgumentException(
                "memLevel: " + memLevel + " (expected: 1-9)");
    }

    int resultCode = z.deflateInit(
            compressionLevel, windowBits, memLevel, JZlib.W_ZLIB);
    if (resultCode != JZlib.Z_OK) {
        throw new CompressionException(
                "failed to initialize an SPDY header block deflater: " + resultCode);
    } else {
        resultCode = z.deflateSetDictionary(SPDY_DICT, SPDY_DICT.length);
        if (resultCode != JZlib.Z_OK) {
            throw new CompressionException(
                    "failed to set the SPDY dictionary: " + resultCode);
        }
    }
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:30,代码来源:SpdyHeaderBlockJZlibEncoder.java


示例3: SpdyHeaderBlockJZlibEncoder

import io.netty.handler.codec.compression.CompressionException; //导入依赖的package包/类
public SpdyHeaderBlockJZlibEncoder(
        SpdyVersion version, int compressionLevel, int windowBits, int memLevel) {
    super(version);
    if (compressionLevel < 0 || compressionLevel > 9) {
        throw new IllegalArgumentException(
                "compressionLevel: " + compressionLevel + " (expected: 0-9)");
    }
    if (windowBits < 9 || windowBits > 15) {
        throw new IllegalArgumentException(
                "windowBits: " + windowBits + " (expected: 9-15)");
    }
    if (memLevel < 1 || memLevel > 9) {
        throw new IllegalArgumentException(
                "memLevel: " + memLevel + " (expected: 1-9)");
    }

    int resultCode = z.deflateInit(
            compressionLevel, windowBits, memLevel, JZlib.W_ZLIB);
    if (resultCode != JZlib.Z_OK) {
        throw new CompressionException(
                "failed to initialize an SPDY header block deflater: " + resultCode);
    } else {
        resultCode = z.deflateSetDictionary(SPDY_DICT, SPDY_DICT.length);
        if (resultCode != JZlib.Z_OK) {
            throw new CompressionException(
                    "failed to set the SPDY dictionary: " + resultCode);
        }
    }
}
 
开发者ID:kyle-liu,项目名称:netty4study,代码行数:30,代码来源:SpdyHeaderBlockJZlibEncoder.java


示例4: encode

import io.netty.handler.codec.compression.CompressionException; //导入依赖的package包/类
private ByteBuf encode(ByteBufAllocator alloc) {
    boolean release = true;
    ByteBuf out = null;
    try {
        int oldNextInIndex = z.next_in_index;
        int oldNextOutIndex = z.next_out_index;

        int maxOutputLength = (int) Math.ceil(z.next_in.length * 1.001) + 12;
        out = alloc.heapBuffer(maxOutputLength);
        z.next_out = out.array();
        z.next_out_index = out.arrayOffset() + out.writerIndex();
        z.avail_out = maxOutputLength;

        int resultCode;
        try {
            resultCode = z.deflate(JZlib.Z_SYNC_FLUSH);
        } finally {
            out.skipBytes(z.next_in_index - oldNextInIndex);
        }
        if (resultCode != JZlib.Z_OK) {
            throw new CompressionException("compression failure: " + resultCode);
        }

        int outputLength = z.next_out_index - oldNextOutIndex;
        if (outputLength > 0) {
            out.writerIndex(out.writerIndex() + outputLength);
        }
        release = false;
        return out;
    } finally {
        // Deference the external references explicitly to tell the VM that
        // the allocated byte arrays are temporary so that the call stack
        // can be utilized.
        // I'm not sure if the modern VMs do this optimization though.
        z.next_in = null;
        z.next_out = null;
        if (release && out != null) {
            out.release();
        }
    }
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:42,代码来源:SpdyHeaderBlockJZlibEncoder.java



注:本文中的io.netty.handler.codec.compression.CompressionException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Speedometer类代码示例发布时间:2022-05-16
下一篇:
Java IClassFileAttribute类代码示例发布时间:2022-05-16
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap