org.apache.geronimo.javamail.store.imap.connection
Class IMAPResponseStream

java.lang.Object
  extended by org.apache.geronimo.javamail.store.imap.connection.IMAPResponseStream

public class IMAPResponseStream
extends Object


Field Summary
protected  byte[] buffer
           
protected  int BUFFER_SIZE
           
protected  InputStream in
           
 
Constructor Summary
IMAPResponseStream(InputStream in)
           
 
Method Summary
 void checkLiteral()
          Check the line just read to see if we're processing a line with a literal value.
protected  boolean fillBufferIfNeeded()
           
protected  int nextByte()
          Get the next byte from the input stream, handling read errors and EOF conditions as MessagingExceptions.
 int read()
           
 void readBuffer()
          Read a buffer of data.
 byte[] readData()
          Read a "line" of server response data.
 IMAPResponse readResponse()
          Read a single response line from the input stream, returning a parsed and processed response line.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUFFER_SIZE

protected final int BUFFER_SIZE
See Also:
Constant Field Values

in

protected InputStream in

buffer

protected byte[] buffer
Constructor Detail

IMAPResponseStream

public IMAPResponseStream(InputStream in)
Method Detail

read

public int read()
         throws IOException
Throws:
IOException

fillBufferIfNeeded

protected boolean fillBufferIfNeeded()
                              throws IOException
Throws:
IOException

readResponse

public IMAPResponse readResponse()
                          throws MessagingException
Read a single response line from the input stream, returning a parsed and processed response line.

Returns:
A parsed IMAPResponse item using the response data.
Throws:
MessagingException

readData

public byte[] readData()
                throws MessagingException
Read a "line" of server response data. An individual line may span multiple line breaks, depending on syntax implications.

Returns:
Throws:
MessagingException

readBuffer

public void readBuffer()
                throws MessagingException
Read a buffer of data. This accumulates the data into a ByteArrayOutputStream, terminating the processing at a line break. This also handles line breaks that are the result of literal continuations in the stream.

Throws:
MessagingException
IOException

checkLiteral

public void checkLiteral()
                  throws MessagingException
Check the line just read to see if we're processing a line with a literal value. Literals are encoded as "{length}\r\n", so if we've read up to the line break, we can check to see if we need to continue reading. If a literal marker is found, we read that many characters from the reader without looking for line breaks. Once we've read the literal data, we just read the rest of the line as normal (which might also end with a literal marker).

Throws:
MessagingException

nextByte

protected int nextByte()
                throws MessagingException
Get the next byte from the input stream, handling read errors and EOF conditions as MessagingExceptions.

Returns:
The next byte read from the stream.
Throws:
MessagingException


Copyright © 2003-2009 The Apache Software Foundation. All Rights Reserved.