/* -*-mode:java; c-basic-offset:2; -*- */
/**ATTENTION:This class is modified in respect to the original sources
*
*/
/*
Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution.
3. The names of the authors may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* This program is based on zlib-1.1.3, so all credit should go authors
* Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
* and contributors of zlib.
*/
/*
*Modified by Asoft ltd. at 2003 for running on J2ME platform
*www.asoft.ru
*Alexandre Rusev rusev@asoft.ru
*Alexey Soloviev soloviev@asoft.ru
*/
package com.asoft.midp.jzlib;
import com.asoft.midp.dynarray.*;
public final class Deflate
{
private static final int DEBUG = 5;
static final private int MAX_MEM_LEVEL = 9;
static final private int Z_DEFAULT_COMPRESSION = -1;
static final private int MAX_WBITS = 15; // 32K LZ77 window
static final private int DEF_MEM_LEVEL = 8;
static class Config
{
int good_length; // reduce lazy search above this match length
int max_lazy; // do not perform lazy search above this match length
int nice_length; // quit search above this match length
int max_chain;
int func;
Config(int good_length, int max_lazy,
int nice_length, int max_chain, int func)
{
this.good_length = good_length;
this.max_lazy = max_lazy;
this.nice_length = nice_length;
this.max_chain = max_chain;
this.func = func;
}
}
static final private int STORED = 0;
static final private int FAST = 1;
static final private int SLOW = 2;
static final private Config[] config_table;
static
{
config_table = new Config[10];
// good lazy nice chain
config_table[0] = new Config(0, 0, 0, 0, STORED);
config_table[1] = new Config(4, 4, 8, 4, FAST);
config_table[2] = new Config(4, 5, 16, 8, FAST);
config_table[3] = new Config(4, 6, 32, 32, FAST);
config_table[4] = new Config(4, 4, 16, 16, SLOW);
config_table[5] = new Config(8, 16, 32, 32, SLOW);
config_table[6] = new Config(8, 16, 128, 128, SLOW);
config_table[7] = new Config(8, 32, 128, 256, SLOW);
config_table[8] = new Config(32, 128, 258, 1024, SLOW);
config_table[9] = new Config(32, 258, 258, 4096, SLOW);
}
static final private String[] z_errmsg = {
"need dictionary", // Z_NEED_DICT 2
"stream end", // Z_STREAM_END 1
"", // Z_OK 0
"file error", // Z_ERRNO (-1)
"stream error", // Z_STREAM_ERROR (-2)
"data error", // Z_DATA_ERROR (-3)
"insufficient memory", // Z_MEM_ERROR (-4)
"buffer error", // Z_BUF_ERROR (-5)
"incompatible version",// Z_VERSION_ERROR (-6)
""
};
// block not completed, need more input or more output
static final private int NeedMore = 0;
// block flush performed
static final private int BlockDone = 1;
// finish started, need only more output at next deflate
static final private int FinishStarted = 2;
// finish done, accept no more input or output
static final private int FinishDone = 3;
// preset dictionary flag in zlib header
static final private int PRESET_DICT = 0x20;
static final private int Z_FILTERED = 1;
static final private int Z_HUFFMAN_ONLY = 2;
static final private int Z_DEFAULT_STRATEGY = 0;
static final private int Z_NO_FLUSH = 0;
static final private int Z_PARTIAL_FLUSH = 1;
static final private int Z_SYNC_FLUSH = 2;
static final private int Z_FULL_FLUSH = 3;
static final private int Z_FINISH = 4;
static final private int Z_OK = 0;
static final private int Z_STREAM_END = 1;
static final private int Z_NEED_DICT = 2;
static final private int Z_ERRNO = -1;
static final private int Z_STREAM_ERROR = -2;
static final private int Z_DATA_ERROR = -3;
static final private int Z_MEM_ERROR = -4;
static final private int Z_BUF_ERROR = -5;
static final private int Z_VERSION_ERROR = -6;
static final private int INIT_STATE = 42;
static final private int BUSY_STATE = 113;
static final private int FINISH_STATE = 666;
// The deflate compression method
static final private int Z_DEFLATED = 8;
static final private int STORED_BLOCK = 0;
static final private int STATIC_TREES = 1;
static final private int DYN_TREES = 2;
// The three kinds of block type
static final private int Z_BINARY = 0;
static final private int Z_ASCII = 1;
static final private int Z_UNKNOWN = 2;
static final private int Buf_size = 8 * 2;
// repeat previous bit length 3-6 times (2 bits of repeat count)
static final private int REP_3_6 = 16;
// repeat a zero length 3-10 times (3 bits of repeat count)
static final private int REPZ_3_10 = 17;
// repeat a zero length 11-138 times (7 bits of repeat count)
static final private int REPZ_11_138 = 18;
static final private int MIN_MATCH = 3;
static final private int MAX_MATCH = 258;
static final private int MIN_LOOKAHEAD = (MAX_MATCH + MIN_MATCH + 1);
static final private int MAX_BITS = 15;
static final private int D_CODES = 30;
static final private int BL_CODES = 19;
static final private int LENGTH_CODES = 29;
static final private int LITERALS = 256;
static final private int L_CODES = (LITERALS + 1 + LENGTH_CODES);
static final private int HEAP_SIZE = (2 * L_CODES + 1);
static final private int END_BLOCK = 256;
ZStream strm; // pointer back to this zlib stream
int status; // as the name implies
byte_array pending_buf; // output still pending
int pending_buf_size; // size of pending_buf
int pending_out; // next pending byte to output to the stream
int pending; // nb of bytes in the pending buffer
int noheader; // suppress zlib header and adler32
byte data_type; // UNKNOWN, BINARY or ASCII
byte method; // STORED (for zip only) or DEFLATED
int last_flush; // value of flush param for previous deflate call
int w_size; // LZ77 window size (32K by default)
int w_bits; // log2(w_size) (8..16)
int w_mask;
没有合适的资源?快使用搜索试试~ 我知道了~
j2me zip 压缩及解压,不支持gzip格式
共33个文件
java:33个
5星 · 超过95%的资源 需积分: 12 193 下载量 92 浏览量
2008-12-08
17:10:58
上传
评论
收藏 104KB RAR 举报
温馨提示
j2me zip 压缩及解压,不支持gzip格式
资源推荐
资源详情
资源评论
收起资源包目录
j2me zip unzip.rar (33个子文件)
com
asoft
midp
zip
Inflater.java 17KB
DataFormatException.java 2KB
Deflater.java 17KB
dynarray
long_AccessibleArray.java 3KB
long_ArrayU.java 2KB
short_AccessibleArray.java 3KB
short_array.java 16KB
char_array.java 16KB
short_ArrayU.java 2KB
long_arraywraper.java 4KB
short_arraywraper.java 4KB
int_array.java 16KB
long_array.java 16KB
byte_array.java 21KB
int_ArrayU.java 2KB
int_AccessibleArray.java 3KB
int_arraywraper.java 4KB
char_AccessibleArray.java 3KB
char_ArrayU.java 2KB
byte_arraywraper.java 5KB
byte_arrayU.java 3KB
char_arraywraper.java 4KB
byte_AccessibleArray.java 3KB
jzlib
StaticTree.java 7KB
Inflate.java 12KB
ZStream.java 12KB
InfCodes.java 32KB
JZlib.java 3KB
Tree.java 16KB
InfTree.java 19KB
InfBlocks.java 30KB
Deflate.java 74KB
Adler32.java 5KB
共 33 条
- 1
资源评论
- pbdxd1202011-10-30很好,只是代码过多。
- lihaiping9082013-08-06还不错,只是代码量太大,不适合放在falsh里运行。
- fylk_n22012-05-29不错,能解决一般的java程序压缩和解压
njlxp
- 粉丝: 1
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功