1 package org.apache.maven.plugin.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 private static final Pattern JDKINTERNALAPI = Pattern.compile( "\\s+->\\s([a-z\\.]+)\\s+(JDK internal API .+)" );
46
47
48
49
50
51
52
53 private Map<String, String> offendingPackages = new HashMap<String, String>();
54
55 private static final Pattern PROFILE = Pattern.compile( "\\s+->\\s([a-z\\.]+)\\s+(\\S+)" );
56
57
58
59
60
61
62
63 private Map<String, String> profiles = new HashMap<String, String>();
64
65
66 public void consumeLine( String line )
67 {
68 super.consumeLine( line );
69 Matcher matcher;
70
71 matcher = JDKINTERNALAPI.matcher( line );
72 if ( matcher.matches() )
73 {
74 offendingPackages.put( matcher.group( 1 ), matcher.group( 2 ) );
75 return;
76 }
77
78 matcher = PROFILE.matcher( line );
79 if ( matcher.matches() )
80 {
81 profiles.put( matcher.group( 1 ), matcher.group( 2 ) );
82 return;
83 }
84 }
85
86 public Map<String, String> getOffendingPackages()
87 {
88 return offendingPackages;
89 }
90
91 public Map<String, String> getProfiles()
92 {
93 return profiles;
94 }
95
96 }