[Jukebox-cvs] CVS update: J4/src/java/gnu/j4/io/base64 Base64DecoderInputStream.java Base64EncoderIn
Brought to you by:
vtt
From: CVS B. <vt...@fr...> - 2000-07-25 18:54:01
|
User: vt Date: 00/07/25 11:53:57 Modified: src/java/gnu/j4/io/base64 Base64DecoderInputStream.java Base64EncoderInputStream.java Log: Quick fix for the available() bug. available() is still not 100% correct, however, it correctly handles the end of input stream condition. Revision Changes Path 1.4 +25 -4 J4/src/java/gnu/j4/io/base64/Base64DecoderInputStream.java CVSWEB Options: ------------------- CVSWeb: Annotate this file: http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/J4/src/java/gnu/j4/io/base64/Base64DecoderInputStream.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/Base64DecoderInputStream.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/Base64DecoderInputStream.java.diff?r1=1.4&r2=1.3&cvsroot=jukebox4 ----------------------------------- Index: Base64DecoderInputStream.java =================================================================== RCS file: /usr/local/cvs/J4/src/java/gnu/j4/io/base64/Base64DecoderInputStream.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Base64DecoderInputStream.java 1999/06/29 04:35:35 1.3 +++ Base64DecoderInputStream.java 2000/07/25 18:53:57 1.4 @@ -6,13 +6,15 @@ /** * RFC-2045 compliant implementation of Base64 content decoding reader. - * <br> - * Reads from the Base64 encoded stream, returns the source data stream. + * + * Reads the bytes from the Base64 encoded stream, returns the bytes from the source data stream. + * * <p> + * * Be careful with instances of this class, they're good just for once. * - * @author Unknown, last modified by <a href="mailto:vt...@fr...">Vadim Tkachenko</a> 1995-1998 - * @version $Id: Base64DecoderInputStream.java,v 1.3 1999/06/29 04:35:35 vt Exp $ + * @author Unknown, last modified by <a href="mailto:vt...@fr...">Vadim Tkachenko</a> 1995-2000 + * @version $Id: Base64DecoderInputStream.java,v 1.4 2000/07/25 18:53:57 vt Exp $ */ public class Base64DecoderInputStream extends Base64InputStream { /** @@ -81,5 +83,24 @@ state.writeOctetByte( (byte)c ); } return true; + } + + /** + * Returns the number of bytes that can be read from this input stream without + * blocking. + * + * This methods reads the value of <code>super.available()</code> and + * adjusts it with the amount of data available in the triplet. + * + * @return The number of bytes that can be read from the input stream + * without blocking. + * + * @exception IOException - if an I/O error occurs. + */ + public int available() throws IOException { + + System.err.println("Available: " + super.available() + "/" + state.tripletAvailable()); + + return super.available() + state.tripletAvailable(); } } 1.4 +28 -4 J4/src/java/gnu/j4/io/base64/Base64EncoderInputStream.java CVSWEB Options: ------------------- CVSWeb: Annotate this file: http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/J4/src/java/gnu/j4/io/base64/Base64EncoderInputStream.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/Base64EncoderInputStream.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/Base64EncoderInputStream.java.diff?r1=1.4&r2=1.3&cvsroot=jukebox4 ----------------------------------- Index: Base64EncoderInputStream.java =================================================================== RCS file: /usr/local/cvs/J4/src/java/gnu/j4/io/base64/Base64EncoderInputStream.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Base64EncoderInputStream.java 1999/06/29 04:35:35 1.3 +++ Base64EncoderInputStream.java 2000/07/25 18:53:57 1.4 @@ -5,14 +5,19 @@ /** * RFC-2045 compliant implementation of Base64 content encoding reader. - * <br> - * Reads from the data source stream, returns the Base64 encoded stream. + * + * Reads the bytes from the data source stream, returns the bytes from the + * Base64 encoded stream. + * * <p> + * * Be careful with instances of this class, they're good just for once. - * @author Copyright © <a href="mailto:vt...@fr...">Vadim Tkachenko</a> 1995-1998 - * @version $Id: Base64EncoderInputStream.java,v 1.3 1999/06/29 04:35:35 vt Exp $ + * + * @author Copyright © <a href="mailto:vt...@fr...">Vadim Tkachenko</a> 1995-2000 + * @version $Id: Base64EncoderInputStream.java,v 1.4 2000/07/25 18:53:57 vt Exp $ */ public class Base64EncoderInputStream extends Base64InputStream implements Base64Constants { + /** * Current maximum line length. * Can't be lower than 4. 0 means infinite. @@ -159,5 +164,24 @@ */ public int getMaxLineLength() { return maxLineLength; + } + + /** + * Returns the number of bytes that can be read from this input stream without + * blocking. + * + * This methods reads the value of <code>super.available()</code> and + * adjusts it with the amount of data available in the octet. + * + * @return The number of bytes that can be read from the input stream + * without blocking. + * + * @exception IOException - if an I/O error occurs. + */ + public int available() throws IOException { + +// System.err.println("Available: " + super.available() + "/" + state.octetAvailable()); + + return super.available() + state.octetAvailable(); } } |