This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch backport1
in repository https://gitbox.apache.org/repos/asf/maven-reporting-impl.git

commit 126bf94a361e476d09049ed9ecc9a23d11228912
Author: Sylwester Lachiewicz <slachiew...@apache.org>
AuthorDate: Sun Feb 4 17:07:15 2024 +0100

    Reformat with spotless
---
 .../maven/reporting/AbstractMavenReport.java       | 280 +++++++----------
 .../reporting/AbstractMavenReportRenderer.java     | 347 ++++++++-------------
 .../reporting/AbstractMavenReportRendererTest.java | 106 +++----
 3 files changed, 291 insertions(+), 442 deletions(-)

diff --git a/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java 
b/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java
index 83d7236..afc71d9 100644
--- a/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java
+++ b/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java
@@ -1,5 +1,3 @@
-package org.apache.maven.reporting;
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.reporting;
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
  *
- *  http://www.apache.org/licenses/LICENSE-2.0
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
@@ -18,6 +16,17 @@ package org.apache.maven.reporting;
  * specific language governing permissions and limitations
  * under the License.
  */
+package org.apache.maven.reporting;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.repository.ArtifactRepository;
@@ -47,16 +56,6 @@ import org.codehaus.plexus.util.ReaderFactory;
 
 import static org.apache.maven.shared.utils.logging.MessageUtils.buffer;
 
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
 /**
  * The basis for a Maven report which can be generated both as part of a site 
generation or
  * as a direct standalone goal invocation.
@@ -73,46 +72,43 @@ import java.util.Map;
  *  from maven-reporting-api
  * @see #executeReport(Locale) <code>abstract executeReport( Locale )</code>
  */
-public abstract class AbstractMavenReport
-    extends AbstractMojo
-    implements MavenMultiPageReport, Contextualizable
-{
+public abstract class AbstractMavenReport extends AbstractMojo implements 
MavenMultiPageReport, Contextualizable {
     /**
      * The output directory for the report. Note that this parameter is only 
evaluated if the goal is run directly from
      * the command line. If the goal is run indirectly as part of a site 
generation, the output directory configured in
      * the Maven Site Plugin is used instead.
      */
-    @Parameter( defaultValue = "${project.reporting.outputDirectory}", 
readonly = true, required = true )
+    @Parameter(defaultValue = "${project.reporting.outputDirectory}", readonly 
= true, required = true)
     protected File outputDirectory;
 
     /**
      * The Maven Project.
      */
-    @Parameter( defaultValue = "${project}", readonly = true, required = true )
+    @Parameter(defaultValue = "${project}", readonly = true, required = true)
     protected MavenProject project;
 
     /**
      * Specifies the input encoding.
      */
-    @Parameter( property = "encoding", defaultValue = 
"${project.build.sourceEncoding}", readonly = true )
+    @Parameter(property = "encoding", defaultValue = 
"${project.build.sourceEncoding}", readonly = true)
     private String inputEncoding;
 
     /**
      * Specifies the output encoding.
      */
-    @Parameter( property = "outputEncoding", defaultValue = 
"${project.reporting.outputEncoding}", readonly = true )
+    @Parameter(property = "outputEncoding", defaultValue = 
"${project.reporting.outputEncoding}", readonly = true)
     private String outputEncoding;
 
     /**
      * The local repository.
      */
-    @Parameter( defaultValue = "${localRepository}", readonly = true, required 
= true )
+    @Parameter(defaultValue = "${localRepository}", readonly = true, required 
= true)
     protected ArtifactRepository localRepository;
 
     /**
      * Remote repositories used for the project.
      */
-    @Parameter( defaultValue = "${project.remoteArtifactRepositories}", 
readonly = true, required = true )
+    @Parameter(defaultValue = "${project.remoteArtifactRepositories}", 
readonly = true, required = true)
     protected List<ArtifactRepository> remoteRepositories;
 
     /**
@@ -139,7 +135,7 @@ public abstract class AbstractMavenReport
     /**
      * The output format: null by default, to represent a site, but can be 
configured to a Doxia sink.
      */
-    @Parameter( property = "output.format" )
+    @Parameter(property = "output.format")
     protected String outputFormat;
 
     private PlexusContainer container;
@@ -151,153 +147,120 @@ public abstract class AbstractMavenReport
      * @see org.apache.maven.plugin.Mojo#execute()
      */
     @Override
-    public void execute()
-        throws MojoExecutionException
-    {
-        if ( !canGenerateReport() )
-        {
+    public void execute() throws MojoExecutionException {
+        if (!canGenerateReport()) {
             return;
         }
 
-        if ( outputFormat != null )
-        {
+        if (outputFormat != null) {
             reportToMarkup();
-        }
-        else
-        {
+        } else {
             reportToSite();
         }
     }
 
-    private void reportToMarkup()
-        throws MojoExecutionException
-    {
-        getLog().info( "Rendering to " + outputFormat + " markup" );
+    private void reportToMarkup() throws MojoExecutionException {
+        getLog().info("Rendering to " + outputFormat + " markup");
 
-        if ( !isExternalReport() )
-        {
-            try
-            {
-                sinkFactory = container.lookup( SinkFactory.class, 
outputFormat );
-                String extension = "markdown".equals( outputFormat ) ? "md" : 
outputFormat; // TODO
-                sink = sinkFactory.createSink( outputDirectory, 
getOutputName() + '.' + extension );
-            }
-            catch ( ComponentLookupException cle )
-            {
+        if (!isExternalReport()) {
+            try {
+                sinkFactory = container.lookup(SinkFactory.class, 
outputFormat);
+                String extension = "markdown".equals(outputFormat) ? "md" : 
outputFormat; // TODO
+                sink = sinkFactory.createSink(outputDirectory, getOutputName() 
+ '.' + extension);
+            } catch (ComponentLookupException cle) {
                 throw new MojoExecutionException(
-                    "Cannot find SinkFactory for Doxia output format: " + 
outputFormat, cle );
-            }
-            catch ( IOException ioe )
-            {
-                throw new MojoExecutionException( "Cannot create sink for " + 
outputDirectory, ioe );
+                        "Cannot find SinkFactory for Doxia output format: " + 
outputFormat, cle);
+            } catch (IOException ioe) {
+                throw new MojoExecutionException("Cannot create sink for " + 
outputDirectory, ioe);
             }
         }
 
-        try
-        {
+        try {
             Locale locale = Locale.ROOT;
-            generate( sink, sinkFactory, locale );
-        }
-        catch ( MavenReportException mre )
-        {
+            generate(sink, sinkFactory, locale);
+        } catch (MavenReportException mre) {
             throw new MojoExecutionException(
-                    "An error has occurred in " + getName( Locale.ENGLISH ) + 
" report generation.", mre );
-        }
-        finally
-        {
-            if ( sink != null )
-            {
+                    "An error has occurred in " + getName(Locale.ENGLISH) + " 
report generation.", mre);
+        } finally {
+            if (sink != null) {
                 sink.close();
             }
         }
     }
 
-    private void reportToSite()
-        throws MojoExecutionException
-    {
-        File outputDirectory = new File( getOutputDirectory() );
+    private void reportToSite() throws MojoExecutionException {
+        File outputDirectory = new File(getOutputDirectory());
 
         String filename = getOutputName() + ".html";
 
         Locale locale = Locale.getDefault();
 
-        try
-        {
-            SiteRenderingContext siteContext = createSiteRenderingContext( 
locale );
+        try {
+            SiteRenderingContext siteContext = 
createSiteRenderingContext(locale);
 
             // copy resources
-            getSiteRenderer().copyResources( siteContext, outputDirectory );
+            getSiteRenderer().copyResources(siteContext, outputDirectory);
 
             // TODO Replace null with real value
-            RenderingContext docRenderingContext = new RenderingContext( 
outputDirectory, filename, null );
+            RenderingContext docRenderingContext = new 
RenderingContext(outputDirectory, filename, null);
 
-            SiteRendererSink sink = new SiteRendererSink( docRenderingContext 
);
+            SiteRendererSink sink = new SiteRendererSink(docRenderingContext);
 
-            generate( sink, null, locale );
+            generate(sink, null, locale);
 
-            if ( !isExternalReport() ) // MSHARED-204: only render Doxia sink 
if not an external report
+            if (!isExternalReport()) // MSHARED-204: only render Doxia sink if 
not an external report
             {
                 outputDirectory.mkdirs();
 
-                try ( Writer writer =
-                      new OutputStreamWriter( new FileOutputStream( new File( 
outputDirectory, filename ) ),
-                                              getOutputEncoding() ) )
-                {
+                try (Writer writer = new OutputStreamWriter(
+                        new FileOutputStream(new File(outputDirectory, 
filename)), getOutputEncoding())) {
                     // render report
-                    getSiteRenderer().mergeDocumentIntoSite( writer, sink, 
siteContext );
+                    getSiteRenderer().mergeDocumentIntoSite(writer, sink, 
siteContext);
                 }
             }
 
             // copy generated resources also
-            getSiteRenderer().copyResources( siteContext, outputDirectory );
-        }
-        catch ( RendererException | IOException | MavenReportException e )
-        {
+            getSiteRenderer().copyResources(siteContext, outputDirectory);
+        } catch (RendererException | IOException | MavenReportException e) {
             throw new MojoExecutionException(
-                "An error has occurred in " + getName( Locale.ENGLISH ) + " 
report generation.", e );
+                    "An error has occurred in " + getName(Locale.ENGLISH) + " 
report generation.", e);
         }
     }
 
-    private SiteRenderingContext createSiteRenderingContext( Locale locale )
-        throws MavenReportException, IOException
-    {
+    private SiteRenderingContext createSiteRenderingContext(Locale locale) 
throws MavenReportException, IOException {
         DecorationModel decorationModel = new DecorationModel();
 
         Map<String, Object> templateProperties = new HashMap<>();
         // We tell the skin that we are rendering in standalone mode
-        templateProperties.put( "standalone", Boolean.TRUE );
-        templateProperties.put( "project", getProject() );
-        templateProperties.put( "inputEncoding", getInputEncoding() );
-        templateProperties.put( "outputEncoding", getOutputEncoding() );
+        templateProperties.put("standalone", Boolean.TRUE);
+        templateProperties.put("project", getProject());
+        templateProperties.put("inputEncoding", getInputEncoding());
+        templateProperties.put("outputEncoding", getOutputEncoding());
         // Put any of the properties in directly into the Velocity context
-        for ( Map.Entry<Object, Object> entry : 
getProject().getProperties().entrySet() )
-        {
-            templateProperties.put( (String) entry.getKey(), entry.getValue() 
);
+        for (Map.Entry<Object, Object> entry : 
getProject().getProperties().entrySet()) {
+            templateProperties.put((String) entry.getKey(), entry.getValue());
         }
 
         SiteRenderingContext context;
-        try
-        {
-           Artifact skinArtifact =
-               siteTool.getSkinArtifactFromRepository( localRepository, 
remoteRepositories, decorationModel );
-
-           getLog().info( buffer().a( "Rendering content with " ).strong( 
skinArtifact.getId()
-               + " skin" ).a( '.' ).toString() );
-
-            context = siteRenderer.createContextForSkin( skinArtifact, 
templateProperties, decorationModel,
-                                                         project.getName(), 
locale );
-        }
-        catch ( SiteToolException e )
-        {
-            throw new MavenReportException( "Failed to retrieve skin 
artifact", e );
-        }
-        catch ( RendererException e )
-        {
-            throw new MavenReportException( "Failed to create context for 
skin", e );
+        try {
+            Artifact skinArtifact =
+                    siteTool.getSkinArtifactFromRepository(localRepository, 
remoteRepositories, decorationModel);
+
+            getLog().info(buffer().a("Rendering content with ")
+                    .strong(skinArtifact.getId() + " skin")
+                    .a('.')
+                    .toString());
+
+            context = siteRenderer.createContextForSkin(
+                    skinArtifact, templateProperties, decorationModel, 
project.getName(), locale);
+        } catch (SiteToolException e) {
+            throw new MavenReportException("Failed to retrieve skin artifact", 
e);
+        } catch (RendererException e) {
+            throw new MavenReportException("Failed to create context for 
skin", e);
         }
 
         // Generate static site
-        context.setRootDirectory( project.getBasedir() );
+        context.setRootDirectory(project.getBasedir());
 
         return context;
     }
@@ -312,10 +275,8 @@ public abstract class AbstractMavenReport
      */
     @Deprecated
     @Override
-    public void generate( org.codehaus.doxia.sink.Sink sink, Locale locale )
-        throws MavenReportException
-    {
-        generate( sink, null, locale );
+    public void generate(org.codehaus.doxia.sink.Sink sink, Locale locale) 
throws MavenReportException {
+        generate(sink, null, locale);
     }
 
     /**
@@ -327,10 +288,8 @@ public abstract class AbstractMavenReport
      * @deprecated use {@link #generate(Sink, SinkFactory, Locale)} instead.
      */
     @Deprecated
-    public void generate( Sink sink, Locale locale )
-        throws MavenReportException
-    {
-        generate( sink, null, locale );
+    public void generate(Sink sink, Locale locale) throws MavenReportException 
{
+        generate(sink, null, locale);
     }
 
     /**
@@ -342,13 +301,10 @@ public abstract class AbstractMavenReport
      * @throws MavenReportException
      */
     @Override
-    public void generate( Sink sink, SinkFactory sinkFactory, Locale locale )
-        throws MavenReportException
-    {
-        if ( !canGenerateReport() )
-        {
-            getLog().info( "This report cannot be generated as part of the 
current build. "
-                           + "The report name should be referenced in this 
line of output." );
+    public void generate(Sink sink, SinkFactory sinkFactory, Locale locale) 
throws MavenReportException {
+        if (!canGenerateReport()) {
+            getLog().info("This report cannot be generated as part of the 
current build. "
+                    + "The report name should be referenced in this line of 
output.");
             return;
         }
 
@@ -356,7 +312,7 @@ public abstract class AbstractMavenReport
 
         this.sinkFactory = sinkFactory;
 
-        executeReport( locale );
+        executeReport(locale);
 
         closeReport();
     }
@@ -365,41 +321,34 @@ public abstract class AbstractMavenReport
      * @return CATEGORY_PROJECT_REPORTS
      */
     @Override
-    public String getCategoryName()
-    {
+    public String getCategoryName() {
         return CATEGORY_PROJECT_REPORTS;
     }
 
     @Override
-    public File getReportOutputDirectory()
-    {
-        if ( reportOutputDirectory == null )
-        {
-            reportOutputDirectory = new File( getOutputDirectory() );
+    public File getReportOutputDirectory() {
+        if (reportOutputDirectory == null) {
+            reportOutputDirectory = new File(getOutputDirectory());
         }
 
         return reportOutputDirectory;
     }
 
     @Override
-    public void setReportOutputDirectory( File reportOutputDirectory )
-    {
+    public void setReportOutputDirectory(File reportOutputDirectory) {
         this.reportOutputDirectory = reportOutputDirectory;
         this.outputDirectory = reportOutputDirectory;
     }
 
-    protected String getOutputDirectory()
-    {
+    protected String getOutputDirectory() {
         return outputDirectory.getAbsolutePath();
     }
 
-    protected MavenProject getProject()
-    {
+    protected MavenProject getProject() {
         return project;
     }
 
-    protected Renderer getSiteRenderer()
-    {
+    protected Renderer getSiteRenderer() {
         return siteRenderer;
     }
 
@@ -408,9 +357,8 @@ public abstract class AbstractMavenReport
      *
      * @return The input files encoding, never <code>null</code>.
      */
-    protected String getInputEncoding()
-    {
-        return ( inputEncoding == null ) ? ReaderFactory.FILE_ENCODING : 
inputEncoding;
+    protected String getInputEncoding() {
+        return (inputEncoding == null) ? ReaderFactory.FILE_ENCODING : 
inputEncoding;
     }
 
     /**
@@ -418,18 +366,15 @@ public abstract class AbstractMavenReport
      *
      * @return The effective reporting output file encoding, never 
<code>null</code>.
      */
-    protected String getOutputEncoding()
-    {
-        return ( outputEncoding == null ) ? WriterFactory.UTF_8 : 
outputEncoding;
+    protected String getOutputEncoding() {
+        return (outputEncoding == null) ? WriterFactory.UTF_8 : outputEncoding;
     }
 
     /**
      * Actions when closing the report.
      */
-    protected void closeReport()
-    {
-        if ( getSink() != null )
-        {
+    protected void closeReport() {
+        if (getSink() != null) {
             getSink().close();
         }
     }
@@ -437,16 +382,14 @@ public abstract class AbstractMavenReport
     /**
      * @return the sink used
      */
-    public Sink getSink()
-    {
+    public Sink getSink() {
         return sink;
     }
 
     /**
      * @return the sink factory used
      */
-    public SinkFactory getSinkFactory()
-    {
+    public SinkFactory getSinkFactory() {
         return sinkFactory;
     }
 
@@ -455,14 +398,12 @@ public abstract class AbstractMavenReport
      * @return {@code false} by default.
      */
     @Override
-    public boolean isExternalReport()
-    {
+    public boolean isExternalReport() {
         return false;
     }
 
     @Override
-    public boolean canGenerateReport()
-    {
+    public boolean canGenerateReport() {
         return true;
     }
 
@@ -472,15 +413,12 @@ public abstract class AbstractMavenReport
      * @param locale the wanted locale to return the report's description, 
could be <code>null</code>.
      * @throws MavenReportException if any
      */
-    protected abstract void executeReport( Locale locale )
-        throws MavenReportException;
+    protected abstract void executeReport(Locale locale) throws 
MavenReportException;
 
     /**
      * {@inheritDoc}
      */
-    public void contextualize( Context context )
-        throws ContextException
-    {
-        container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY 
);
+    public void contextualize(Context context) throws ContextException {
+        container = (PlexusContainer) context.get(PlexusConstants.PLEXUS_KEY);
     }
 }
diff --git 
a/src/main/java/org/apache/maven/reporting/AbstractMavenReportRenderer.java 
b/src/main/java/org/apache/maven/reporting/AbstractMavenReportRenderer.java
index 4c9a07c..483b731 100644
--- a/src/main/java/org/apache/maven/reporting/AbstractMavenReportRenderer.java
+++ b/src/main/java/org/apache/maven/reporting/AbstractMavenReportRenderer.java
@@ -1,5 +1,3 @@
-package org.apache.maven.reporting;
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.reporting;
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
  *
- *  http://www.apache.org/licenses/LICENSE-2.0
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
@@ -18,12 +16,7 @@ package org.apache.maven.reporting;
  * specific language governing permissions and limitations
  * under the License.
  */
-
-import org.apache.maven.doxia.sink.Sink;
-import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
-import org.apache.maven.doxia.util.HtmlTools;
-
-import org.apache.maven.shared.utils.StringUtils;
+package org.apache.maven.reporting;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -32,6 +25,11 @@ import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
+import org.apache.maven.doxia.util.HtmlTools;
+import org.apache.maven.shared.utils.StringUtils;
+
 /**
  * <p>An abstract class to manage report generation, with many helper methods 
to ease the job: you just need to
  * implement getTitle() and renderBody().</p>
@@ -47,9 +45,7 @@ import java.util.Properties;
  * @see #getTitle()
  * @see #renderBody()
  */
-public abstract class AbstractMavenReportRenderer
-    implements MavenReportRenderer
-{
+public abstract class AbstractMavenReportRenderer implements 
MavenReportRenderer {
     /** The current sink to use */
     protected Sink sink;
 
@@ -61,19 +57,17 @@ public abstract class AbstractMavenReportRenderer
      *
      * @param sink the sink to use.
      */
-    public AbstractMavenReportRenderer( Sink sink )
-    {
+    public AbstractMavenReportRenderer(Sink sink) {
         this.sink = sink;
     }
 
     /** {@inheritDoc} */
     @Override
-    public void render()
-    {
+    public void render() {
         sink.head();
 
         sink.title();
-        text( getTitle() );
+        text(getTitle());
         sink.title_();
 
         sink.head_();
@@ -112,12 +106,10 @@ public abstract class AbstractMavenReportRenderer
      * @see Sink#sectionTitle5()
      * @see Sink#sectionTitle5_()
      */
-    protected void startSection( String name )
-    {
+    protected void startSection(String name) {
         section = section + 1;
 
-        switch ( section )
-        {
+        switch (section) {
             case 1:
                 sink.section1();
                 sink.sectionTitle1();
@@ -144,10 +136,9 @@ public abstract class AbstractMavenReportRenderer
                 break;
         }
 
-        text( name );
+        text(name);
 
-        switch ( section )
-        {
+        switch (section) {
             case 1:
                 sink.sectionTitle1_();
                 break;
@@ -169,7 +160,7 @@ public abstract class AbstractMavenReportRenderer
                 break;
         }
 
-        sink.anchor( HtmlTools.encodeId( name ) );
+        sink.anchor(HtmlTools.encodeId(name));
         sink.anchor_();
     }
 
@@ -183,10 +174,8 @@ public abstract class AbstractMavenReportRenderer
      * @see Sink#section5_()
      * @throws IllegalStateException if too many closing sections.
      */
-    protected void endSection()
-    {
-        switch ( section )
-        {
+    protected void endSection() {
+        switch (section) {
             case 1:
                 sink.section1_();
                 break;
@@ -210,9 +199,8 @@ public abstract class AbstractMavenReportRenderer
 
         section = section - 1;
 
-        if ( section < 0 )
-        {
-            throw new IllegalStateException( "Too many closing sections" );
+        if (section < 0) {
+            throw new IllegalStateException("Too many closing sections");
         }
     }
 
@@ -225,9 +213,8 @@ public abstract class AbstractMavenReportRenderer
      *
      * @see Sink#table()
      */
-    protected void startTable()
-    {
-        startTable( new int[] {Sink.JUSTIFY_LEFT}, false );
+    protected void startTable() {
+        startTable(new int[] {Sink.JUSTIFY_LEFT}, false);
     }
 
     /**
@@ -240,10 +227,9 @@ public abstract class AbstractMavenReportRenderer
      * @see Sink#tableRows(int[],boolean)
      * @since 2.1
      */
-    protected void startTable( int[] justification, boolean grid )
-    {
+    protected void startTable(int[] justification, boolean grid) {
         sink.table();
-        sink.tableRows( justification, grid );
+        sink.tableRows(justification, grid);
     }
 
     /**
@@ -251,8 +237,7 @@ public abstract class AbstractMavenReportRenderer
      *
      * @see Sink#table_()
      */
-    protected void endTable()
-    {
+    protected void endTable() {
         sink.tableRows_();
         sink.table_();
     }
@@ -265,11 +250,10 @@ public abstract class AbstractMavenReportRenderer
      * @see Sink#tableHeaderCell()
      * @see Sink#tableHeaderCell_()
      */
-    protected void tableHeaderCell( String text )
-    {
+    protected void tableHeaderCell(String text) {
         sink.tableHeaderCell();
 
-        text( text );
+        text(text);
 
         sink.tableHeaderCell_();
     }
@@ -282,9 +266,8 @@ public abstract class AbstractMavenReportRenderer
      * @see #linkPatternedText(String)
      * @see #tableCell(String)
      */
-    protected void tableCell( String text )
-    {
-        tableCell( text, false );
+    protected void tableCell(String text) {
+        tableCell(text, false);
     }
 
     /**
@@ -299,17 +282,13 @@ public abstract class AbstractMavenReportRenderer
      * @see Sink#tableCell_()
      * @see Sink#rawText(String)
      */
-    protected void tableCell( String text, boolean asHtml )
-    {
+    protected void tableCell(String text, boolean asHtml) {
         sink.tableCell();
 
-        if ( asHtml )
-        {
-            sink.rawText( text );
-        }
-        else
-        {
-            linkPatternedText( text );
+        if (asHtml) {
+            sink.rawText(text);
+        } else {
+            linkPatternedText(text);
         }
 
         sink.tableCell_();
@@ -324,15 +303,12 @@ public abstract class AbstractMavenReportRenderer
      * @see Sink#tableRow()
      * @see Sink#tableRow_()
      */
-    protected void tableRow( String[] content )
-    {
+    protected void tableRow(String[] content) {
         sink.tableRow();
 
-        if ( content != null )
-        {
-            for ( int i = 0; i < content.length; i++ )
-            {
-                tableCell( content[i] );
+        if (content != null) {
+            for (int i = 0; i < content.length; i++) {
+                tableCell(content[i]);
             }
         }
 
@@ -347,15 +323,12 @@ public abstract class AbstractMavenReportRenderer
      * @see Sink#tableRow()
      * @see Sink#tableRow_()
      */
-    protected void tableHeader( String[] content )
-    {
+    protected void tableHeader(String[] content) {
         sink.tableRow();
 
-        if ( content != null )
-        {
-            for ( int i = 0; i < content.length; i++ )
-            {
-                tableHeaderCell( content[i] );
+        if (content != null) {
+            for (int i = 0; i < content.length; i++) {
+                tableHeaderCell(content[i]);
             }
         }
 
@@ -370,11 +343,10 @@ public abstract class AbstractMavenReportRenderer
      * @see Sink#tableCaption()
      * @see Sink#tableCaption_()
      */
-    protected void tableCaption( String caption )
-    {
+    protected void tableCaption(String caption) {
         sink.tableCaption();
 
-        text( caption );
+        text(caption);
 
         sink.tableCaption_();
     }
@@ -391,11 +363,10 @@ public abstract class AbstractMavenReportRenderer
      * @see Sink#paragraph()
      * @see Sink#paragraph_()
      */
-    protected void paragraph( String paragraph )
-    {
+    protected void paragraph(String paragraph) {
         sink.paragraph();
 
-        text( paragraph );
+        text(paragraph);
 
         sink.paragraph_();
     }
@@ -409,11 +380,10 @@ public abstract class AbstractMavenReportRenderer
      * @see Sink#link(String)
      * @see Sink#link_()
      */
-    protected void link( String href, String name )
-    {
-        sink.link( href );
+    protected void link(String href, String name) {
+        sink.link(href);
 
-        text( name );
+        text(name);
 
         sink.link_();
     }
@@ -425,15 +395,12 @@ public abstract class AbstractMavenReportRenderer
      * @param text a text, could be null.
      * @see Sink#text(String)
      */
-    protected void text( String text )
-    {
-        if ( StringUtils.isEmpty( text ) ) // Take care of spaces
-        {
-            sink.text( "-" );
-        }
-        else
+    protected void text(String text) {
+        if (StringUtils.isEmpty(text)) // Take care of spaces
         {
-            sink.text( text );
+            sink.text("-");
+        } else {
+            sink.text(text);
         }
     }
 
@@ -445,11 +412,10 @@ public abstract class AbstractMavenReportRenderer
      * @see Sink#verbatim(boolean)
      * @see Sink#verbatim_()
      */
-    protected void verbatimText( String text )
-    {
-        sink.verbatim( SinkEventAttributeSet.BOXED );
+    protected void verbatimText(String text) {
+        sink.verbatim(SinkEventAttributeSet.BOXED);
 
-        text( text );
+        text(text);
 
         sink.verbatim_();
     }
@@ -464,17 +430,13 @@ public abstract class AbstractMavenReportRenderer
      * @see Sink#verbatim(boolean)
      * @see Sink#verbatim_()
      */
-    protected void verbatimLink( String text, String href )
-    {
-        if ( StringUtils.isEmpty( href ) )
-        {
-            verbatimText( text );
-        }
-        else
-        {
-            sink.verbatim( SinkEventAttributeSet.BOXED );
+    protected void verbatimLink(String text, String href) {
+        if (StringUtils.isEmpty(href)) {
+            verbatimText(text);
+        } else {
+            sink.verbatim(SinkEventAttributeSet.BOXED);
 
-            link( href, text );
+            link(href, text);
 
             sink.verbatim_();
         }
@@ -486,9 +448,8 @@ public abstract class AbstractMavenReportRenderer
      * @param jsCode a string of Javascript
      * @see Sink#rawText(String)
      */
-    protected void javaScript( String jsCode )
-    {
-        sink.rawText( "<script type=\"text/javascript\">\n" + jsCode + 
"</script>" );
+    protected void javaScript(String jsCode) {
+        sink.rawText("<script type=\"text/javascript\">\n" + jsCode + 
"</script>");
     }
 
     /**
@@ -501,34 +462,23 @@ public abstract class AbstractMavenReportRenderer
      * @see #link(String, String)
      * @see #applyPattern(String)
      */
-    public void linkPatternedText( String text )
-    {
-        if ( StringUtils.isEmpty( text ) )
-        {
-            text( text );
-        }
-        else
-        {
-            List<String> segments = applyPattern( text );
-
-            if ( segments == null )
-            {
-                text( text );
-            }
-            else
-            {
-                for ( Iterator<String> it = segments.iterator(); it.hasNext(); 
)
-                {
+    public void linkPatternedText(String text) {
+        if (StringUtils.isEmpty(text)) {
+            text(text);
+        } else {
+            List<String> segments = applyPattern(text);
+
+            if (segments == null) {
+                text(text);
+            } else {
+                for (Iterator<String> it = segments.iterator(); it.hasNext(); 
) {
                     String name = it.next();
                     String href = it.next();
 
-                    if ( href == null )
-                    {
-                        text( name );
-                    }
-                    else
-                    {
-                       link( href, name );
+                    if (href == null) {
+                        text(name);
+                    } else {
+                        link(href, name);
                     }
                 }
             }
@@ -545,15 +495,12 @@ public abstract class AbstractMavenReportRenderer
      * @return a link pattern
      * @see #linkPatternedText(String)
      */
-    protected static String createLinkPatternedText( String text, String href )
-    {
-        if ( text == null )
-        {
+    protected static String createLinkPatternedText(String text, String href) {
+        if (text == null) {
             return text;
         }
 
-        if ( href == null )
-        {
+        if (href == null) {
             return text;
         }
 
@@ -566,23 +513,19 @@ public abstract class AbstractMavenReportRenderer
      * @param props the properties to display.
      * @return the properties object as comma separated String
      */
-    protected static String propertiesToString( Properties props )
-    {
-        if ( props == null || props.isEmpty() )
-        {
+    protected static String propertiesToString(Properties props) {
+        if (props == null || props.isEmpty()) {
             return "";
         }
 
         StringBuilder sb = new StringBuilder();
 
-        for ( Map.Entry<?, ?> entry : props.entrySet() )
-        {
-            if ( sb.length() > 0 )
-            {
-                sb.append( ", " );
+        for (Map.Entry<?, ?> entry : props.entrySet()) {
+            if (sb.length() > 0) {
+                sb.append(", ");
             }
 
-            sb.append( entry.getKey() ).append( "=" ).append( entry.getValue() 
);
+            sb.append(entry.getKey()).append("=").append(entry.getValue());
         }
 
         return sb.toString();
@@ -599,10 +542,8 @@ public abstract class AbstractMavenReportRenderer
      * @param text a text with or without the pattern <code>{text, url}</code>
      * @return a map of text/href
      */
-    private static List<String> applyPattern( String text )
-    {
-        if ( StringUtils.isEmpty( text ) )
-        {
+    private static List<String> applyPattern(String text) {
+        if (StringUtils.isEmpty(text)) {
             return null;
         }
 
@@ -611,19 +552,15 @@ public abstract class AbstractMavenReportRenderer
         List<String> segments = new ArrayList<>();
 
         // TODO Special case http://jira.codehaus.org/browse/MEV-40
-        if ( text.indexOf( "${" ) != -1 )
-        {
-            int lastComma = text.lastIndexOf( "," );
-            int lastSemi = text.lastIndexOf( "}" );
-            if ( lastComma != -1 && lastSemi != -1 && lastComma < lastSemi )
-            {
-                segments.add( text.substring( lastComma + 1, lastSemi ).trim() 
);
-                segments.add( null );
-            }
-            else
-            {
-                segments.add( text );
-                segments.add( null );
+        if (text.indexOf("${") != -1) {
+            int lastComma = text.lastIndexOf(",");
+            int lastSemi = text.lastIndexOf("}");
+            if (lastComma != -1 && lastSemi != -1 && lastComma < lastSemi) {
+                segments.add(text.substring(lastComma + 1, lastSemi).trim());
+                segments.add(null);
+            } else {
+                segments.add(text);
+                segments.add(null);
             }
 
             return segments;
@@ -633,38 +570,28 @@ public abstract class AbstractMavenReportRenderer
         int braceStack = 0;
         int lastOffset = 0;
 
-        for ( int i = 0; i < text.length(); i++ )
-        {
-            char ch = text.charAt( i );
+        for (int i = 0; i < text.length(); i++) {
+            char ch = text.charAt(i);
 
-            if ( ch == '\'' && !inQuote && braceStack == 0 )
-            {
+            if (ch == '\'' && !inQuote && braceStack == 0) {
                 // handle: ''
-                if ( i + 1 < text.length() && text.charAt( i + 1 ) == '\'' )
-                {
+                if (i + 1 < text.length() && text.charAt(i + 1) == '\'') {
                     i++;
-                    segments.add( text.substring( lastOffset, i ) );
-                    segments.add( null );
+                    segments.add(text.substring(lastOffset, i));
+                    segments.add(null);
                     lastOffset = i + 1;
-                }
-                else
-                {
+                } else {
                     inQuote = true;
                 }
-            }
-            else
-            {
-                switch ( ch )
-                {
+            } else {
+                switch (ch) {
                     case '{':
-                        if ( !inQuote )
-                        {
-                            if ( braceStack == 0 )
-                            {
-                                if ( i != lastOffset ) // handle { at first 
character
+                        if (!inQuote) {
+                            if (braceStack == 0) {
+                                if (i != lastOffset) // handle { at first 
character
                                 {
-                                    segments.add( text.substring( lastOffset, 
i ) );
-                                    segments.add( null );
+                                    segments.add(text.substring(lastOffset, 
i));
+                                    segments.add(null);
                                 }
                                 lastOffset = i + 1;
                             }
@@ -672,24 +599,21 @@ public abstract class AbstractMavenReportRenderer
                         }
                         break;
                     case '}':
-                        if ( !inQuote )
-                        {
+                        if (!inQuote) {
                             braceStack--;
-                            if ( braceStack == 0 )
-                            {
-                                String subString = text.substring( lastOffset, 
i );
+                            if (braceStack == 0) {
+                                String subString = text.substring(lastOffset, 
i);
                                 lastOffset = i + 1;
 
-                                int lastComma = subString.lastIndexOf( "," );
-                                if ( lastComma != -1 )
-                                {
-                                    segments.add( subString.substring( 0, 
lastComma ).trim() );
-                                    segments.add( subString.substring( 
lastComma + 1 ).trim() );
-                                }
-                                else
-                                {
-                                    segments.add( subString );
-                                    segments.add( null );
+                                int lastComma = subString.lastIndexOf(",");
+                                if (lastComma != -1) {
+                                    segments.add(
+                                            subString.substring(0, 
lastComma).trim());
+                                    segments.add(
+                                            subString.substring(lastComma + 
1).trim());
+                                } else {
+                                    segments.add(subString);
+                                    segments.add(null);
                                 }
                             }
                         }
@@ -703,24 +627,21 @@ public abstract class AbstractMavenReportRenderer
             }
         }
 
-        if ( !StringUtils.isEmpty( text.substring( lastOffset ) ) )
-        {
-            segments.add( text.substring( lastOffset ) );
-            segments.add( null );
+        if (!StringUtils.isEmpty(text.substring(lastOffset))) {
+            segments.add(text.substring(lastOffset));
+            segments.add(null);
         }
 
-        if ( braceStack != 0 )
-        {
-            throw new IllegalArgumentException( "Unmatched braces in the 
pattern." );
+        if (braceStack != 0) {
+            throw new IllegalArgumentException("Unmatched braces in the 
pattern.");
         }
 
-        if ( inQuote )
-        {
-            //throw new IllegalArgumentException( "Unmatched quote in the 
pattern." );
-            //TODO: warning...
+        if (inQuote) {
+            // throw new IllegalArgumentException( "Unmatched quote in the 
pattern." );
+            // TODO: warning...
         }
 
-        return Collections.unmodifiableList( segments );
+        return Collections.unmodifiableList(segments);
     }
 
     // ----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/maven/reporting/AbstractMavenReportRendererTest.java 
b/src/test/java/org/apache/maven/reporting/AbstractMavenReportRendererTest.java
index cdb9299..f716677 100644
--- 
a/src/test/java/org/apache/maven/reporting/AbstractMavenReportRendererTest.java
+++ 
b/src/test/java/org/apache/maven/reporting/AbstractMavenReportRendererTest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.reporting;
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.reporting;
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
  *
- *  http://www.apache.org/licenses/LICENSE-2.0
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
@@ -18,6 +16,7 @@ package org.apache.maven.reporting;
  * specific language governing permissions and limitations
  * under the License.
  */
+package org.apache.maven.reporting;
 
 import java.util.Iterator;
 import java.util.List;
@@ -29,40 +28,30 @@ import junitx.util.PrivateAccessor;
 /**
  * Test case for some public method in AbstractMavenReportRenderer.
  */
-public class AbstractMavenReportRendererTest
-    extends TestCase
-{
-    private static List<String> applyPattern( String pattern )
-        throws Throwable
-    {
-        return (List<String>) PrivateAccessor.invoke( 
AbstractMavenReportRenderer.class, "applyPattern",
-                                              new Class[] { String.class }, 
new Object[] { pattern } );
+public class AbstractMavenReportRendererTest extends TestCase {
+    private static List<String> applyPattern(String pattern) throws Throwable {
+        return (List<String>) PrivateAccessor.invoke(
+                AbstractMavenReportRenderer.class, "applyPattern", new Class[] 
{String.class}, new Object[] {pattern});
     }
 
-    private static void checkPattern( String pattern, String[] expectedResult 
) throws Throwable
-    {
-        List<String> result = applyPattern( pattern );
-        Assert.assertEquals( "result size", expectedResult.length, 
result.size() );
+    private static void checkPattern(String pattern, String[] expectedResult) 
throws Throwable {
+        List<String> result = applyPattern(pattern);
+        Assert.assertEquals("result size", expectedResult.length, 
result.size());
         int i = 0;
-        for ( Iterator<String> it = result.iterator(); it.hasNext(); )
-        {
+        for (Iterator<String> it = result.iterator(); it.hasNext(); ) {
             String name = it.next();
             String href = it.next();
-            Assert.assertEquals( expectedResult[i], name );
-            Assert.assertEquals( expectedResult[i + 1], href );
+            Assert.assertEquals(expectedResult[i], name);
+            Assert.assertEquals(expectedResult[i + 1], href);
             i += 2;
         }
     }
 
-    private static void checkPatternIllegalArgument( String cause, String 
pattern ) throws Throwable
-    {
-        try
-        {
-            applyPattern( pattern );
-            Assert.fail( cause + " should throw an IllegalArgumentException" );
-        }
-        catch ( IllegalArgumentException iae )
-        {
+    private static void checkPatternIllegalArgument(String cause, String 
pattern) throws Throwable {
+        try {
+            applyPattern(pattern);
+            Assert.fail(cause + " should throw an IllegalArgumentException");
+        } catch (IllegalArgumentException iae) {
             // ok
         }
     }
@@ -70,60 +59,61 @@ public class AbstractMavenReportRendererTest
     /**
      * @throws Throwable if any
      */
-    public void testApplyPattern() throws Throwable
-    {
+    public void testApplyPattern() throws Throwable {
         // the most simple test
-        checkPattern( "test {text,url}", new String[] { "test ", null, "text", 
"url" } );
+        checkPattern("test {text,url}", new String[] {"test ", null, "text", 
"url"});
 
         // check that link content is trimmed, and no problem if 2 text values 
are the same
-        checkPattern( "test{ text , url }test", new String[] { "test", null, 
"text", "url", "test", null } );
+        checkPattern("test{ text , url }test", new String[] {"test", null, 
"text", "url", "test", null});
 
         // check brace stacking
-        checkPattern( "test{ {text} , url }", new String[] { "test", null, 
"{text}", "url" } );
+        checkPattern("test{ {text} , url }", new String[] {"test", null, 
"{text}", "url"});
 
         // check quoting
-        checkPatternIllegalArgument( "unmatched brace", "{" );
-        checkPattern( "'{'", new String[] { "'{'", null } );
-        checkPattern( " ' { '.", new String[] { " ' { '.", null } );
+        checkPatternIllegalArgument("unmatched brace", "{");
+        checkPattern("'{'", new String[] {"'{'", null});
+        checkPattern(" ' { '.", new String[] {" ' { '.", null});
 
         // unmatched quote: the actual behavior is to ignore that they are 
unmatched
-        checkPattern( " '", new String[] { " '", null } );
+        checkPattern(" '", new String[] {" '", null});
         // but shouldn't it be different and throw an IllegalArgumentException?
         //    checkPatternIllegalArgument( "unmatched quote", " ' " );
         //    checkPatternIllegalArgument( "unmatched quote", " '" );
         // impact is too important to make the change for the moment
 
         // check double quoting
-        checkPattern( " ''", new String[] { " '", null } );
-        checkPattern( " '' ", new String[] { " '", null } );
-        checkPattern( " ''   ", new String[] { " '", null } );
+        checkPattern(" ''", new String[] {" '", null});
+        checkPattern(" '' ", new String[] {" '", null});
+        checkPattern(" ''   ", new String[] {" '", null});
 
         // real world cases with quote
-        checkPattern( "project''s info", new String[] { "project'", null, "s 
info", null } );
-        checkPattern( "it''s a question of {chance, 
http://en.wikipedia.org/wiki/Chance}";,
-                      new String[] { "it'", null, "s a question of ", null,
-                                     "chance", 
"http://en.wikipedia.org/wiki/Chance"; } );
-        checkPattern( "{s'inscrire,m...@mail.com}", new String[] { 
"s'inscrire", "m...@mail.com" } );
+        checkPattern("project''s info", new String[] {"project'", null, "s 
info", null});
+        checkPattern(
+                "it''s a question of {chance, 
http://en.wikipedia.org/wiki/Chance}";,
+                new String[] {"it'", null, "s a question of ", null, "chance", 
"http://en.wikipedia.org/wiki/Chance"});
+        checkPattern("{s'inscrire,m...@mail.com}", new String[] {"s'inscrire", 
"m...@mail.com"});
 
         // throwing an IllegalArgumentException in case of unmatched quote 
would avoid the following:
-        checkPattern( "it's a question of {chance, 
http://en.wikipedia.org/wiki/Chance}";,
-                      new String[] { "it's a question of {chance, 
http://en.wikipedia.org/wiki/Chance}";, null } );
+        checkPattern(
+                "it's a question of {chance, 
http://en.wikipedia.org/wiki/Chance}";,
+                new String[] {"it's a question of {chance, 
http://en.wikipedia.org/wiki/Chance}";, null});
 
-        checkPattern( "{}test,", new String[] { "", null, "test,", null } );
-        checkPattern( "Hi ${name}. How is it going, sir?", new String[] { "Hi 
${name}. How is it going, sir?", null } );
+        checkPattern("{}test,", new String[] {"", null, "test,", null});
+        checkPattern("Hi ${name}. How is it going, sir?", new String[] {"Hi 
${name}. How is it going, sir?", null});
 
         // MSHARED-392 multiple links
-        checkPattern( "{Indiana University Extreme! Lab Software License, 
vesion 1.1.1,"
+        checkPattern(
+                "{Indiana University Extreme! Lab Software License, vesion 
1.1.1,"
                         + 
"http://www.extreme.indiana.edu/viewcvs/~checkout~/XPP3/java/LICENSE.txt}";
                         + "{Public 
Domain,http://creativecommons.org/licenses/publicdomain}";
                         + "{Apache Software License, version 
1.1,http://www.apache.org/licenses/LICENSE-1.1}";,
-                                  new String[]{"Indiana University Extreme! 
Lab Software License, vesion 1.1.1", 
-                                      
"http://www.extreme.indiana.edu/viewcvs/~checkout~/XPP3/java/LICENSE.txt";,
-                                      "Public Domain",
-                                      
"http://creativecommons.org/licenses/publicdomain";,
-                                      "Apache Software License, version 1.1",
-                                      
"http://www.apache.org/licenses/LICENSE-1.1"});
-
-        
+                new String[] {
+                    "Indiana University Extreme! Lab Software License, vesion 
1.1.1",
+                    
"http://www.extreme.indiana.edu/viewcvs/~checkout~/XPP3/java/LICENSE.txt";,
+                    "Public Domain",
+                    "http://creativecommons.org/licenses/publicdomain";,
+                    "Apache Software License, version 1.1",
+                    "http://www.apache.org/licenses/LICENSE-1.1";
+                });
     }
 }

Reply via email to