1 package org.codehaus.plexus.digest; 2 3 /* 4 * Copyright 2001-2006 The Codehaus. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 import java.io.File; 20 21 /** 22 * Create a digest for a file. 23 * 24 * @author <a href="mailto:brett@apache.org">Brett Porter</a> 25 */ 26 public interface Digester 27 { 28 String ROLE = Digester.class.getName(); 29 30 /** 31 * Get the algorithm used for the checksum. 32 * 33 * @return the algorithm 34 */ 35 String getAlgorithm(); 36 37 /** 38 * The filename extension for this digester. 39 * 40 * @return the filename extension. 41 */ 42 String getFilenameExtension(); 43 44 /** 45 * Calculate a checksum for a file. 46 * 47 * @param file the file to calculate the checksum for 48 * @return the current checksum. 49 * @throws DigesterException if there was a problem computing the hashcode. 50 */ 51 String calc( File file ) 52 throws DigesterException; 53 54 /** 55 * Verify that a checksum is correct. 56 * 57 * @param file the file to compute the checksum for 58 * @param checksum the checksum to compare to 59 * @throws DigesterException if there was a problem computing the hashcode. 60 */ 61 void verify( File file, String checksum ) 62 throws DigesterException; 63 }