2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 package org.apache.tools.zip;
22 * Simple placeholder for all those extra fields we don't want to deal with.
25 * Assumes local file data and central directory entries are identical - unless
30 public class UnrecognizedExtraField implements ZipExtraField {
37 private ZipShort headerId;
43 * the header id to use
45 public void setHeaderId(ZipShort headerId) {
46 this.headerId = headerId;
52 * @return the header id
54 public ZipShort getHeaderId() {
59 * Extra field data in local file data - without Header-ID or length
64 private byte[] localData;
67 * Set the extra field data in the local file data - without Header-ID or
71 * the field data to use
73 public void setLocalFileDataData(byte[] data) {
78 * Get the length of the local data.
80 * @return the length of the local data
82 public ZipShort getLocalFileDataLength() {
83 return new ZipShort(localData.length);
89 * @return the local data
91 public byte[] getLocalFileDataData() {
96 * Extra field data in central directory - without Header-ID or length
101 private byte[] centralData;
104 * Set the extra field data in central directory.
109 public void setCentralDirectoryData(byte[] data) {
114 * Get the central data length. If there is no central data, get the local
117 * @return the central data length
119 public ZipShort getCentralDirectoryLength() {
120 if (centralData != null) {
121 return new ZipShort(centralData.length);
123 return getLocalFileDataLength();
127 * Get the central data.
129 * @return the central data if present, else return the local file data
131 public byte[] getCentralDirectoryData() {
132 if (centralData != null) {
135 return getLocalFileDataData();
140 * the array of bytes.
142 * the source location in the data array.
144 * the number of bytes to use in the data array.
145 * @see ZipExtraField#parseFromLocalFileData(byte[], int, int)
147 public void parseFromLocalFileData(byte[] data, int offset, int length) {
148 byte[] tmp = new byte[length];
149 System.arraycopy(data, offset, tmp, 0, length);
150 setLocalFileDataData(tmp);