Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ProjectIndexPageReport |
|
| 1.25;1,25 | ||||
ProjectIndexPageReport$ProjectIndexRenderer |
|
| 1.25;1,25 |
1 | package org.apache.maven.report.projectinfo; | |
2 | ||
3 | /* | |
4 | * Licensed to the Apache Software Foundation (ASF) under one | |
5 | * or more contributor license agreements. See the NOTICE file | |
6 | * distributed with this work for additional information | |
7 | * regarding copyright ownership. The ASF licenses this file | |
8 | * to you under the Apache License, Version 2.0 (the | |
9 | * "License"); you may not use this file except in compliance | |
10 | * with the License. You may obtain a copy of the License at | |
11 | * | |
12 | * http://www.apache.org/licenses/LICENSE-2.0 | |
13 | * | |
14 | * Unless required by applicable law or agreed to in writing, | |
15 | * software distributed under the License is distributed on an | |
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
17 | * KIND, either express or implied. See the License for the | |
18 | * specific language governing permissions and limitations | |
19 | * under the License. | |
20 | */ | |
21 | ||
22 | import org.apache.maven.doxia.sink.Sink; | |
23 | import org.apache.maven.plugins.annotations.Mojo; | |
24 | import org.apache.maven.reporting.AbstractMavenReportRenderer; | |
25 | ||
26 | import java.util.Locale; | |
27 | ||
28 | /** | |
29 | * Generates the project index page. | |
30 | * | |
31 | * @author <a href="mailto:brett@apache.org">Brett Porter </a> | |
32 | * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton </a> | |
33 | * @version $Id: ProjectIndexPageReport.java 1359783 2012-07-10 16:57:48Z tchemit $ | |
34 | * @since 2.0 | |
35 | */ | |
36 | @Mojo( name = "index" ) | |
37 | 1 | public class ProjectIndexPageReport |
38 | extends AbstractProjectInfoReport | |
39 | { | |
40 | // ---------------------------------------------------------------------- | |
41 | // Public methods | |
42 | // ---------------------------------------------------------------------- | |
43 | ||
44 | @Override | |
45 | public String getName( Locale locale ) | |
46 | { | |
47 | 2 | return getI18nString( locale, "title" ); |
48 | } | |
49 | ||
50 | @Override | |
51 | public String getDescription( Locale locale ) | |
52 | { | |
53 | String desc; | |
54 | 1 | if ( project.getDescription() != null ) |
55 | { | |
56 | // TODO How to handle i18n? | |
57 | 0 | desc = project.getDescription(); |
58 | } | |
59 | else | |
60 | { | |
61 | 1 | return getI18nString( locale, "nodescription" ); |
62 | } | |
63 | 0 | return desc; |
64 | } | |
65 | ||
66 | @Override | |
67 | public void executeReport( Locale locale ) | |
68 | { | |
69 | 1 | ProjectIndexRenderer r = |
70 | new ProjectIndexRenderer( getName( locale ), project.getName(), getDescription( locale ), getSink() ); | |
71 | ||
72 | 1 | r.render(); |
73 | 1 | } |
74 | ||
75 | /** {@inheritDoc} */ | |
76 | public String getOutputName() | |
77 | { | |
78 | 2 | return "index"; |
79 | } | |
80 | ||
81 | @Override | |
82 | protected String getI18Nsection() | |
83 | { | |
84 | 3 | return "index"; |
85 | } | |
86 | ||
87 | // ---------------------------------------------------------------------- | |
88 | // Private | |
89 | // ---------------------------------------------------------------------- | |
90 | ||
91 | /** | |
92 | * Internal renderer class | |
93 | */ | |
94 | 1 | private static class ProjectIndexRenderer |
95 | extends AbstractMavenReportRenderer | |
96 | { | |
97 | private final String title; | |
98 | ||
99 | private final String description; | |
100 | ||
101 | private final String name; | |
102 | ||
103 | ProjectIndexRenderer( String title, String name, String description, Sink sink ) | |
104 | { | |
105 | 1 | super( sink ); |
106 | ||
107 | 1 | this.title = title; |
108 | ||
109 | 1 | this.description = description; |
110 | ||
111 | 1 | this.name = name; |
112 | 1 | } |
113 | ||
114 | @Override | |
115 | public String getTitle() | |
116 | { | |
117 | 1 | return title; |
118 | } | |
119 | ||
120 | @Override | |
121 | public void renderBody() | |
122 | { | |
123 | 1 | startSection( title.trim() + " " + name ); |
124 | ||
125 | 1 | paragraph( description ); |
126 | ||
127 | 1 | endSection(); |
128 | 1 | } |
129 | } | |
130 | } |