    001/*
    002 *  Licensed to the Apache Software Foundation (ASF) under one or more
    003 *  contributor license agreements.  See the NOTICE file distributed with
    004 *  this work for additional information regarding copyright ownership.
    005 *  The ASF licenses this file to You under the Apache License, Version 2.0
    006 *  (the "License"); you may not use this file except in compliance with
    007 *  the License.  You may obtain a copy of the License at
    008 *
    009 *      http://www.apache.org/licenses/LICENSE-2.0
    010 *
    011 *  Unless required by applicable law or agreed to in writing, software
    012 *  distributed under the License is distributed on an "AS IS" BASIS,
    013 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    014 *  See the License for the specific language governing permissions and
    015 *  limitations under the License.
    016 *
    017 */
    018package org.apache.commons.compress.archivers.zip;
    019
    020import java.util.zip.ZipException;
    021
    022/**
    023 * Controls details of parsing zip extra fields.
    024 *
    025 * @since 1.19
    026 */
    027public interface ExtraFieldParsingBehavior extends UnparseableExtraFieldBehavior {
    028    /**
    029     * Creates an instance of ZipExtraField for the given id.
    030     *
    031     * <p>A good default implementation would be {@link
    032     * ExtraFieldUtils#createExtraField}.</p>
    033     *
    034     * @param headerId the id for the extra field
    035     * @return an instance of ZipExtraField, must not be {@code null}
    036     * @throws ZipException if an error occurs
    037     * @throws InstantiationException if unable to instantiate the class
    038     * @throws IllegalAccessException if not allowed to instantiate the class
    039     */
    040    ZipExtraField createExtraField(final ZipShort headerId)
    041        throws ZipException, InstantiationException, IllegalAccessException;
    042
    043    /**
    044     * Fills in the extra field data for a single extra field.
    045     *
    046     * <p>A good default implementation would be {@link
    047     * ExtraFieldUtils#fillExtraField}.</p>
    048     *
    049     * @param field the extra field instance to fill
    050     * @param data the array of extra field data
    051     * @param off offset into data where this field's data starts
    052     * @param len the length of this field's data
    053     * @param local whether the extra field data stems from the local
    054     * file header. If this is false then the data is part if the
    055     * central directory header extra data.
    056     * @return the filled field. Usually this is the same as {@code
    057     * field} but it could be a replacement extra field as well. Must
    058     * not be {@code null}.
    059     * @throws ZipException if an error occurs
    060     */
    061    ZipExtraField fill(ZipExtraField field, byte[] data, int off, int len, boolean local)
    062        throws ZipException;
    063}