KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > schlichtherle > io > archive > zip > CheckedReadOnlySfxDriver


1 /*
2  * CheckedReadOnlySfxDriver.java
3  *
4  * Created on 30. Juni 2006, 00:06
5  */

6 /*
7  * Copyright 2006 Schlichtherle IT Services
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */

21
22 package de.schlichtherle.io.archive.zip;
23
24 import de.schlichtherle.io.rof.*;
25
26 import java.io.*;
27 import java.util.zip.*;
28
29 /**
30  * A {@link ReadOnlySfxDriver} which checks the CRC-32 value for all ZIP
31  * entries in input archives.
32  * The additional CRC-32 computation makes this class slower than its super
33  * class.
34  * <p>
35  * If there is a mismatch of the CRC-32 values for a ZIP entry in an input
36  * archive, the {@link InputStream#close} method of the corresponding stream
37  * for the archive entry will throw a
38  * {@link de.schlichtherle.util.zip.CRC32Exception}.
39  * This exception is then propagated through the stack up to the corresponding
40  * file operation in the package <code>de.schlichtherle.io</code> where it is
41  * either allowed to pass on or is catched and processed accordingly.
42  * For example, the {@link de.schlichtherle.io.FileInputStream#close()}
43  * method would allow the <code>CRC32Exception</code> to pass on to the
44  * client application, whereas the
45  * {@link de.schlichtherle.io.File#catTo(OutputStream)} method would simply
46  * return <code>false</code>.
47  * Other than this, the archive entry will be processed normally.
48  * So if just the CRC-32 value for the entry in the archive file has been
49  * modified, you can still read its entire contents.
50  * <p>
51  * Instances of this class are immutable.
52  *
53  * @see ReadOnlySfxDriver
54  * @see CheckedZip32InputArchive
55  * @see CheckedZip32OutputArchive
56  *
57  * @author Christian Schlichtherle
58  * @version @version@
59  * @since TrueZIP 6.1
60  */

61 public class CheckedReadOnlySfxDriver extends ReadOnlySfxDriver {
62
63     /**
64      * Equivalent to {@link #CheckedReadOnlySfxDriver(String)
65      * CheckedReadOnlySfxDriver(ENCODING)}.
66      * This parameter is based on heuristics.
67      */

68     public CheckedReadOnlySfxDriver() {
69         this(ENCODING);
70     }
71
72     /**
73      * Equivalent to
74      * {@link ReadOnlySfxDriver#ReadOnlySfxDriver(String)
75      * super(encoding)}.
76      * This parameter is based on heuristics.
77      */

78     public CheckedReadOnlySfxDriver(String JavaDoc encoding) {
79         super(encoding);
80     }
81     
82     protected Zip32InputArchive createZip32InputArchive(
83             ReadOnlyFile rof,
84             String JavaDoc encoding,
85             boolean preambled,
86             boolean postambled)
87     throws NullPointerException JavaDoc,
88             UnsupportedEncodingException,
89             FileNotFoundException,
90             ZipException,
91             IOException {
92         return new CheckedZip32InputArchive(rof, encoding, preambled, postambled);
93     }
94 }
95
Popular Tags