You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kh...@apache.org on 2015/12/08 12:09:41 UTC
svn commit: r1718564 - in /maven/shared/trunk/maven-shared-io/src:
main/java/org/apache/maven/shared/io/download/
main/java/org/apache/maven/shared/io/location/
test/java/org/apache/maven/shared/io/location/
Author: khmarbaise
Date: Tue Dec 8 11:09:41 2015
New Revision: 1718564
URL: http://svn.apache.org/viewvc?rev=1718564&view=rev
Log:
Cleaned up several checkstyle reported errors/warnings.
Modified:
maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/download/DefaultDownloadManager.java
maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/ArtifactLocatorStrategy.java
maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/ClasspathResourceLocatorStrategy.java
maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/FileLocation.java
maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/FileLocatorStrategy.java
maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/Location.java
maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/Locator.java
maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/LocatorStrategy.java
maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/URLLocation.java
maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/URLLocatorStrategy.java
maven/shared/trunk/maven-shared-io/src/test/java/org/apache/maven/shared/io/location/LocatorTest.java
Modified: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/download/DefaultDownloadManager.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/download/DefaultDownloadManager.java?rev=1718564&r1=1718563&r2=1718564&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/download/DefaultDownloadManager.java (original)
+++ maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/download/DefaultDownloadManager.java Tue Dec 8 11:09:41 2015
@@ -42,7 +42,7 @@ import org.apache.maven.wagon.events.Tra
import org.apache.maven.wagon.repository.Repository;
/**
- * The Implementation of the {@link DownloadManager}.
+ * The Implementation of the {@link DownloadManager
*
*/
public class DefaultDownloadManager
Modified: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/ArtifactLocatorStrategy.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/ArtifactLocatorStrategy.java?rev=1718564&r1=1718563&r2=1718564&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/ArtifactLocatorStrategy.java (original)
+++ maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/ArtifactLocatorStrategy.java Tue Dec 8 11:09:41 2015
@@ -29,6 +29,10 @@ import org.apache.maven.artifact.resolve
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.shared.io.logging.MessageHolder;
+/**
+ * The locator strategy.
+ *
+ */
public class ArtifactLocatorStrategy
implements LocatorStrategy
{
@@ -40,12 +44,18 @@ public class ArtifactLocatorStrategy
private final ArtifactRepository localRepository;
- private final List remoteRepositories;
+ private final List<ArtifactRepository> remoteRepositories;
private String defaultClassifier = null;
+ /**
+ * @param factory {@link ArtifactFactory}
+ * @param resolver {@link ArtifactResolver}
+ * @param localRepository {@link ArtifactRepository}
+ * @param remoteRepositories {@link RemoteRepository}
+ */
public ArtifactLocatorStrategy( ArtifactFactory factory, ArtifactResolver resolver,
- ArtifactRepository localRepository, List remoteRepositories )
+ ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
{
this.factory = factory;
this.resolver = resolver;
@@ -53,8 +63,15 @@ public class ArtifactLocatorStrategy
this.remoteRepositories = remoteRepositories;
}
+ /**
+ * @param factory {@link ArtifactFactory}
+ * @param resolver {@link ArtifactResolver}
+ * @param localRepository {@link ArtifactRepository}
+ * @param remoteRepositories {@link ArtifactRepository}
+ * @param defaultArtifactType default artifact type.
+ */
public ArtifactLocatorStrategy( ArtifactFactory factory, ArtifactResolver resolver,
- ArtifactRepository localRepository, List remoteRepositories,
+ ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories,
String defaultArtifactType )
{
this.factory = factory;
@@ -64,8 +81,16 @@ public class ArtifactLocatorStrategy
this.defaultArtifactType = defaultArtifactType;
}
+ /**
+ * @param factory {@link ArtifactFactory}
+ * @param resolver {@link ArtifactResolver}
+ * @param localRepository {@link ArtifactRepository}
+ * @param remoteRepositories {@link ArtifactRepository}
+ * @param defaultArtifactType default artifact type.
+ * @param defaultClassifier default classifier.
+ */
public ArtifactLocatorStrategy( ArtifactFactory factory, ArtifactResolver resolver,
- ArtifactRepository localRepository, List remoteRepositories,
+ ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories,
String defaultArtifactType, String defaultClassifier )
{
this.factory = factory;
@@ -80,6 +105,9 @@ public class ArtifactLocatorStrategy
* Assumes artifact identity is given in a set of comma-delimited tokens of
* the form: <code>groupId:artifactId:version:type:classifier</code>, where
* type and classifier are optional.
+ * @param locationSpecification location spec.
+ * @param messageHolder {@link MessageHolder}
+ * @return location.
*/
public Location resolve( String locationSpecification, MessageHolder messageHolder )
{
Modified: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/ClasspathResourceLocatorStrategy.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/ClasspathResourceLocatorStrategy.java?rev=1718564&r1=1718563&r2=1718564&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/ClasspathResourceLocatorStrategy.java (original)
+++ maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/ClasspathResourceLocatorStrategy.java Tue Dec 8 11:09:41 2015
@@ -23,6 +23,10 @@ import java.net.URL;
import org.apache.maven.shared.io.logging.MessageHolder;
+/**
+ * classpath resource locator strategy.
+ *
+ */
public class ClasspathResourceLocatorStrategy
implements LocatorStrategy
{
@@ -33,10 +37,18 @@ public class ClasspathResourceLocatorStr
private boolean tempFileDeleteOnExit = true;
+ /**
+ * Create instance.
+ */
public ClasspathResourceLocatorStrategy()
{
}
+ /**
+ * @param tempFilePrefix Prefix.
+ * @param tempFileSuffix Suffix.
+ * @param tempFileDeleteOnExit delete on exit.
+ */
public ClasspathResourceLocatorStrategy( String tempFilePrefix, String tempFileSuffix,
boolean tempFileDeleteOnExit )
{
@@ -45,6 +57,7 @@ public class ClasspathResourceLocatorStr
this.tempFileDeleteOnExit = tempFileDeleteOnExit;
}
+ /** {@inheritDoc} */
public Location resolve( String locationSpecification, MessageHolder messageHolder )
{
ClassLoader cloader = Thread.currentThread().getContextClassLoader();
Modified: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/FileLocation.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/FileLocation.java?rev=1718564&r1=1718563&r2=1718564&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/FileLocation.java (original)
+++ maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/FileLocation.java Tue Dec 8 11:09:41 2015
@@ -27,6 +27,10 @@ import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
+/**
+ * file location implementation.
+ *
+ */
public class FileLocation
implements Location
{
@@ -36,17 +40,25 @@ public class FileLocation
private final String specification;
private FileInputStream stream;
+ /**
+ * @param file {@link File}
+ * @param specification spec.
+ */
public FileLocation( File file, String specification )
{
this.file = file;
this.specification = specification;
}
+ /**
+ * @param specification spec.
+ */
protected FileLocation( String specification )
{
this.specification = specification;
}
+ /** {@inheritDoc} */
public void close()
{
if ( ( channel != null ) && channel.isOpen() )
@@ -74,6 +86,7 @@ public class FileLocation
}
}
+ /** {@inheritDoc} */
public File getFile()
throws IOException
{
@@ -82,11 +95,18 @@ public class FileLocation
return unsafeGetFile();
}
+ /**
+ * @return {@link File}
+ */
protected File unsafeGetFile()
{
return file;
}
+ /**
+ * initialize file.
+ * @throws IOException in case error.
+ */
protected void initFile()
throws IOException
{
@@ -97,6 +117,9 @@ public class FileLocation
}
}
+ /**
+ * @param file {@link File}
+ */
protected void setFile( File file )
{
if ( channel != null )
@@ -107,11 +130,13 @@ public class FileLocation
this.file = file;
}
+ /** {@inheritDoc} */
public String getSpecification()
{
return specification;
}
+ /** {@inheritDoc} */
public void open()
throws IOException
{
@@ -124,6 +149,7 @@ public class FileLocation
}
}
+ /** {@inheritDoc} */
public int read( ByteBuffer buffer )
throws IOException
{
@@ -131,6 +157,7 @@ public class FileLocation
return channel.read( buffer );
}
+ /** {@inheritDoc} */
public int read( byte[] buffer )
throws IOException
{
@@ -138,6 +165,7 @@ public class FileLocation
return channel.read( ByteBuffer.wrap( buffer ) );
}
+ /** {@inheritDoc} */
public InputStream getInputStream()
throws IOException
{
Modified: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/FileLocatorStrategy.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/FileLocatorStrategy.java?rev=1718564&r1=1718563&r2=1718564&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/FileLocatorStrategy.java (original)
+++ maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/FileLocatorStrategy.java Tue Dec 8 11:09:41 2015
@@ -23,10 +23,15 @@ import java.io.File;
import org.apache.maven.shared.io.logging.MessageHolder;
+/**
+ * file locator strategy.
+ *
+ */
public class FileLocatorStrategy
implements LocatorStrategy
{
+ /** {@inheritDoc} */
public Location resolve( String locationSpecification, MessageHolder messageHolder )
{
File file = new File( locationSpecification );
Modified: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/Location.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/Location.java?rev=1718564&r1=1718563&r2=1718564&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/Location.java (original)
+++ maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/Location.java Tue Dec 8 11:09:41 2015
@@ -24,21 +24,53 @@ import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
+/**
+ * The location interface.
+ *
+ */
public interface Location
{
+ /**
+ * @return {@link File}.
+ * @throws IOException in case of an error.
+ */
File getFile() throws IOException;
+ /**
+ * open the location.
+ * @throws IOException in case of an error.
+ */
void open() throws IOException;
+ /**
+ * Close the location.
+ */
void close();
+ /**
+ * @param buffer The buffer.
+ * @return number of read bytes.
+ * @throws IOException in case of an error.
+ */
int read( ByteBuffer buffer ) throws IOException;
+ /**
+ * @param buffer The buffer.
+ * @return number of read bytes.
+ * @throws IOException in case of an error.
+ */
int read( byte[] buffer ) throws IOException;
+ /**
+ * @return the resulting input stream.
+ * @throws IOException in case of an error.
+ */
InputStream getInputStream() throws IOException;
+ /**
+ * @return spec.
+ */
String getSpecification();
}
Modified: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/Locator.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/Locator.java?rev=1718564&r1=1718563&r2=1718564&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/Locator.java (original)
+++ maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/Locator.java Tue Dec 8 11:09:41 2015
@@ -26,55 +26,85 @@ import java.util.List;
import org.apache.maven.shared.io.logging.DefaultMessageHolder;
import org.apache.maven.shared.io.logging.MessageHolder;
+/**
+ * The Locator.
+ *
+ */
public final class Locator
{
- private List strategies;
+ private List<LocatorStrategy> strategies;
private final MessageHolder messageHolder;
- public Locator( List strategies, MessageHolder messageHolder )
+ /**
+ * @param strategies List of strategies.
+ * @param messageHolder {@link MessageHolder}
+ */
+ public Locator( List<LocatorStrategy> strategies, MessageHolder messageHolder )
{
this.messageHolder = messageHolder;
- this.strategies = new ArrayList( strategies );
+ this.strategies = new ArrayList<LocatorStrategy>( strategies );
}
+ /**
+ * Create instance.
+ */
public Locator()
{
this.messageHolder = new DefaultMessageHolder();
- this.strategies = new ArrayList();
+ this.strategies = new ArrayList<LocatorStrategy>();
}
+ /**
+ * @return {@link MessageHolder}
+ */
public MessageHolder getMessageHolder()
{
return messageHolder;
}
+ /**
+ * @param strategy The strategy to be added.
+ */
public void addStrategy( LocatorStrategy strategy )
{
this.strategies.add( strategy );
}
+ /**
+ * @param strategy the strategy to remove.
+ */
public void removeStrategy( LocatorStrategy strategy )
{
this.strategies.remove( strategy );
}
- public void setStrategies( List strategies )
+ /**
+ * @param strategies the strategies to be set.
+ */
+ public void setStrategies( List<LocatorStrategy> strategies )
{
this.strategies.clear();
this.strategies.addAll( strategies );
}
- public List getStrategies()
+ /**
+ * @return list of strategies.
+ */
+ public List<LocatorStrategy> getStrategies()
{
return strategies;
}
+ /**
+ * @param locationSpecification location spec.
+ * @return {@link Location}
+ */
public Location resolve( String locationSpecification )
{
Location location = null;
- for ( Iterator it = strategies.iterator(); location == null && it.hasNext(); )
+ for ( Iterator<LocatorStrategy> it = strategies.iterator(); location == null && it.hasNext(); )
{
LocatorStrategy strategy = (LocatorStrategy) it.next();
Modified: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/LocatorStrategy.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/LocatorStrategy.java?rev=1718564&r1=1718563&r2=1718564&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/LocatorStrategy.java (original)
+++ maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/LocatorStrategy.java Tue Dec 8 11:09:41 2015
@@ -21,9 +21,18 @@ package org.apache.maven.shared.io.locat
import org.apache.maven.shared.io.logging.MessageHolder;
+/**
+ * Locator Strategy interface.
+ *
+ */
public interface LocatorStrategy
{
+ /**
+ * @param locationSpecification the specifiaction.
+ * @param messageHolder {@link MessageHolder}
+ * @return {@link Location}
+ */
Location resolve( String locationSpecification, MessageHolder messageHolder );
}
Modified: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/URLLocation.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/URLLocation.java?rev=1718564&r1=1718563&r2=1718564&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/URLLocation.java (original)
+++ maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/URLLocation.java Tue Dec 8 11:09:41 2015
@@ -25,6 +25,10 @@ import java.net.URL;
import org.apache.maven.shared.utils.io.FileUtils;
+/**
+ * The URL Location.
+ *
+ */
public class URLLocation
extends FileLocation
{
@@ -37,6 +41,13 @@ public class URLLocation
private final boolean tempFileDeleteOnExit;
+ /**
+ * @param url The URL.
+ * @param specification The spec.
+ * @param tempFilePrefix the prefix.
+ * @param tempFileSuffix The suffix.
+ * @param tempFileDeleteOnExit delete on exit.
+ */
public URLLocation( URL url, String specification, String tempFilePrefix, String tempFileSuffix,
boolean tempFileDeleteOnExit )
{
@@ -48,6 +59,7 @@ public class URLLocation
this.tempFileDeleteOnExit = tempFileDeleteOnExit;
}
+ /** {@inheritDoc} */
protected void initFile()
throws IOException
{
Modified: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/URLLocatorStrategy.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/URLLocatorStrategy.java?rev=1718564&r1=1718563&r2=1718564&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/URLLocatorStrategy.java (original)
+++ maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/location/URLLocatorStrategy.java Tue Dec 8 11:09:41 2015
@@ -24,6 +24,10 @@ import java.net.URL;
import org.apache.maven.shared.io.logging.MessageHolder;
+/**
+ * URL Locator Strategy.
+ *
+ */
public class URLLocatorStrategy
implements LocatorStrategy
{
@@ -34,10 +38,18 @@ public class URLLocatorStrategy
private boolean tempFileDeleteOnExit = true;
+ /**
+ * Create instance.
+ */
public URLLocatorStrategy()
{
}
+ /**
+ * @param tempFilePrefix prefix.
+ * @param tempFileSuffix suffix.
+ * @param tempFileDeleteOnExit delete on exit.
+ */
public URLLocatorStrategy( String tempFilePrefix, String tempFileSuffix, boolean tempFileDeleteOnExit )
{
this.tempFilePrefix = tempFilePrefix;
@@ -45,6 +57,7 @@ public class URLLocatorStrategy
this.tempFileDeleteOnExit = tempFileDeleteOnExit;
}
+ /** {@inheritDoc} */
public Location resolve( String locationSpecification, MessageHolder messageHolder )
{
Location location = null;
Modified: maven/shared/trunk/maven-shared-io/src/test/java/org/apache/maven/shared/io/location/LocatorTest.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-io/src/test/java/org/apache/maven/shared/io/location/LocatorTest.java?rev=1718564&r1=1718563&r2=1718564&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-io/src/test/java/org/apache/maven/shared/io/location/LocatorTest.java (original)
+++ maven/shared/trunk/maven-shared-io/src/test/java/org/apache/maven/shared/io/location/LocatorTest.java Tue Dec 8 11:09:41 2015
@@ -41,12 +41,12 @@ public class LocatorTest
public void testShouldConstructWithStrategyStackAndMessageHolder()
{
- new Locator( Collections.EMPTY_LIST, new DefaultMessageHolder() );
+ new Locator( Collections.<LocatorStrategy>emptyList(), new DefaultMessageHolder() );
}
public void testShouldAllowModificationOfStrategiesAfterConstructionWithUnmodifiableStack()
{
- Locator locator = new Locator( Collections.unmodifiableList( Collections.EMPTY_LIST ),
+ Locator locator = new Locator( Collections.unmodifiableList( Collections.<LocatorStrategy>emptyList() ),
new DefaultMessageHolder() );
locator.addStrategy( new FileLocatorStrategy() );
@@ -71,7 +71,7 @@ public class LocatorTest
locator.setStrategies( Collections.singletonList( replacementStrategy ) );
- List strategies = locator.getStrategies();
+ List<LocatorStrategy> strategies = locator.getStrategies();
assertFalse( strategies.contains( originalStrategy ) );
assertTrue( strategies.contains( replacementStrategy ) );
@@ -88,7 +88,7 @@ public class LocatorTest
Locator locator = new Locator();
locator.addStrategy( originalStrategy );
- List strategies = locator.getStrategies();
+ List<LocatorStrategy> strategies = locator.getStrategies();
assertTrue( strategies.contains( originalStrategy ) );
@@ -103,7 +103,7 @@ public class LocatorTest
public void testResolutionFallsThroughStrategyStackAndReturnsNullIfNotResolved()
{
- List strategies = new ArrayList();
+ List<LocatorStrategy> strategies = new ArrayList<LocatorStrategy>();
strategies.add( new LoggingLocatorStrategy() );
strategies.add( new LoggingLocatorStrategy() );