public class POP3 extends SocketClient
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.
POP3Client,
MalformedServerReplyException| Modifier and Type | Field and Description |
|---|---|
protected ProtocolCommandSupport |
_commandSupport_
A ProtocolCommandSupport object used to manage the registering of ProtocolCommandListeners and the firing of ProtocolCommandEvents.
|
static int |
AUTHORIZATION_STATE
A constant representing the POP3 authorization state.
|
(package private) static Charset |
DEFAULT_ENCODING |
static int |
DEFAULT_PORT
The default POP3 port.
|
static int |
DISCONNECTED_STATE
A constant representing the state where the client is not yet connected to a POP3 server.
|
(package private) static String |
ERROR |
(package private) String |
lastReplyLine |
(package private) static String |
OK |
(package private) static String |
OK_INT |
(package private) BufferedReader |
reader |
(package private) int |
replyCode |
(package private) List<String> |
replyLines |
static int |
TRANSACTION_STATE
A constant representing the POP3 transaction state.
|
static int |
UPDATE_STATE
A constant representing the POP3 update state.
|
(package private) BufferedWriter |
writer |
_defaultPort_, _hostname_, _input_, _output_, _serverSocketFactory_, _socket_, _socketFactory_, _timeout_, connectTimeout, NETASCII_EOL, remoteInetSocketAddress| Constructor and Description |
|---|
POP3()
The default POP3Client constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
_connectAction_()
Performs connection initialization and sets state to
AUTHORIZATION_STATE. |
void |
disconnect()
Disconnects the client from the server, and sets the state to
DISCONNECTED_STATE. |
void |
getAdditionalReply()
Gets the additional lines of a multi-line server reply.
|
protected ProtocolCommandSupport |
getCommandSupport()
Provide command support to super-class
|
String |
getReplyString()
Gets the reply to the last command sent to the server.
|
String[] |
getReplyStrings()
Gets an array of lines received as a reply to the last command sent to the server.
|
int |
getState()
Gets the current POP3 client state.
|
void |
removeProtocolCommandistener(ProtocolCommandListener listener)
Removes a ProtocolCommandListener.
|
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.
|
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.
|
void |
setState(int state)
Sets the internal POP3 state.
|
addProtocolCommandListener, applySocketAttributes, checkOpenOutputStream, connect, connect, connect, connect, connect, connect, createCommandSupport, fireCommandSent, fireReplyReceived, getCharset, getConnectTimeout, getDefaultPort, getDefaultTimeout, getHostAddress, getHostAddress, getKeepAlive, getLocalAddress, getLocalPort, getProxy, getReceiveBufferSize, getRemoteAddress, getRemoteInetSocketAddress, getRemotePort, getSendBufferSize, getServerSocketFactory, getSoLinger, getSoTimeout, getTcpNoDelay, isAvailable, isConnected, removeProtocolCommandListener, setCharset, setConnectTimeout, setDefaultPort, setDefaultTimeout, setKeepAlive, setProxy, setReceiveBufferSize, setSendBufferSize, setServerSocketFactory, setSocketFactory, setSoLinger, setSoTimeout, setTcpNoDelay, verifyRemoteprotected ProtocolCommandSupport _commandSupport_
public static final int AUTHORIZATION_STATE
static final Charset DEFAULT_ENCODING
public static final int DEFAULT_PORT
public static final int DISCONNECTED_STATE
static final String ERROR
String lastReplyLine
static final String OK
static final String OK_INT
BufferedReader reader
int replyCode
public static final int TRANSACTION_STATE
public static final int UPDATE_STATE
BufferedWriter writer
public POP3()
DISCONNECTED_STATE.protected void _connectAction_()
throws IOException
AUTHORIZATION_STATE._connectAction_ in class SocketClientIOException - (SocketException) if a problem occurs with the socketpublic void disconnect()
throws IOException
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 class SocketClientIOException - If there is an error in disconnecting.public void getAdditionalReply()
throws IOException
IOException - on errorprotected ProtocolCommandSupport getCommandSupport()
getCommandSupport in class SocketClientnullpublic String getReplyString()
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.public String[] getReplyStrings()
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.public int getState()
public void removeProtocolCommandistener(ProtocolCommandListener listener)
SocketClient.removeProtocolCommandListener(org.apache.commons.net.ProtocolCommandListener)listener - The ProtocolCommandListener to removepublic int sendCommand(int command)
throws IOException
command - The POP3 command to send (one of the POP3Command constants).POP3Reply.OK, POP3Reply.ERROR or POP3Reply.OK_INT).IOException - on errorpublic int sendCommand(int command,
String args)
throws IOException
command - The POP3 command to send (one of the POP3Command constants).args - The command arguments.POP3Reply.OK, POP3Reply.ERROR or POP3Reply.OK_INT).IOException - on errorpublic int sendCommand(String command) throws IOException
command - The POP3 command to send.POP3Reply.OK, POP3Reply.ERROR or POP3Reply.OK_INT).IOException - on errorpublic int sendCommand(String command, String args) throws IOException
command - The POP3 command to send.args - The command arguments.POP3Reply.OK, POP3Reply.ERROR or POP3Reply.OK_INT).IOException - on errorpublic void setState(int state)
state - the new state. This must be one of the _STATE constants.