01: /*
02: * Copyright 2001-2002,2004 The Apache Software Foundation
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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 org.apache.tools.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.4.2.3 $
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,
94: int length) {
95: byte[] tmp = new byte[length];
96: System.arraycopy(data, offset, tmp, 0, length);
97: setLocalFileDataData(tmp);
98: }
99: }
|