Package com.icegreen.greenmail.imap
Class ImapRequestLineReader
- java.lang.Object
-
- com.icegreen.greenmail.imap.ImapRequestLineReader
-
public class ImapRequestLineReader extends Object
Wraps the client input reader with a bunch of convenience methods, allowing lookahead=1 on the underlying character stream. TODO need to look at encoding, and whether we should be wrapping an InputStream instead.- Version:
- $Revision: 109034 $
- Author:
- Darrell DeBoer
-
-
Constructor Summary
Constructors Constructor Description ImapRequestLineReader(InputStream input, OutputStream output)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcommandContinuationRequest()Sends a server command continuation request '+' back to the client, requesting more data to be sent.charconsume()Consumes the current character in the reader, so that subsequent calls to the request will provide a new character.charconsumeAll(char c)Consumes all given chars.voidconsumeLine()Consumes whole line till newline.voideol()Moves the request line reader to end of the line, checking that no non-space character are found.charnextChar()Reads the next character in the current line.charnextWordChar()Reads the next regular, non-space character in the current line.voidread(byte[] holder)Reads and consumes a number of characters from the underlying reader, filling the byte array provided.
-
-
-
Constructor Detail
-
ImapRequestLineReader
public ImapRequestLineReader(InputStream input, OutputStream output)
-
-
Method Detail
-
nextWordChar
public char nextWordChar() throws ProtocolExceptionReads the next regular, non-space character in the current line. Spaces are skipped over, but end-of-line characters will cause aProtocolExceptionto be thrown. This method will continue to return the same character until theconsume()method is called.- Returns:
- The next non-space character.
- Throws:
ProtocolException- If the end-of-line or end-of-stream is reached.
-
nextChar
public char nextChar() throws ProtocolExceptionReads the next character in the current line. This method will continue to return the same character until theconsume()method is called.- Returns:
- The next character.
- Throws:
ProtocolException- If the end-of-stream is reached.
-
eol
public void eol() throws ProtocolExceptionMoves the request line reader to end of the line, checking that no non-space character are found.- Throws:
ProtocolException- If more non-space tokens are found in this line, or the end-of-file is reached.
-
consume
public char consume() throws ProtocolExceptionConsumes the current character in the reader, so that subsequent calls to the request will provide a new character. This method does *not* read the new character, or check if such a character exists. If no current character has been seen, the method moves to the next character, consumes it, and moves on to the subsequent one.- Throws:
ProtocolException- if a the current character can't be obtained (eg we're at end-of-file).
-
read
public void read(byte[] holder) throws ProtocolExceptionReads and consumes a number of characters from the underlying reader, filling the byte array provided.- Parameters:
holder- A byte array which will be filled with bytes read from the underlying reader.- Throws:
ProtocolException- If a char can't be read into each array element.
-
commandContinuationRequest
public void commandContinuationRequest() throws ProtocolExceptionSends a server command continuation request '+' back to the client, requesting more data to be sent.- Throws:
ProtocolException
-
consumeLine
public void consumeLine() throws ProtocolExceptionConsumes whole line till newline.- Throws:
ProtocolException- on error.
-
consumeAll
public char consumeAll(char c) throws ProtocolExceptionConsumes all given chars.- Returns:
- next char
- Throws:
ProtocolException- on error.
-
-