1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.shared.jar;
20
21 import java.io.File;
22 import java.util.Collections;
23 import java.util.List;
24 import java.util.jar.Attributes;
25 import java.util.jar.JarEntry;
26 import java.util.jar.Manifest;
27
28 import org.apache.maven.shared.jar.classes.JarClasses;
29 import org.apache.maven.shared.jar.identification.JarIdentification;
30 import org.codehaus.plexus.util.StringUtils;
31
32
33
34
35 public final class JarData {
36
37
38
39 private final File file;
40
41
42
43
44 private final boolean aSealed;
45
46
47
48
49 private String fileHash;
50
51
52
53
54 private String bytecodeHash;
55
56
57
58
59 private final Manifest manifest;
60
61
62
63
64 private JarClasses jarClasses;
65
66
67
68
69 private final List<JarEntry> entries;
70
71
72
73
74 private JarIdentification jarIdentification;
75
76
77
78
79
80
81
82
83 public JarData(File file, Manifest manifest, List<JarEntry> entries) {
84 this.file = file;
85
86 this.manifest = manifest;
87
88 this.entries = Collections.unmodifiableList(entries);
89
90 boolean aSealed = false;
91 if (this.manifest != null) {
92 String sval = this.manifest.getMainAttributes().getValue(Attributes.Name.SEALED);
93 if (StringUtils.isNotEmpty(sval)) {
94 aSealed = "true".equalsIgnoreCase(sval.trim());
95 }
96 }
97 this.aSealed = aSealed;
98 }
99
100 public List<JarEntry> getEntries() {
101 return entries;
102 }
103
104 public Manifest getManifest() {
105 return manifest;
106 }
107
108 public File getFile() {
109 return file;
110 }
111
112 public boolean isSealed() {
113 return aSealed;
114 }
115
116 public void setFileHash(String fileHash) {
117 this.fileHash = fileHash;
118 }
119
120 public String getFileHash() {
121 return fileHash;
122 }
123
124 public void setBytecodeHash(String bytecodeHash) {
125 this.bytecodeHash = bytecodeHash;
126 }
127
128 public String getBytecodeHash() {
129 return bytecodeHash;
130 }
131
132 public boolean isDebugPresent() {
133 return jarClasses.isDebugPresent();
134 }
135
136 public void setJarClasses(JarClasses jarClasses) {
137 this.jarClasses = jarClasses;
138 }
139
140 public int getNumEntries() {
141 return entries.size();
142 }
143
144 public int getNumClasses() {
145 return jarClasses.getClassNames().size();
146 }
147
148 public int getNumPackages() {
149 return jarClasses.getPackages().size();
150 }
151
152 public String getJdkRevision() {
153 return jarClasses.getJdkRevision();
154 }
155
156 public void setJarIdentification(JarIdentification jarIdentification) {
157 this.jarIdentification = jarIdentification;
158 }
159
160 public JarIdentification getJarIdentification() {
161 return jarIdentification;
162 }
163
164 public JarClasses getJarClasses() {
165 return jarClasses;
166 }
167 }