1 | /*
|
---|
2 | * Copyright 2001-2002,2004-2005 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 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 | */
|
---|
28 | public class UnrecognizedExtraField implements ZipExtraField {
|
---|
29 |
|
---|
30 | /**
|
---|
31 | * The Header-ID.
|
---|
32 | *
|
---|
33 | * @since 1.1
|
---|
34 | */
|
---|
35 | private ZipShort headerId;
|
---|
36 |
|
---|
37 | public void setHeaderId(ZipShort headerId) {
|
---|
38 | this.headerId = headerId;
|
---|
39 | }
|
---|
40 |
|
---|
41 | public ZipShort getHeaderId() {
|
---|
42 | return headerId;
|
---|
43 | }
|
---|
44 |
|
---|
45 | /**
|
---|
46 | * Extra field data in local file data - without
|
---|
47 | * Header-ID or length specifier.
|
---|
48 | *
|
---|
49 | * @since 1.1
|
---|
50 | */
|
---|
51 | private byte[] localData;
|
---|
52 |
|
---|
53 | public void setLocalFileDataData(byte[] data) {
|
---|
54 | localData = data;
|
---|
55 | }
|
---|
56 |
|
---|
57 | public ZipShort getLocalFileDataLength() {
|
---|
58 | return new ZipShort(localData.length);
|
---|
59 | }
|
---|
60 |
|
---|
61 | public byte[] getLocalFileDataData() {
|
---|
62 | return localData;
|
---|
63 | }
|
---|
64 |
|
---|
65 | /**
|
---|
66 | * Extra field data in central directory - without
|
---|
67 | * Header-ID or length specifier.
|
---|
68 | *
|
---|
69 | * @since 1.1
|
---|
70 | */
|
---|
71 | private byte[] centralData;
|
---|
72 |
|
---|
73 | public void setCentralDirectoryData(byte[] data) {
|
---|
74 | centralData = data;
|
---|
75 | }
|
---|
76 |
|
---|
77 | public ZipShort getCentralDirectoryLength() {
|
---|
78 | if (centralData != null) {
|
---|
79 | return new ZipShort(centralData.length);
|
---|
80 | }
|
---|
81 | return getLocalFileDataLength();
|
---|
82 | }
|
---|
83 |
|
---|
84 | public byte[] getCentralDirectoryData() {
|
---|
85 | if (centralData != null) {
|
---|
86 | return centralData;
|
---|
87 | }
|
---|
88 | return getLocalFileDataData();
|
---|
89 | }
|
---|
90 |
|
---|
91 | public void parseFromLocalFileData(byte[] data, int offset, int length) {
|
---|
92 | byte[] tmp = new byte[length];
|
---|
93 | System.arraycopy(data, offset, tmp, 0, length);
|
---|
94 | setLocalFileDataData(tmp);
|
---|
95 | }
|
---|
96 | }
|
---|