FileDocCategorySizeDatePackage
LoggingInputStream.javaAPI DocAndroid 1.5 API2427Wed May 06 22:42:46 BST 2009com.android.email.mail.transport

LoggingInputStream

public class LoggingInputStream extends InputStream
Simple class used for debugging only that affords us a view of the raw IMAP or POP3 stream, in addition to the tokenized version. Use of this class *MUST* be restricted to logging-enabled situations only.

Fields Summary
InputStream
mIn
StringBuilder
mSb
boolean
mBufferDirty
private final String
LINE_TAG
Constructors Summary
public LoggingInputStream(InputStream in)


       
        super();
        mIn = in;
        mSb = new StringBuilder(LINE_TAG);
        mBufferDirty = false;
    
Methods Summary
private voidlogRaw(int oneByte)
Write and clear the buffer

        if (oneByte == '\r" || oneByte == '\n") {          
            if (mBufferDirty) {
                Log.d(Email.LOG_TAG, mSb.toString());
                mSb = new StringBuilder(LINE_TAG);
                mBufferDirty = false;
            }
        } else {
            mSb.append((char)oneByte);
            mBufferDirty = true;
        }
    
public intread()
Collect chars as read, and log them when EOL reached.

        int oneByte = mIn.read();
        logRaw(oneByte);
        return oneByte;
    
public intread(byte[] b, int offset, int length)
Collect chars as read, and log them when EOL reached.

        int bytesRead = mIn.read(b, offset, length);
        int copyBytes = bytesRead;
        while (copyBytes > 0) {
            logRaw((char)b[offset]);
            copyBytes--;
            offset++;
        }

        return bytesRead;