Skip to content
This repository has been archived by the owner on Dec 17, 2023. It is now read-only.

Commit

Permalink
run javadoc:fix
Browse files Browse the repository at this point in the history
  • Loading branch information
slachiewicz committed Dec 10, 2023
1 parent c0b139f commit 62224ff
Show file tree
Hide file tree
Showing 12 changed files with 143 additions and 26 deletions.
17 changes: 17 additions & 0 deletions src/main/java/org/codehaus/plexus/digest/AbstractDigester.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,27 @@ public abstract class AbstractDigester
{
private final StreamingDigester streamingDigester;

/**
* <p>Constructor for AbstractDigester.</p>
*
* @param streamingDigester a {@link org.codehaus.plexus.digest.StreamingDigester} object.
*/
protected AbstractDigester( StreamingDigester streamingDigester )
{
this.streamingDigester = streamingDigester;
}

/**
* <p>getAlgorithm.</p>
*
* @return a {@link java.lang.String} object.
*/
public String getAlgorithm()
{
return streamingDigester.getAlgorithm();
}

/** {@inheritDoc} */
public String calc( File file )
throws DigesterException
{
Expand All @@ -65,6 +76,7 @@ public String calc( File file )
}
}

/** {@inheritDoc} */
public void verify( File file, String checksum )
throws DigesterException
{
Expand All @@ -79,6 +91,11 @@ public void verify( File file, String checksum )
}
}

/**
* <p>toString.</p>
*
* @return a {@link java.lang.String} object.
*/
public String toString()
{
return "[Digester:" + streamingDigester.getAlgorithm() + "]";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public abstract class AbstractStreamingDigester

private static final int BUFFER_SIZE = 32768;

/**
* <p>Constructor for AbstractStreamingDigester.</p>
*
* @param algorithm a {@link java.lang.String} object.
*/
protected AbstractStreamingDigester( String algorithm )
{
try
Expand All @@ -46,34 +51,64 @@ protected AbstractStreamingDigester( String algorithm )
}
}

/**
* <p>getAlgorithm.</p>
*
* @return a {@link java.lang.String} object.
*/
public String getAlgorithm()
{
return md.getAlgorithm();
}

/**
* <p>calc.</p>
*
* @return a {@link java.lang.String} object.
* @throws org.codehaus.plexus.digest.DigesterException if any.
*/
public String calc()
throws DigesterException
{
return calc( this.md );
}

/**
* <p>reset.</p>
*
* @throws org.codehaus.plexus.digest.DigesterException if any.
*/
public void reset()
throws DigesterException
{
md.reset();
}

/** {@inheritDoc} */
public void update( InputStream is )
throws DigesterException
{
update( is, md );
}

/**
* <p>calc.</p>
*
* @param md a {@link java.security.MessageDigest} object.
* @return a {@link java.lang.String} object.
*/
protected static String calc( MessageDigest md )
{
return Hex.encode( md.digest() );
}

/**
* <p>update.</p>
*
* @param is a {@link java.io.InputStream} object.
* @param digest a {@link java.security.MessageDigest} object.
* @throws org.codehaus.plexus.digest.DigesterException if any.
*/
protected static void update( InputStream is, MessageDigest digest )
throws DigesterException
{
Expand Down
21 changes: 10 additions & 11 deletions src/main/java/org/codehaus/plexus/digest/ChecksumFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@
import java.io.IOException;

/**
* ChecksumFile
* ChecksumFile
*
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
* @version $Id$
*
* @plexus.component role="org.codehaus.plexus.digest.ChecksumFile"
*/
public class ChecksumFile
Expand All @@ -47,7 +46,7 @@ public class ChecksumFile
* <p>
* Given a checksum file, check to see if the file it represents is valid according to the checksum.
* </p>
*
*
* <dl>
* <lh>Terminology:</lh>
* <dt>Checksum File</dt>
Expand All @@ -58,16 +57,16 @@ public class ChecksumFile
* <dt>Reference File</dt>
* <dd>The file that is being referenced in the checksum file.</dd>
* </dl>
*
*
* <p>
* NOTE: Only supports single file checksums of type MD5 or SHA1.
* </p>
*
*
* @param checksumFile the checksum file (must end in ".sha1" or ".md5")
* @return true if the checksum is valid for the file it represents.
* @throws DigesterException if there is a digester problem during the check of the reference file.
* @throws FileNotFoundException if the checksumFile itself or the file it refers to is not found.
* @throws IOException if the reading of the checksumFile or the file it refers to fails.
* @throws org.codehaus.plexus.digest.DigesterException if there is a digester problem during the check of the reference file.
* @throws java.io.FileNotFoundException if the checksumFile itself or the file it refers to is not found.
* @throws java.io.IOException if the reading of the checksumFile or the file it refers to fails.
*/
public boolean isValidChecksum( File checksumFile ) throws DigesterException, FileNotFoundException, IOException
{
Expand Down Expand Up @@ -111,12 +110,12 @@ else if ( path.endsWith( digestSha1.getFilenameExtension() ) )

/**
* Creates a checksum file of the provided referenceFile.
*
*
* @param referenceFile the file to checksum.
* @param digester the digester to use.
* @return the checksum File that was created.
* @throws DigesterException if there was a problem calculating the checksum of the referenceFile.
* @throws IOException if there was a problem either reading the referenceFile, or writing the checksum file.
* @throws org.codehaus.plexus.digest.DigesterException if there was a problem calculating the checksum of the referenceFile.
* @throws java.io.IOException if there was a problem either reading the referenceFile, or writing the checksum file.
*/
public File createChecksum( File referenceFile, Digester digester ) throws DigesterException, IOException
{
Expand Down
16 changes: 13 additions & 3 deletions src/main/java/org/codehaus/plexus/digest/DigestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,31 @@ private DigestUtils()
{
// don't create this class
}

/**
* Take a raw checksum string and verify that it matches the expectedFilename and digester, then
* return the trimmed checksum string.
*
*
* @param rawChecksum the raw checksum string that may include the filename.
* @param digester the expected digester for this checksum string.
* @return the trimmed checksum string (no filename portion)
* @throws DigesterException if there was a problem verifying the checksum string.
* @throws org.codehaus.plexus.digest.DigesterException if there was a problem verifying the checksum string.
* @param expectedFilename a {@link java.lang.String} object.
*/
public static String cleanChecksum( String rawChecksum, Digester digester, String expectedFilename ) throws DigesterException
{
return cleanChecksum( rawChecksum, digester.getAlgorithm(), expectedFilename );
}

/**
* <p>cleanChecksum.</p>
*
* @param checksum a {@link java.lang.String} object.
* @param algorithm a {@link java.lang.String} object.
* @param path a {@link java.lang.String} object.
* @return a {@link java.lang.String} object.
* @throws org.codehaus.plexus.digest.DigesterException if any.
*/
public static String cleanChecksum( String checksum, String algorithm, String path )
throws DigesterException
{
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/org/codehaus/plexus/digest/Digester.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
public interface Digester
{
/** Constant <code>ROLE="Digester.class.getName()"</code> */
String ROLE = Digester.class.getName();

/**
Expand All @@ -33,10 +34,10 @@ public interface Digester
* @return the algorithm
*/
String getAlgorithm();

/**
* The filename extension for this digester.
*
*
* @return the filename extension.
*/
String getFilenameExtension();
Expand All @@ -46,7 +47,7 @@ public interface Digester
*
* @param file the file to calculate the checksum for
* @return the current checksum.
* @throws DigesterException if there was a problem computing the hashcode.
* @throws org.codehaus.plexus.digest.DigesterException if there was a problem computing the hashcode.
*/
String calc( File file )
throws DigesterException;
Expand All @@ -56,7 +57,7 @@ String calc( File file )
*
* @param file the file to compute the checksum for
* @param checksum the checksum to compare to
* @throws DigesterException if there was a problem computing the hashcode.
* @throws org.codehaus.plexus.digest.DigesterException if there was a problem computing the hashcode.
*/
void verify( File file, String checksum )
throws DigesterException;
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/org/codehaus/plexus/digest/DigesterException.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,47 @@
*/

/**
* <p>DigesterException class.</p>
*
* @author Edwin Punzalan
*/
public class DigesterException
extends Exception
{
/**
* <p>Constructor for DigesterException.</p>
*/
public DigesterException()
{
super();
}

/**
* <p>Constructor for DigesterException.</p>
*
* @param message a {@link java.lang.String} object.
*/
public DigesterException( String message )
{
super( message );
}

/**
* <p>Constructor for DigesterException.</p>
*
* @param message a {@link java.lang.String} object.
* @param cause a {@link java.lang.Throwable} object.
*/
public DigesterException( String message, Throwable cause )
{
super( message, cause );
}

/**
* <p>Constructor for DigesterException.</p>
*
* @param cause a {@link java.lang.Throwable} object.
*/
public DigesterException( Throwable cause )
{
super( cause );
Expand Down
15 changes: 13 additions & 2 deletions src/main/java/org/codehaus/plexus/digest/Hex.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,19 @@
*/

/**
* Hex - simple hex conversions.
* Hex - simple hex conversions.
*
* @version $Id$
*/
public class Hex
{
private static final byte[] DIGITS = "0123456789abcdef".getBytes();

/**
* <p>encode.</p>
*
* @param data an array of {@link byte} objects.
* @return a {@link java.lang.String} object.
*/
public static String encode( byte[] data )
{
int l = data.length;
Expand All @@ -40,6 +45,12 @@ public static String encode( byte[] data )
return new String( raw );
}

/**
* <p>encode.</p>
*
* @param raw a {@link java.lang.String} object.
* @return a {@link java.lang.String} object.
*/
public static String encode( String raw )
{
return encode( raw.getBytes() );
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/org/codehaus/plexus/digest/Md5Digester.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,25 @@

/**
* Digester that does MD5 Message Digesting Only.
*
*
* @plexus.component role="org.codehaus.plexus.digest.Digester" role-hint="md5"
*/
public class Md5Digester
extends AbstractDigester
{
/**
* <p>getFilenameExtension.</p>
*
* @return a {@link java.lang.String} object.
*/
public String getFilenameExtension()
{
return ".md5";
}


/**
* <p>Constructor for Md5Digester.</p>
*/
public Md5Digester()
{
super( new StreamingMd5Digester() );
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/org/codehaus/plexus/digest/Sha1Digester.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,19 @@
public class Sha1Digester
extends AbstractDigester
{
/**
* <p>getFilenameExtension.</p>
*
* @return a {@link java.lang.String} object.
*/
public String getFilenameExtension()
{
return ".sha1";
}


/**
* <p>Constructor for Sha1Digester.</p>
*/
public Sha1Digester()
{
super( new StreamingSha1Digester() );
Expand Down
Loading

0 comments on commit 62224ff

Please sign in to comment.