01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: package org.apache.pluto.ant;
18:
19: import java.io.File;
20: import java.io.FileInputStream;
21: import java.util.jar.JarEntry;
22: import java.util.jar.JarInputStream;
23:
24: import org.apache.tools.ant.BuildException;
25: import org.apache.tools.ant.Task;
26:
27: public class ExamineArchiveTask extends Task {
28:
29: private File archive = null;
30:
31: public void execute() throws BuildException {
32: try {
33:
34: JarInputStream jarIn = new JarInputStream(
35: new FileInputStream(archive));
36: JarEntry entry;
37: while ((entry = jarIn.getNextJarEntry()) != null) {
38: String name = entry.getName();
39: long crc = entry.getCrc();
40: long size = entry.getSize();
41: long compressedSize = entry.getCompressedSize();
42: int compressMethod = entry.getMethod();
43: long timeStamp = entry.getTime();
44: int hashCode = entry.hashCode();
45:
46: StringBuffer out = new StringBuffer();
47:
48: out.append("Name: " + name + "\n");
49: out.append(" Size: " + Long.toHexString(size) + " ");
50: out.append(" Compressed Size: "
51: + Long.toHexString(compressedSize) + " ");
52: out.append(" Compression Method: " + compressMethod
53: + " ");
54: out.append(" Timestamp: "
55: + Long.toHexString(timeStamp) + " ");
56: out.append(" HashCode: "
57: + Integer.toHexString(hashCode) + " ");
58: out.append(" CRC: " + Long.toHexString(crc) + " ");
59:
60: System.out.println(out.toString());
61:
62: }
63:
64: } catch (Exception e) {
65: throw new BuildException(e.getMessage(), e);
66: }
67:
68: }
69:
70: public void setArchive(File archive) {
71: this .archive = archive;
72: }
73:
74: public File getArchive() {
75: return this.archive;
76: }
77:
78: }
|