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