[Jukebox-cvs] CVS update: J4/src/java/gnu/j4/io/base64 Base64State.java
Brought to you by:
vtt
From: CVS B. <vt...@fr...> - 2000-07-28 06:44:12
|
User: vt Date: 00/07/27 23:44:22 Modified: src/java/gnu/j4/io/base64 Base64State.java Log: Changed the modifiers to reflect the proper access permissions and documented a little Revision Changes Path 1.4 +62 -16 J4/src/java/gnu/j4/io/base64/Base64State.java CVSWEB Options: ------------------- CVSWeb: Annotate this file: http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/J4/src/java/gnu/j4/io/base64/Base64State.java?annotate=1.4&cvsroot=jukebox4 CVSWeb: View this file: http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/J4/src/java/gnu/j4/io/base64/Base64State.java?rev=1.4&content-type=text/x-cvsweb-markup&cvsroot=jukebox4 CVSWeb: Diff to previous version: http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/J4/src/java/gnu/j4/io/base64/Base64State.java.diff?r1=1.4&r2=1.3&cvsroot=jukebox4 ----------------------------------- Index: Base64State.java =================================================================== RCS file: /usr/local/cvs/J4/src/java/gnu/j4/io/base64/Base64State.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Base64State.java 1999/06/29 04:35:35 1.3 +++ Base64State.java 2000/07/28 06:44:22 1.4 @@ -5,11 +5,12 @@ * its access methods. * * @author Copyright © <a href="mailto:vt...@fr...">Vadim Tkachenko</a> 1995-1998 - * @version $Id: Base64State.java,v 1.3 1999/06/29 04:35:35 vt Exp $ + * @version $Id: Base64State.java,v 1.4 2000/07/28 06:44:22 vt Exp $ * @see Base64EncoderInputStream * @see Base64DecoderInputStream */ class Base64State { + /** * Offset within a triplet which points to the byte to read/write next. */ @@ -32,55 +33,98 @@ /** * Read the next byte from the octet. - * <p> - * Note: it's your responsibility to maintain the offset sane. + * + * No bounds checking is performed for efficiency, so don't try this at + * home. + * * @return Octet byte. */ - public byte readOctetByte() { + byte readOctetByte() { + return octet[offset4++]; } /** * Write the next byte to the octet. - * <p> - * Note: it's your responsibility to maintain the offset sane. + * + * No bounds checking is performed for efficiency, so don't try this at + * home. + * * @param b Byte to write. */ - public void writeOctetByte( byte b ) { + void writeOctetByte( byte b ) { + octet[offset4++] = b; } - public boolean isOctetReady() { + /** + * Check if the octet is full. + * + * @return <code>true</code> if the {@link #octet octet} {@link + * #offset4 offset} equals to 4, i.e. it is full and ready to be + * consumed. + */ + boolean isOctetReady() { + return (offset4 == 4) ? true : false; } - public void clearOctet() { + void clearOctet() { + offset4 = 0; } - public void clearTriplet() { + void clearTriplet() { + offset3 = 0; } - public void writeTripletByte( byte b ) { + /** + * Write the next byte to the triplet. + * + * No bounds checking is performed for efficiency, so don't try this at + * home. + * + * @param b Byte to write. + */ + void writeTripletByte( byte b ) { + triplet[offset3++] = b; } + + /** + * Check if the triplet is full. + * + * @return <code>true</code> if the {@link #triplet triplet} {@link + * #offset3 offset} equals to 3, i.e. it is full and ready to be + * consumed. + */ + boolean isTripletReady() { - public boolean isTripletReady() { return (offset3 == 3) ? true : false; } - public boolean isTripletClear() { + /** + * Check if the triplet is clear. + * + * @return <code>true</code> if the {@link #triplet triplet} {@link + * #offset3 offset} equals to 0, i.e. there's no data in the triplet. + */ + boolean isTripletClear() { return (offset3 == 0) ? true : false; } - public void clear() { + /** + * Clear both the {@link #triplet triplet} and {@link #octet}. + */ + void clear() { + clearTriplet(); clearOctet(); } @@ -90,7 +134,8 @@ * * @return number of bytes available to read/write from the triplet. */ - public int tripletAvailable() { + int tripletAvailable() { + return (3 - offset3); } @@ -99,7 +144,8 @@ * * @return number of bytes available to read/write from the octet. */ - public int octetAvailable() { + int octetAvailable() { + return (4 - offset4); } } |