diff -r b704be5f8463 -r dbe255defdbb samples/messagedigest/src-new-api/org/apidesign/api/security/DigestImplementation.java --- a/samples/messagedigest/src-new-api/org/apidesign/api/security/DigestImplementation.java Sat Nov 15 13:12:46 2008 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - -package org.apidesign.api.security; - -import java.nio.ByteBuffer; -import org.apidesign.spi.security.Digestor; - -/** - * - * @author Jaroslav Tulach - */ -final class DigestImplementation { - private static final DigestorAccessorImpl ACCESSOR = new DigestorAccessorImpl(); - - private final Digestor digestor; - private final String algorithm; - private Data data; - - private DigestImplementation(Digestor digestor, String algorithm, Data d) { - this.digestor = digestor; - this.algorithm = algorithm; - this.data = d; - } - - static DigestImplementation create(Digestor digestor, String algorithm) { - Data d = ACCESSOR.create(digestor, algorithm); - if (d == null) { - return null; - } else { - return new DigestImplementation(digestor, algorithm, d); - } - } - - byte[] digest(ByteBuffer bb) { - ACCESSOR.update(digestor, data, bb); - return ACCESSOR.digest(digestor, data); - } -}