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 |
---|---|
private int |
__popState |
protected ProtocolCommandSupport |
_commandSupport_
A ProtocolCommandSupport object used to manage the registering of
ProtocolCommandListeners and te firing of ProtocolCommandEvents.
|
(package private) static java.lang.String |
_DEFAULT_ENCODING |
(package private) static java.lang.String |
_ERROR |
(package private) java.lang.String |
_lastReplyLine |
(package private) static java.lang.String |
_OK |
(package private) static java.lang.String |
_OK_INT |
(package private) java.io.BufferedReader |
_reader |
(package private) int |
_replyCode |
(package private) java.util.List<java.lang.String> |
_replyLines |
(package private) java.io.BufferedWriter |
_writer |
static int |
AUTHORIZATION_STATE
A constant representing the POP3 authorization state.
|
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.
|
static int |
TRANSACTION_STATE
A constant representing the POP3 transaction state.
|
static int |
UPDATE_STATE
A constant representing the POP3 update state.
|
_defaultPort_, _hostname_, _input_, _output_, _serverSocketFactory_, _socket_, _socketFactory_, _timeout_, connectTimeout, NETASCII_EOL
Constructor and Description |
---|
POP3()
The default POP3Client constructor.
|
Modifier and Type | Method and Description |
---|---|
private void |
__getReply() |
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()
Retrieves the additional lines of a multi-line server reply.
|
protected ProtocolCommandSupport |
getCommandSupport()
Provide command support to super-class
|
java.lang.String |
getReplyString()
Returns the reply to the last command sent to the server.
|
java.lang.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(int command)
Sends a command with no arguments to the server and returns the
reply code.
|
int |
sendCommand(int command,
java.lang.String args)
Sends a command an arguments to the server and returns the reply code.
|
int |
sendCommand(java.lang.String command)
Sends a command with no arguments to the server and returns the
reply code.
|
int |
sendCommand(java.lang.String command,
java.lang.String args)
Sends a command an arguments to the server and returns the reply code.
|
void |
setState(int state)
Set the internal POP3 state.
|
addProtocolCommandListener, connect, connect, connect, connect, connect, connect, createCommandSupport, fireCommandSent, fireReplyReceived, getCharset, getCharsetName, getConnectTimeout, getDefaultPort, getDefaultTimeout, getKeepAlive, getLocalAddress, getLocalPort, getProxy, getReceiveBufferSize, getRemoteAddress, getRemotePort, getSendBufferSize, getServerSocketFactory, getSoLinger, getSoTimeout, getTcpNoDelay, isAvailable, isConnected, removeProtocolCommandListener, setCharset, setConnectTimeout, setDefaultPort, setDefaultTimeout, setKeepAlive, setProxy, setReceiveBufferSize, setSendBufferSize, setServerSocketFactory, setSocketFactory, setSoLinger, setSoTimeout, setTcpNoDelay, verifyRemote
public static final int DEFAULT_PORT
public static final int DISCONNECTED_STATE
public static final int AUTHORIZATION_STATE
public static final int TRANSACTION_STATE
public static final int UPDATE_STATE
static final java.lang.String _OK
static final java.lang.String _OK_INT
static final java.lang.String _ERROR
static final java.lang.String _DEFAULT_ENCODING
private int __popState
java.io.BufferedWriter _writer
java.io.BufferedReader _reader
int _replyCode
java.lang.String _lastReplyLine
java.util.List<java.lang.String> _replyLines
protected ProtocolCommandSupport _commandSupport_
public POP3()
DISCONNECTED_STATE
.private void __getReply() throws java.io.IOException
java.io.IOException
protected void _connectAction_() throws java.io.IOException
AUTHORIZATION_STATE
._connectAction_
in class SocketClient
java.io.IOException
- (SocketException) if a problem occurs with the socketpublic void setState(int state)
state
- the new state. This must be one of the _STATE
constants.public int getState()
public void getAdditionalReply() throws java.io.IOException
java.io.IOException
- on errorpublic void disconnect() throws java.io.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 SocketClient
java.io.IOException
- If there is an error in disconnecting.public int sendCommand(java.lang.String command, java.lang.String args) throws java.io.IOException
command
- The POP3 command to send.args
- The command arguments.java.io.IOException
- on errorpublic int sendCommand(java.lang.String command) throws java.io.IOException
command
- The POP3 command to send.java.io.IOException
- on errorpublic int sendCommand(int command, java.lang.String args) throws java.io.IOException
command
- The POP3 command to send
(one of the POP3Command constants).args
- The command arguments.java.io.IOException
- on errorpublic int sendCommand(int command) throws java.io.IOException
command
- The POP3 command to send
(one of the POP3Command constants).java.io.IOException
- on errorpublic java.lang.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 java.lang.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 void removeProtocolCommandistener(ProtocolCommandListener listener)
SocketClient.removeProtocolCommandListener(org.apache.commons.net.ProtocolCommandListener)
listener
- The ProtocolCommandListener to removeprotected ProtocolCommandSupport getCommandSupport()
getCommandSupport
in class SocketClient
null