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.InputStream; 20 21 /** 22 * Gradually create a digest for a stream. 23 * 24 * @author <a href="mailto:brett@apache.org">Brett Porter</a> 25 */ 26 public interface StreamingDigester 27 { 28 String ROLE = StreamingDigester.class.getName(); 29 30 /** 31 * Get the algorithm used for the checksum. 32 * 33 * @return the algorithm 34 */ 35 String getAlgorithm(); 36 37 /** 38 * Reset the hashcode calculation algorithm. 39 * Only useful when performing incremental hashcodes based on repeated use of {@link #update(InputStream)} 40 * 41 * @throws DigesterException if there was a problem with the internal message digest 42 */ 43 void reset() 44 throws DigesterException; 45 46 /** 47 * Calculate the current checksum. 48 * 49 * @return the current checksum. 50 * @throws DigesterException if there was a problem computing the hashcode. 51 */ 52 String calc() 53 throws DigesterException; 54 55 /** 56 * Update the checksum with the content of the input stream. 57 * 58 * @param is the input stream 59 * @throws DigesterException if there was a problem computing the hashcode. 60 */ 61 void update( InputStream is ) 62 throws DigesterException; 63 64 }