1 package org.apache.maven.plugins.jdeps.consumers;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.HashMap;
23 import java.util.Map;
24 import java.util.regex.Matcher;
25 import java.util.regex.Pattern;
26
27 import org.codehaus.plexus.util.cli.CommandLineUtils;
28 import org.codehaus.plexus.util.cli.StreamConsumer;
29
30
31
32
33
34
35
36 public class JDepsConsumer
37 extends CommandLineUtils.StringStreamConsumer
38 implements StreamConsumer
39 {
40
41
42
43
44
45
46 private static final Pattern JDKINTERNALAPI = Pattern.compile( ".+->\\s([a-z\\.]+)\\s+(JDK internal API .+)" );
47
48
49
50
51
52
53
54 private Map<String, String> offendingPackages = new HashMap<String, String>();
55
56 private static final Pattern PROFILE = Pattern.compile( "\\s+->\\s([a-z\\.]+)\\s+(\\S+)" );
57
58
59
60
61
62
63
64 private Map<String, String> profiles = new HashMap<String, String>();
65
66
67 public void consumeLine( String line )
68 {
69 super.consumeLine( line );
70 Matcher matcher;
71
72 matcher = JDKINTERNALAPI.matcher( line );
73 if ( matcher.matches() )
74 {
75 offendingPackages.put( matcher.group( 1 ), matcher.group( 2 ) );
76 return;
77 }
78
79 matcher = PROFILE.matcher( line );
80 if ( matcher.matches() )
81 {
82 profiles.put( matcher.group( 1 ), matcher.group( 2 ) );
83 return;
84 }
85 }
86
87 public Map<String, String> getOffendingPackages()
88 {
89 return offendingPackages;
90 }
91
92 public Map<String, String> getProfiles()
93 {
94 return profiles;
95 }
96
97 }