blob: bce85c1d22860f230e9c85d5e3a530b5b189e705 [file] [log] [blame]
Torsten Curdtca165392008-07-10 10:17:44 +00001/*
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 * http://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 */
19package org.apache.commons.compress.archivers.zip;
20
21import java.util.zip.ZipException;
22
23/**
24 * General format of extra field data. <p>
25 *
26 * Extra fields usually appear twice per file, once in the local file data and
27 * once in the central directory. Usually they are the same, but they don't have
28 * to be. {@link java.util.zip.ZipOutputStream java.util.zip.ZipOutputStream}
29 * will only use the local file data in both places.</p>
Torsten Curdtca165392008-07-10 10:17:44 +000030 */
31public interface ZipExtraField
32{
33 /**
34 * The Header-ID.
35 *
36 * @return The HeaderId value
37 * @since 1.1
38 */
Torsten Curdtab9ebfc2009-01-12 11:15:34 +000039 ZipShort getHeaderId();
Torsten Curdtca165392008-07-10 10:17:44 +000040
41 /**
42 * Length of the extra field in the local file data - without Header-ID or
43 * length specifier.
44 *
45 * @return The LocalFileDataLength value
46 * @since 1.1
47 */
48 ZipShort getLocalFileDataLength();
49
50 /**
51 * Length of the extra field in the central directory - without Header-ID or
52 * length specifier.
53 *
54 * @return The CentralDirectoryLength value
55 * @since 1.1
56 */
57 ZipShort getCentralDirectoryLength();
58
59 /**
60 * The actual data to put into local file data - without Header-ID or length
61 * specifier.
62 *
63 * @return The LocalFileDataData value
64 * @since 1.1
65 */
66 byte[] getLocalFileDataData();
67
68 /**
69 * The actual data to put central directory - without Header-ID or length
70 * specifier.
71 *
72 * @return The CentralDirectoryData value
73 * @since 1.1
74 */
75 byte[] getCentralDirectoryData();
76
77 /**
78 * Populate data from this array as if it was in local file data.
79 *
80 * @param buffer the buffer to read data from
81 * @param offset offset into buffer to read data
82 * @param length the length of data
83 * @exception ZipException on error
84 * @since 1.1
85 */
86 void parseFromLocalFileData( byte[] buffer, int offset, int length )
87 throws ZipException;
88}