org.apache.commons.net.pop3
Class POP3
The POP3 class is not meant to be used by itself and is provided
only so that you may easily implement your own POP3 client if
you so desire. If you have no need to perform your own implementation,
you should use
POP3Client
.
Rather than list it separately for each method, we mention here that
every method communicating with the server and throwing an IOException
can also throw a
MalformedServerReplyException
, which is a subclass
of IOException. A MalformedServerReplyException will be thrown when
the reply received from the server deviates enough from the protocol
specification that it cannot be interpreted in a useful manner despite
attempts to be as lenient as possible.
POP3() -
The default POP3Client constructor.
|
protected void | _connectAction_() -
Performs connection initialization and sets state to
AUTHORIZATION_STATE .
|
void | addProtocolCommandListener(ProtocolCommandListener listener) -
Adds a ProtocolCommandListener.
|
void | disconnect() -
Disconnects the client from the server, and sets the state to
DISCONNECTED_STATE .
|
void | getAdditionalReply() -
Retrieves the additional lines of a multi-line server reply.
|
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.
|
int | getState() -
Returns the current POP3 client state.
|
void | removeProtocolCommandistener(ProtocolCommandListener listener) -
Removes a ProtocolCommandListener.
|
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 | sendCommand(int command) -
Sends a command with no arguments to the server and returns the
reply code.
|
int | sendCommand(int command, String args) -
Sends a command an arguments to the server and returns the reply code.
|
void | setState(int state) -
Sets POP3 client state.
|
_connectAction_ , connect , connect , connect , connect , connect , connect , disconnect , getDefaultPort , getDefaultTimeout , getLocalAddress , getLocalPort , getRemoteAddress , getRemotePort , getSoLinger , getSoTimeout , getTcpNoDelay , isConnected , setDefaultPort , setDefaultTimeout , setSoLinger , setSoTimeout , setSocketFactory , setTcpNoDelay , verifyRemote |
AUTHORIZATION_STATE
public static final int AUTHORIZATION_STATE
A constant representing the POP3 authorization state. **
DEFAULT_PORT
public static final int DEFAULT_PORT
The default POP3 port. Set to 110 according to RFC 1288. **
DISCONNECTED_STATE
public static final int DISCONNECTED_STATE
A constant representing the state where the client is not yet connected
to a POP3 server.
TRANSACTION_STATE
public static final int TRANSACTION_STATE
A constant representing the POP3 transaction state. **
UPDATE_STATE
public static final int UPDATE_STATE
A constant representing the POP3 update state. **
_commandSupport_
protected ProtocolCommandSupport _commandSupport_
A ProtocolCommandSupport object used to manage the registering of
ProtocolCommandListeners and te firing of ProtocolCommandEvents.
POP3
public POP3()
The default POP3Client constructor. Initializes the state
to DISCONNECTED_STATE
.
_connectAction_
protected void _connectAction_()
throws IOException
Performs connection initialization and sets state to
AUTHORIZATION_STATE
.
- _connectAction_ in interface SocketClient
addProtocolCommandListener
public void addProtocolCommandListener(ProtocolCommandListener listener)
listener
- The ProtocolCommandListener to add.
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.
- disconnect in interface SocketClient
getAdditionalReply
public void getAdditionalReply()
throws IOException
Retrieves the additional lines of a multi-line server reply.
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. If the reply is a single line, but its format ndicates it
should be a multiline reply, then you must call
getAdditionalReply()
to
fetch the rest of the reply, and then call
getReplyString
again. You only have to worry about this if you are implementing
your own client using the
sendCommand
methods.
- The last server response.
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. If
the reply is a single line, but its format ndicates it should be
a multiline reply, then you must call
getAdditionalReply()
to
fetch the rest of the reply, and then call
getReplyStrings
again. You only have to worry about this if you are implementing
your own client using the
sendCommand
methods.
- The last server response.
getState
public int getState()
Returns the current POP3 client state.
- The current POP3 client state.
removeProtocolCommandistener
public void removeProtocolCommandistener(ProtocolCommandListener listener)
listener
- The ProtocolCommandListener to remove.
sendCommand
public int sendCommand(String command)
throws IOException
Sends a command with no arguments to the server and returns the
reply code.
command
- The POP3 command to send.
- The server reply code (either POP3Reply.OK or POP3Reply.ERROR).
sendCommand
public int sendCommand(String command,
String args)
throws IOException
Sends a command an arguments to the server and returns the reply code.
command
- The POP3 command to send.args
- The command arguments.
- The server reply code (either POP3Reply.OK or POP3Reply.ERROR).
sendCommand
public int sendCommand(int command)
throws IOException
Sends a command with no arguments to the server and returns the
reply code.
command
- The POP3 command to send
(one of the POP3Command constants).
- The server reply code (either POP3Reply.OK or POP3Reply.ERROR).
sendCommand
public int sendCommand(int command,
String args)
throws IOException
Sends a command an arguments to the server and returns the reply code.
command
- The POP3 command to send
(one of the POP3Command constants).args
- The command arguments.
- The server reply code (either POP3Reply.OK or POP3Reply.ERROR).
setState
public void setState(int state)
Sets POP3 client state. This must be one of the
_STATE
constants.