KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > schlichtherle > util > zip > CRC32Exception


1 /*
2  * CRC32Exception.java
3  *
4  * Created on 29. Juni 2006, 21:39
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.util.zip;
23
24 import java.util.zip.ZipException JavaDoc;
25
26 /**
27  * Thrown to indicate a CRC-32 mismatch when closing the stream returned by
28  * {@link ZipFile#getCheckedInputStream}.
29  * The exception's detail message is the name of the ZIP entry.
30  *
31  * @author Christian Schlichtherle
32  * @version @version@
33  * @since TrueZIP 6.1
34  */

35 public class CRC32Exception extends ZipException JavaDoc {
36     
37     final long expectedCrc, actualCrc;
38
39     /**
40      * Creates a new instance of <code>CRC32Exception</code> where the
41      * given entry name is the detail message of the base class.
42      *
43      * @see #getMessage
44      * @see #getExpectedCrc
45      * @see #getActualCrc
46      */

47     CRC32Exception(String JavaDoc entryName, long expectedCrc, long actualCrc) {
48         super(entryName);
49         assert expectedCrc != actualCrc;
50         this.expectedCrc = expectedCrc;
51         this.actualCrc = actualCrc;
52     }
53
54     /**
55      * Returns the CRC-32 value which has been read from the ZIP file.
56      */

57     public long getExpectedCrc() {
58         return expectedCrc;
59     }
60
61     /**
62      * Returns the CRC-32 value which has been computed from the contents
63      * of the ZIP entry.
64      */

65     public long getActualCrc() {
66         return actualCrc;
67     }
68 }
69
Popular Tags