01: /*
02: * Copyright 2004-2008 H2 Group. Licensed under the H2 License, Version 1.0
03: * (http://h2database.com/html/license.html).
04: * Initial Developer: H2 Group
05: */
06: package org.h2.compress;
07:
08: import java.sql.SQLException;
09:
10: /**
11: * Each data compression algorithm must implement this interface.
12: */
13: public interface Compressor {
14:
15: /**
16: * No compression is used.
17: */
18: int NO = 0;
19:
20: /**
21: * The LZF compression algorithm is used
22: */
23: int LZF = 1;
24:
25: /**
26: * The DEFLATE compression algorithm is used.
27: */
28: int DEFLATE = 2;
29:
30: /**
31: * Get the compression algorithm type.
32: *
33: * @return the type
34: */
35: int getAlgorithm();
36:
37: /**
38: * Compress a number of bytes.
39: *
40: * @param in the input data
41: * @param inLen the number of bytes to compress
42: * @param out the output area
43: * @param outPos the offset at the output array
44: * @return the size of the compressed data
45: */
46: int compress(byte[] in, int inLen, byte[] out, int outPos);
47:
48: /**
49: * Expand a number of compressed bytes.
50: *
51: * @param in the compressed data
52: * @param inPos the offset at the input array
53: * @param inLen the number of bytes to read
54: * @param out the output area
55: * @param outPos the offset at the output array
56: * @param outLen the size of the uncompressed data
57: */
58: void expand(byte[] in, int inPos, int inLen, byte[] out,
59: int outPos, int outLen) throws SQLException;
60:
61: /**
62: * Set the compression options. This may include settings for
63: * higher performance but less compression.
64: *
65: * @param options the options
66: */
67: void setOptions(String options) throws SQLException;
68: }
|