LoggingInputStreampublic 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 void | logRaw(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 int | read()Collect chars as read, and log them when EOL reached.
int oneByte = mIn.read();
logRaw(oneByte);
return oneByte;
| public int | read(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;
|
|