< prev index next >

src/java.base/share/classes/java/security/MessageDigestSpi.java

Print this page
rev 56290 : 8230648: Replace @exception tag with @throws in java.base
Summary: Minor coding style update of javadoc tag in any file in java.base
Reviewed-by: prappo, lancea
   1 /*
   2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 150      * engine implementor.
 151      *
 152      * This method should be abstract, but we leave it concrete for
 153      * binary compatibility.  Knowledgeable providers should override this
 154      * method.
 155      *
 156      * @param buf the output buffer in which to store the digest
 157      *
 158      * @param offset offset to start from in the output buffer
 159      *
 160      * @param len number of bytes within buf allotted for the digest.
 161      * Both this default implementation and the SUN provider do not
 162      * return partial digests.  The presence of this parameter is solely
 163      * for consistency in our API's.  If the value of this parameter is less
 164      * than the actual digest length, the method will throw a DigestException.
 165      * This parameter is ignored if its value is greater than or equal to
 166      * the actual digest length.
 167      *
 168      * @return the length of the digest stored in the output buffer.
 169      *
 170      * @exception DigestException if an error occurs.
 171      *
 172      * @since 1.2
 173      */
 174     protected int engineDigest(byte[] buf, int offset, int len)
 175                                                 throws DigestException {
 176 
 177         byte[] digest = engineDigest();
 178         if (len < digest.length)
 179                 throw new DigestException("partial digests not returned");
 180         if (buf.length - offset < digest.length)
 181                 throw new DigestException("insufficient space in the output "
 182                                           + "buffer to store the digest");
 183         System.arraycopy(digest, 0, buf, offset, digest.length);
 184         return digest.length;
 185     }
 186 
 187     /**
 188      * Resets the digest for further use.
 189      */
 190     protected abstract void engineReset();
 191 
 192     /**
 193      * Returns a clone if the implementation is cloneable.
 194      *
 195      * @return a clone if the implementation is cloneable.
 196      *
 197      * @exception CloneNotSupportedException if this is called on an
 198      * implementation that does not support {@code Cloneable}.
 199      */
 200     public Object clone() throws CloneNotSupportedException {
 201         if (this instanceof Cloneable) {
 202             return super.clone();
 203         } else {
 204             throw new CloneNotSupportedException();
 205         }
 206     }
 207 }
   1 /*
   2  * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 150      * engine implementor.
 151      *
 152      * This method should be abstract, but we leave it concrete for
 153      * binary compatibility.  Knowledgeable providers should override this
 154      * method.
 155      *
 156      * @param buf the output buffer in which to store the digest
 157      *
 158      * @param offset offset to start from in the output buffer
 159      *
 160      * @param len number of bytes within buf allotted for the digest.
 161      * Both this default implementation and the SUN provider do not
 162      * return partial digests.  The presence of this parameter is solely
 163      * for consistency in our API's.  If the value of this parameter is less
 164      * than the actual digest length, the method will throw a DigestException.
 165      * This parameter is ignored if its value is greater than or equal to
 166      * the actual digest length.
 167      *
 168      * @return the length of the digest stored in the output buffer.
 169      *
 170      * @throws    DigestException if an error occurs.
 171      *
 172      * @since 1.2
 173      */
 174     protected int engineDigest(byte[] buf, int offset, int len)
 175                                                 throws DigestException {
 176 
 177         byte[] digest = engineDigest();
 178         if (len < digest.length)
 179                 throw new DigestException("partial digests not returned");
 180         if (buf.length - offset < digest.length)
 181                 throw new DigestException("insufficient space in the output "
 182                                           + "buffer to store the digest");
 183         System.arraycopy(digest, 0, buf, offset, digest.length);
 184         return digest.length;
 185     }
 186 
 187     /**
 188      * Resets the digest for further use.
 189      */
 190     protected abstract void engineReset();
 191 
 192     /**
 193      * Returns a clone if the implementation is cloneable.
 194      *
 195      * @return a clone if the implementation is cloneable.
 196      *
 197      * @throws    CloneNotSupportedException if this is called on an
 198      * implementation that does not support {@code Cloneable}.
 199      */
 200     public Object clone() throws CloneNotSupportedException {
 201         if (this instanceof Cloneable) {
 202             return super.clone();
 203         } else {
 204             throw new CloneNotSupportedException();
 205         }
 206     }
 207 }
< prev index next >