source: other-projects/trunk/gs3-release-maker/apache-ant-1.6.5/src/main/org/apache/tools/zip/JarMarker.java@ 14627

Last change on this file since 14627 was 14627, checked in by oranfry, 17 years ago

initial import of the gs3-release-maker

File size: 2.9 KB
Line 
1/*
2 * Copyright 2005 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18package org.apache.tools.zip;
19
20import java.util.zip.ZipException;
21
22/**
23 * If this extra field is added as the very first extra field of the
24 * archive, Solaris will consider it an executable jar file.
25 *
26 * @since Ant 1.6.3
27 */
28public final class JarMarker implements ZipExtraField {
29
30 private static ZipShort ID = new ZipShort(0xCAFE);
31 private static ZipShort NULL = new ZipShort(0);
32 private static byte[] NO_BYTES = new byte[0];
33 private static JarMarker DEFAULT = new JarMarker();
34
35 public JarMarker() {
36 // empty
37 }
38
39 /**
40 * Since JarMarker is stateless we can always use the same instance.
41 */
42 public static JarMarker getInstance() {
43 return DEFAULT;
44 }
45
46 /**
47 * The Header-ID.
48 * @return the header id
49 */
50 public ZipShort getHeaderId() {
51 return ID;
52 }
53
54 /**
55 * Length of the extra field in the local file data - without
56 * Header-ID or length specifier.
57 * @return 0
58 */
59 public ZipShort getLocalFileDataLength() {
60 return NULL;
61 }
62
63 /**
64 * Length of the extra field in the central directory - without
65 * Header-ID or length specifier.
66 * @return 0
67 */
68 public ZipShort getCentralDirectoryLength() {
69 return NULL;
70 }
71
72 /**
73 * The actual data to put into local file data - without Header-ID
74 * or length specifier.
75 * @return the data
76 * @since 1.1
77 */
78 public byte[] getLocalFileDataData() {
79 return NO_BYTES;
80 }
81
82 /**
83 * The actual data to put central directory - without Header-ID or
84 * length specifier.
85 * @return the data
86 */
87 public byte[] getCentralDirectoryData() {
88 return NO_BYTES;
89 }
90
91 /**
92 * Populate data from this array as if it was in local file data.
93 * @param data an array of bytes
94 * @param offset the start offset
95 * @param length the number of bytes in the array from offset
96 *
97 * @throws ZipException on error
98 */
99 public void parseFromLocalFileData(byte[] data, int offset, int length)
100 throws ZipException {
101 if (length != 0) {
102 throw new ZipException("JarMarker doesn't expect any data");
103 }
104 }
105}
Note: See TracBrowser for help on using the repository browser.