001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one
003     * or more contributor license agreements.  See the NOTICE file
004     * distributed with this work for additional information
005     * regarding copyright ownership.  The ASF licenses this file
006     * to you under the Apache License, Version 2.0 (the
007     * "License"); you may not use this file except in compliance
008     * with the License.  You may obtain a copy of the License at
009     *
010     * http://www.apache.org/licenses/LICENSE-2.0
011     *
012     * Unless required by applicable law or agreed to in writing,
013     * software distributed under the License is distributed on an
014     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     * KIND, either express or implied.  See the License for the
016     * specific language governing permissions and limitations
017     * under the License.
018     */
019    package org.apache.commons.compress.archivers.zip;
020    
021    import java.util.zip.ZipException;
022    
023    /**
024     * General format of extra field data. <p>
025     *
026     * Extra fields usually appear twice per file, once in the local file data and
027     * once in the central directory. Usually they are the same, but they don't have
028     * to be. {@link java.util.zip.ZipOutputStream java.util.zip.ZipOutputStream}
029     * will only use the local file data in both places.</p>
030     */
031    public interface ZipExtraField {
032        /**
033         * The Header-ID.
034         *
035         * @return The HeaderId value
036         */
037        ZipShort getHeaderId();
038    
039        /**
040         * Length of the extra field in the local file data - without Header-ID or
041         * length specifier.
042         *
043         * @return The LocalFileDataLength value
044         */
045        ZipShort getLocalFileDataLength();
046    
047        /**
048         * Length of the extra field in the central directory - without Header-ID or
049         * length specifier.
050         *
051         * @return The CentralDirectoryLength value
052         */
053        ZipShort getCentralDirectoryLength();
054    
055        /**
056         * The actual data to put into local file data - without Header-ID or length
057         * specifier.
058         *
059         * @return The LocalFileDataData value
060         */
061        byte[] getLocalFileDataData();
062    
063        /**
064         * The actual data to put into central directory - without Header-ID or
065         * length specifier.
066         *
067         * @return The CentralDirectoryData value
068         */
069        byte[] getCentralDirectoryData();
070    
071        /**
072         * Populate data from this array as if it was in local file data.
073         *
074         * @param buffer the buffer to read data from
075         * @param offset offset into buffer to read data
076         * @param length the length of data
077         * @exception ZipException on error
078         */
079        void parseFromLocalFileData(byte[] buffer, int offset, int length)
080            throws ZipException;
081    
082        /**
083         * Populate data from this array as if it was in central directory data.
084         *
085         * @param buffer the buffer to read data from
086         * @param offset offset into buffer to read data
087         * @param length the length of data
088         * @exception ZipException on error
089         */
090        void parseFromCentralDirectoryData(byte[] buffer, int offset, int length)
091            throws ZipException;
092    }