1 | |
package org.apache.maven.shared.jar.identification.exposers; |
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.JarAnalyzer; |
23 | |
import org.apache.maven.shared.jar.identification.JarIdentification; |
24 | |
import org.apache.maven.shared.jar.identification.JarIdentificationExposer; |
25 | |
|
26 | |
import java.util.Iterator; |
27 | |
import java.util.Map; |
28 | |
import java.util.jar.Attributes; |
29 | |
import java.util.jar.Manifest; |
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | 0 | public class ManifestExposer |
37 | |
implements JarIdentificationExposer |
38 | |
{ |
39 | |
public void expose( JarIdentification identification, JarAnalyzer jarAnalyzer ) |
40 | |
{ |
41 | 0 | Manifest manifest = jarAnalyzer.getJarData().getManifest(); |
42 | 0 | if ( manifest != null ) |
43 | |
{ |
44 | 0 | addManifestAttributeValues( manifest.getMainAttributes(), identification ); |
45 | |
|
46 | 0 | Map entries = manifest.getEntries(); |
47 | 0 | Iterator itentries = entries.entrySet().iterator(); |
48 | 0 | while ( itentries.hasNext() ) |
49 | |
{ |
50 | 0 | Map.Entry entry = (Map.Entry) itentries.next(); |
51 | 0 | Attributes attribs = (Attributes) entry.getValue(); |
52 | |
|
53 | 0 | addManifestAttributeValues( attribs, identification ); |
54 | 0 | } |
55 | |
} |
56 | 0 | } |
57 | |
|
58 | |
private void addManifestAttributeValues( Attributes attribs, JarIdentification identification ) |
59 | |
{ |
60 | 0 | identification.addName( attribs.getValue( Attributes.Name.IMPLEMENTATION_TITLE ) ); |
61 | 0 | identification.addVersion( attribs.getValue( Attributes.Name.IMPLEMENTATION_VERSION ) ); |
62 | 0 | identification.addVendor( attribs.getValue( Attributes.Name.IMPLEMENTATION_VENDOR ) ); |
63 | |
|
64 | 0 | identification.addName( attribs.getValue( Attributes.Name.SPECIFICATION_TITLE ) ); |
65 | 0 | identification.addVersion( attribs.getValue( Attributes.Name.SPECIFICATION_VERSION ) ); |
66 | 0 | identification.addVendor( attribs.getValue( Attributes.Name.SPECIFICATION_VENDOR ) ); |
67 | |
|
68 | 0 | identification.addGroupId( attribs.getValue( Attributes.Name.EXTENSION_NAME ) ); |
69 | 0 | } |
70 | |
} |