| 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * https://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | package org.apache.commons.compress.archivers.zip; |
| 20 | |
| 21 | import java.util.zip.ZipException; |
| 22 | |
| 23 | /** |
| 24 | * Controls details of parsing ZIP extra fields. |
| 25 | * |
| 26 | * @since 1.19 |
| 27 | */ |
| 28 | public interface ExtraFieldParsingBehavior extends UnparseableExtraFieldBehavior { |
| 29 | |
| 30 | /** |
| 31 | * Creates an instance of ZipExtraField for the given id. |
| 32 | * <p> |
| 33 | * A good default implementation would be {@link ExtraFieldUtils#createExtraField}. |
| 34 | * </p> |
| 35 | * |
| 36 | * @param headerId the id for the extra field |
| 37 | * @return an instance of ZipExtraField, must not be {@code null} |
| 38 | * @throws ZipException if an error occurs |
| 39 | * @throws InstantiationException if unable to instantiate the class, not thrown by Commons Compress. |
| 40 | * @throws IllegalAccessException if not allowed to instantiate the class, not thrown by Commons Compress. |
| 41 | */ |
| 42 | ZipExtraField createExtraField(ZipShort headerId) throws ZipException, InstantiationException, IllegalAccessException; |
| 43 | |
| 44 | /** |
| 45 | * Fills in the extra field data for a single extra field. |
| 46 | * <p> |
| 47 | * A good default implementation would be {@link ExtraFieldUtils#fillExtraField}. |
| 48 | * </p> |
| 49 | * |
| 50 | * @param field the extra field instance to fill |
| 51 | * @param data the array of extra field data |
| 52 | * @param off offset into data where this field's data starts |
| 53 | * @param len the length of this field's data |
| 54 | * @param local whether the extra field data stems from the local file header. If this is false then the data is part if the central directory header extra |
| 55 | * data. |
| 56 | * @return the filled field. Usually this is the same as {@code |
| 57 | * field} but it could be a replacement extra field as well. Must not be {@code null}. |
| 58 | * @throws ZipException if an error occurs |
| 59 | */ |
| 60 | ZipExtraField fill(ZipExtraField field, byte[] data, int off, int len, boolean local) throws ZipException; |
| 61 | } |