1 package org.apache.maven.report.projectinfo;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.Locale;
23 import java.util.regex.Pattern;
24
25 import org.apache.maven.doxia.sink.Sink;
26 import org.apache.maven.reporting.AbstractMavenReportRenderer;
27 import org.codehaus.plexus.i18n.I18N;
28 import org.codehaus.plexus.util.StringUtils;
29
30
31
32
33
34 public abstract class AbstractProjectInfoRenderer
35 extends AbstractMavenReportRenderer
36 {
37
38
39
40 protected I18N i18n;
41
42
43
44
45 protected Locale locale;
46
47
48
49
50
51
52 public AbstractProjectInfoRenderer( Sink sink, I18N i18n, Locale locale )
53 {
54 super( sink );
55
56 this.i18n = i18n;
57
58 this.locale = locale;
59 }
60
61 @Override
62 public String getTitle()
63 {
64 return getI18nString( "title" );
65 }
66
67
68
69
70
71 protected String getI18nString( String key )
72 {
73 return getI18nString( getI18Nsection(), key );
74 }
75
76
77
78
79
80
81 protected String getI18nString( String section, String key )
82 {
83 return i18n.getString( "project-info-reports", locale, "report." + section + '.' + key );
84 }
85
86 @Override
87 protected void text( String text )
88 {
89 if ( StringUtils.isEmpty( text ) )
90 {
91 sink.text( "-" );
92 }
93 else
94 {
95
96 String regex = "(.+?)<(\"[^\"]*\"|'[^']*'|[^'\">])*>(.+?)";
97 if ( Pattern.matches( regex, text ) )
98 {
99 sink.rawText( text );
100 }
101 else
102 {
103 sink.text( text );
104 }
105 }
106 }
107
108 protected abstract String getI18Nsection();
109 }