applied LGPLv3 and source code formatting.
[vamsas.git] / src / org / apache / tools / zip / ZipExtraField.java
1 /*
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
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  *
17  */
18
19 package org.apache.tools.zip;
20
21 import java.util.zip.ZipException;
22
23 /**
24  * General format of extra field data.
25  * 
26  * <p>
27  * Extra fields usually appear twice per file, once in the local file data and
28  * once in the central directory. Usually they are the same, but they don't have
29  * to be. {@link java.util.zip.ZipOutputStream java.util.zip.ZipOutputStream}
30  * will only use the local file data in both places.
31  * </p>
32  * 
33  */
34 public interface ZipExtraField {
35
36   /**
37    * The Header-ID.
38    * 
39    * @return the header id
40    * @since 1.1
41    */
42   ZipShort getHeaderId();
43
44   /**
45    * Length of the extra field in the local file data - without Header-ID or
46    * length specifier.
47    * 
48    * @return the length of the field in the local file data
49    * @since 1.1
50    */
51   ZipShort getLocalFileDataLength();
52
53   /**
54    * Length of the extra field in the central directory - without Header-ID or
55    * length specifier.
56    * 
57    * @return the length of the field in the central directory
58    * @since 1.1
59    */
60   ZipShort getCentralDirectoryLength();
61
62   /**
63    * The actual data to put into local file data - without Header-ID or length
64    * specifier.
65    * 
66    * @return the data
67    * @since 1.1
68    */
69   byte[] getLocalFileDataData();
70
71   /**
72    * The actual data to put central directory - without Header-ID or length
73    * specifier.
74    * 
75    * @return the data
76    * @since 1.1
77    */
78   byte[] getCentralDirectoryData();
79
80   /**
81    * Populate data from this array as if it was in local file data.
82    * 
83    * @param data
84    *          an array of bytes
85    * @param offset
86    *          the start offset
87    * @param length
88    *          the number of bytes in the array from offset
89    * 
90    * @since 1.1
91    * @throws ZipException
92    *           on error
93    */
94   void parseFromLocalFileData(byte[] data, int offset, int length)
95       throws ZipException;
96 }