Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
CompressorType |
|
| 1.4285714285714286;1.429 | ||||
CompressorType$1 |
|
| 1.4285714285714286;1.429 | ||||
CompressorType$2 |
|
| 1.4285714285714286;1.429 | ||||
CompressorType$3 |
|
| 1.4285714285714286;1.429 | ||||
CompressorType$4 |
|
| 1.4285714285714286;1.429 | ||||
CompressorType$5 |
|
| 1.4285714285714286;1.429 |
1 | /** | |
2 | * Distribution License: | |
3 | * JSword is free software; you can redistribute it and/or modify it under | |
4 | * the terms of the GNU Lesser General Public License, version 2.1 or later | |
5 | * as published by the Free Software Foundation. This program is distributed | |
6 | * in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even | |
7 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
8 | * See the GNU Lesser General Public License for more details. | |
9 | * | |
10 | * The License is available on the internet at: | |
11 | * http://www.gnu.org/copyleft/lgpl.html | |
12 | * or by writing to: | |
13 | * Free Software Foundation, Inc. | |
14 | * 59 Temple Place - Suite 330 | |
15 | * Boston, MA 02111-1307, USA | |
16 | * | |
17 | * © CrossWire Bible Society, 2007 - 2016 | |
18 | * | |
19 | */ | |
20 | package org.crosswire.common.compress; | |
21 | ||
22 | import java.io.ByteArrayInputStream; | |
23 | ||
24 | /** | |
25 | * An Enumeration of the possible Compressions. | |
26 | * | |
27 | * @see gnu.lgpl.License The GNU Lesser General Public License for details. | |
28 | * @author DM Smith | |
29 | */ | |
30 | 0 | public enum CompressorType { |
31 | 0 | ZIP { |
32 | @Override | |
33 | public Compressor getCompressor(byte[] input) { | |
34 | 0 | return new Zip(new ByteArrayInputStream(input)); |
35 | } | |
36 | }, | |
37 | ||
38 | 0 | LZSS { |
39 | @Override | |
40 | public Compressor getCompressor(byte[] input) { | |
41 | 0 | return new LZSS(new ByteArrayInputStream(input)); |
42 | } | |
43 | }, | |
44 | ||
45 | 0 | BZIP2 { |
46 | @Override | |
47 | public Compressor getCompressor(byte[] input) { | |
48 | 0 | return new BZip2(new ByteArrayInputStream(input)); |
49 | } | |
50 | }, | |
51 | ||
52 | 0 | GZIP { |
53 | @Override | |
54 | public Compressor getCompressor(byte[] input) { | |
55 | 0 | return new Gzip(new ByteArrayInputStream(input)); |
56 | } | |
57 | }, | |
58 | ||
59 | 0 | XZ { |
60 | @Override | |
61 | public Compressor getCompressor(byte[] input) { | |
62 | 0 | return new XZ(new ByteArrayInputStream(input)); |
63 | } | |
64 | }; | |
65 | ||
66 | /** | |
67 | * Get a compressor. | |
68 | * | |
69 | * @param input the stream to compress or to uncompress. | |
70 | * @return the compressor for the stream | |
71 | */ | |
72 | public abstract Compressor getCompressor(byte[] input); | |
73 | ||
74 | /** | |
75 | * Get a CompressorType from a String | |
76 | * | |
77 | * @param name the case insensitive representation of the desired CompressorType | |
78 | * @return the desired compressor or null if not found. | |
79 | */ | |
80 | public static CompressorType fromString(String name) { | |
81 | 0 | for (CompressorType v : values()) { |
82 | 0 | if (v.name().equalsIgnoreCase(name)) { |
83 | 0 | return v; |
84 | } | |
85 | } | |
86 | ||
87 | // cannot get here | |
88 | 0 | assert false; |
89 | 0 | return null; |
90 | } | |
91 | } |