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 | 0 | { |
86 | 0 | this.file = file; |
87 | |
|
88 | 0 | this.manifest = manifest; |
89 | |
|
90 | 0 | this.entries = Collections.unmodifiableList( entries ); |
91 | |
|
92 | 0 | boolean sealed = false; |
93 | 0 | if ( this.manifest != null ) |
94 | |
{ |
95 | 0 | String sval = this.manifest.getMainAttributes().getValue( Attributes.Name.SEALED ); |
96 | 0 | if ( StringUtils.isNotEmpty( sval ) ) |
97 | |
{ |
98 | 0 | sealed = "true".equalsIgnoreCase( sval.trim() ); |
99 | |
} |
100 | |
} |
101 | 0 | this.sealed = sealed; |
102 | 0 | } |
103 | |
|
104 | |
public List getEntries() |
105 | |
{ |
106 | 0 | return entries; |
107 | |
} |
108 | |
|
109 | |
public Manifest getManifest() |
110 | |
{ |
111 | 0 | return manifest; |
112 | |
} |
113 | |
|
114 | |
public File getFile() |
115 | |
{ |
116 | 0 | return file; |
117 | |
} |
118 | |
|
119 | |
public boolean isSealed() |
120 | |
{ |
121 | 0 | return sealed; |
122 | |
} |
123 | |
|
124 | |
public void setFileHash( String fileHash ) |
125 | |
{ |
126 | 0 | this.fileHash = fileHash; |
127 | 0 | } |
128 | |
|
129 | |
public String getFileHash() |
130 | |
{ |
131 | 0 | return fileHash; |
132 | |
} |
133 | |
|
134 | |
public void setBytecodeHash( String bytecodeHash ) |
135 | |
{ |
136 | 0 | this.bytecodeHash = bytecodeHash; |
137 | 0 | } |
138 | |
|
139 | |
public String getBytecodeHash() |
140 | |
{ |
141 | 0 | return bytecodeHash; |
142 | |
} |
143 | |
|
144 | |
public boolean isDebugPresent() |
145 | |
{ |
146 | 0 | return jarClasses.isDebugPresent(); |
147 | |
} |
148 | |
|
149 | |
public void setJarClasses( JarClasses jarClasses ) |
150 | |
{ |
151 | 0 | this.jarClasses = jarClasses; |
152 | 0 | } |
153 | |
|
154 | |
public int getNumEntries() |
155 | |
{ |
156 | 0 | return entries.size(); |
157 | |
} |
158 | |
|
159 | |
public int getNumClasses() |
160 | |
{ |
161 | 0 | return jarClasses.getClassNames().size(); |
162 | |
} |
163 | |
|
164 | |
public int getNumPackages() |
165 | |
{ |
166 | 0 | return jarClasses.getPackages().size(); |
167 | |
} |
168 | |
|
169 | |
public String getJdkRevision() |
170 | |
{ |
171 | 0 | return jarClasses.getJdkRevision(); |
172 | |
} |
173 | |
|
174 | |
public void setJarIdentification( JarIdentification jarIdentification ) |
175 | |
{ |
176 | 0 | this.jarIdentification = jarIdentification; |
177 | 0 | } |
178 | |
|
179 | |
public JarIdentification getJarIdentification() |
180 | |
{ |
181 | 0 | return jarIdentification; |
182 | |
} |
183 | |
|
184 | |
public JarClasses getJarClasses() |
185 | |
{ |
186 | 0 | return jarClasses; |
187 | |
} |
188 | |
} |