org.apache.commons.net.imap
Class IMAP

java.lang.Object
  extended by org.apache.commons.net.SocketClient
      extended by org.apache.commons.net.imap.IMAP
Direct Known Subclasses:
IMAPClient

public class IMAP
extends SocketClient

The IMAP class provides the basic the functionality necessary to implement your own IMAP client.


Nested Class Summary
static class IMAP.IMAPState
           
 
Field Summary
protected static String __DEFAULT_ENCODING
          The default control socket ecoding.
protected  BufferedWriter __writer
           
protected  BufferedReader _reader
           
static int DEFAULT_PORT
          The default IMAP port (RFC 3501).
 
Fields inherited from class org.apache.commons.net.SocketClient
_defaultPort_, _input_, _output_, _serverSocketFactory_, _socket_, _socketFactory_, _timeout_, connectTimeout, NETASCII_EOL
 
Constructor Summary
IMAP()
          The default IMAPClient constructor.
 
Method Summary
protected  void _connectAction_()
          Performs connection initialization and sets state to IMAP.IMAPState.NOT_AUTH_STATE.
 void disconnect()
          Disconnects the client from the server, and sets the state to DISCONNECTED_STATE .
 boolean doCommand(IMAPCommand command)
          Sends a command to the server and return whether successful.
 boolean doCommand(IMAPCommand command, String args)
          Sends a command and arguments to the server and return whether successful.
protected  String generateCommandID()
          Generates a new command ID (tag) for a command.
 String getReplyString()
          Returns the reply to the last command sent to the server.
 String[] getReplyStrings()
          Returns an array of lines received as a reply to the last command sent to the server.
 IMAP.IMAPState getState()
          Returns the current IMAP client state.
 int sendCommand(IMAPCommand command)
          Sends a command with no arguments to the server and returns the reply code.
 int sendCommand(IMAPCommand command, String args)
          Sends a command and arguments to the server and returns the reply code.
 int sendCommand(String command)
          Sends a command with no arguments to the server and returns the reply code.
 int sendCommand(String command, String args)
          Sends a command an arguments to the server and returns the reply code.
 int sendData(String command)
          Sends data to the server and returns the reply code.
protected  void setState(IMAP.IMAPState state)
          Sets IMAP client state.
 
Methods inherited from class org.apache.commons.net.SocketClient
addProtocolCommandListener, connect, connect, connect, connect, connect, connect, createCommandSupport, fireCommandSent, fireReplyReceived, getCommandSupport, getConnectTimeout, getDefaultPort, getDefaultTimeout, getKeepAlive, getLocalAddress, getLocalPort, getProxy, getReceiveBufferSize, getRemoteAddress, getRemotePort, getSendBufferSize, getServerSocketFactory, getSoLinger, getSoTimeout, getTcpNoDelay, isAvailable, isConnected, removeProtocolCommandListener, setConnectTimeout, setDefaultPort, setDefaultTimeout, setKeepAlive, setProxy, setReceiveBufferSize, setSendBufferSize, setServerSocketFactory, setSocketFactory, setSoLinger, setSoTimeout, setTcpNoDelay, verifyRemote
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PORT

public static final int DEFAULT_PORT
The default IMAP port (RFC 3501).

See Also:
Constant Field Values

__DEFAULT_ENCODING

protected static final String __DEFAULT_ENCODING
The default control socket ecoding.

See Also:
Constant Field Values

__writer

protected BufferedWriter __writer

_reader

protected BufferedReader _reader
Constructor Detail

IMAP

public IMAP()
The default IMAPClient constructor. Initializes the state to DISCONNECTED_STATE.

Method Detail

_connectAction_

protected void _connectAction_()
                        throws IOException
Performs connection initialization and sets state to IMAP.IMAPState.NOT_AUTH_STATE.

Overrides:
_connectAction_ in class SocketClient
Throws:
IOException

setState

protected void setState(IMAP.IMAPState state)
Sets IMAP client state. This must be one of the _STATE constants.

Parameters:
state - The new state.

getState

public IMAP.IMAPState getState()
Returns the current IMAP client state.

Returns:
The current IMAP client state.

disconnect

public void disconnect()
                throws IOException
Disconnects the client from the server, and sets the state to DISCONNECTED_STATE . The reply text information from the last issued command is voided to allow garbage collection of the memory used to store that information.

Overrides:
disconnect in class SocketClient
Throws:
IOException - If there is an error in disconnecting.

sendCommand

public int sendCommand(String command,
                       String args)
                throws IOException
Sends a command an arguments to the server and returns the reply code.

Parameters:
command - The IMAP command to send.
args - The command arguments.
Returns:
The server reply code (see IMAPReply).
Throws:
IOException

sendCommand

public int sendCommand(String command)
                throws IOException
Sends a command with no arguments to the server and returns the reply code.

Parameters:
command - The IMAP command to send.
Returns:
The server reply code (see IMAPReply).
Throws:
IOException

sendCommand

public int sendCommand(IMAPCommand command,
                       String args)
                throws IOException
Sends a command and arguments to the server and returns the reply code.

Parameters:
command - The IMAP command to send (one of the IMAPCommand constants).
args - The command arguments.
Returns:
The server reply code (see IMAPReply).
Throws:
IOException

doCommand

public boolean doCommand(IMAPCommand command,
                         String args)
                  throws IOException
Sends a command and arguments to the server and return whether successful.

Parameters:
command - The IMAP command to send (one of the IMAPCommand constants).
args - The command arguments.
Returns:
true if the command was successful
Throws:
IOException

sendCommand

public int sendCommand(IMAPCommand command)
                throws IOException
Sends a command with no arguments to the server and returns the reply code.

Parameters:
command - The IMAP command to send (one of the IMAPCommand constants).
Returns:
The server reply code (see IMAPReply).
Throws:
IOException

doCommand

public boolean doCommand(IMAPCommand command)
                  throws IOException
Sends a command to the server and return whether successful.

Parameters:
command - The IMAP command to send (one of the IMAPCommand constants).
Returns:
true if the command was successful
Throws:
IOException

sendData

public int sendData(String command)
             throws IOException
Sends data to the server and returns the reply code.

Parameters:
command - The IMAP command to send.
Returns:
The server reply code (see IMAPReply).
Throws:
IOException

getReplyStrings

public String[] getReplyStrings()
Returns an array of lines received as a reply to the last command sent to the server. The lines have end of lines truncated.

Returns:
The last server response.

getReplyString

public String getReplyString()
Returns the reply to the last command sent to the server. The value is a single string containing all the reply lines including newlines.

Returns:
The last server response.

generateCommandID

protected String generateCommandID()
Generates a new command ID (tag) for a command.

Returns:
a new command ID (tag) for an IMAP command.


Copyright © 2001-2012 The Apache Software Foundation. All Rights Reserved.