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 | |
public abstract class AbstractProjectInfoRenderer |
31 | |
extends AbstractMavenReportRenderer |
32 | |
{ |
33 | |
private I18N i18n; |
34 | |
|
35 | |
private Locale locale; |
36 | |
|
37 | |
public AbstractProjectInfoRenderer( Sink sink, I18N i18n, Locale locale ) |
38 | |
{ |
39 | 16 | super( sink ); |
40 | |
|
41 | 16 | this.i18n = i18n; |
42 | |
|
43 | 16 | this.locale = locale; |
44 | 16 | } |
45 | |
|
46 | |
@Override |
47 | |
public String getTitle() |
48 | |
{ |
49 | 25 | return getI18nString( "title" ); |
50 | |
} |
51 | |
|
52 | |
protected String getI18nString( String key ) |
53 | |
{ |
54 | 118 | return getI18nString( getI18Nsection(), key ); |
55 | |
} |
56 | |
|
57 | |
protected String getI18nString( String section, String key ) |
58 | |
{ |
59 | 125 | return i18n.getString( "project-info-report", locale, "report." + section + '.' + key ); |
60 | |
} |
61 | |
|
62 | |
@Override |
63 | |
protected void text( String text ) |
64 | |
{ |
65 | 163 | if ( StringUtils.isEmpty( text ) ) |
66 | |
{ |
67 | 6 | sink.text( "-" ); |
68 | |
} |
69 | |
else |
70 | |
{ |
71 | |
|
72 | 157 | String regex = "(.+?)<(\"[^\"]*\"|'[^']*'|[^'\">])*>(.+?)"; |
73 | 157 | if ( Pattern.matches( regex, text ) ) |
74 | |
{ |
75 | 0 | sink.rawText( text ); |
76 | |
} |
77 | |
else |
78 | |
{ |
79 | 157 | sink.text( text ); |
80 | |
} |
81 | |
} |
82 | 163 | } |
83 | |
|
84 | |
protected abstract String getI18Nsection(); |
85 | |
} |