KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > groboutils > codecoverage > v2 > ant > zip > UnrecognizedExtraField


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

17
18 package net.sourceforge.groboutils.codecoverage.v2.ant.zip;
19
20 /**
21  * Simple placeholder for all those extra fields we don't want to deal
22  * with.
23  *
24  * <p>Assumes local file data and central directory entries are
25  * identical - unless told the opposite.</p>
26  *
27  * @author Stefan Bodewig
28  * @version $Revision: 1.1 $
29  */

30 public class UnrecognizedExtraField implements ZipExtraField {
31
32     /**
33      * The Header-ID.
34      *
35      * @since 1.1
36      */

37     private ZipShort headerId;
38
39     public void setHeaderId(ZipShort headerId) {
40         this.headerId = headerId;
41     }
42
43     public ZipShort getHeaderId() {
44         return headerId;
45     }
46
47     /**
48      * Extra field data in local file data - without
49      * Header-ID or length specifier.
50      *
51      * @since 1.1
52      */

53     private byte[] localData;
54
55     public void setLocalFileDataData(byte[] data) {
56         localData = data;
57     }
58
59     public ZipShort getLocalFileDataLength() {
60         return new ZipShort(localData.length);
61     }
62
63     public byte[] getLocalFileDataData() {
64         return localData;
65     }
66
67     /**
68      * Extra field data in central directory - without
69      * Header-ID or length specifier.
70      *
71      * @since 1.1
72      */

73     private byte[] centralData;
74
75     public void setCentralDirectoryData(byte[] data) {
76         centralData = data;
77     }
78
79     public ZipShort getCentralDirectoryLength() {
80         if (centralData != null) {
81             return new ZipShort(centralData.length);
82         }
83         return getLocalFileDataLength();
84     }
85
86     public byte[] getCentralDirectoryData() {
87         if (centralData != null) {
88             return centralData;
89         }
90         return getLocalFileDataData();
91     }
92
93     public void parseFromLocalFileData(byte[] data, int offset, int length) {
94         byte[] tmp = new byte[length];
95         System.arraycopy(data, offset, tmp, 0, length);
96         setLocalFileDataData(tmp);
97     }
98 }
99
Popular Tags