Package org.apache.commons.net.pop3
Class POP3
java.lang.Object
org.apache.commons.net.SocketClient
org.apache.commons.net.pop3.POP3
- Direct Known Subclasses:
POP3Client
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.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected ProtocolCommandSupport
A ProtocolCommandSupport object used to manage the registering of ProtocolCommandListeners and the firing of ProtocolCommandEvents.static final int
A constant representing the POP3 authorization state.static final int
The default POP3 port.static final int
A constant representing the state where the client is not yet connected to a POP3 server.static final int
A constant representing the POP3 transaction state.static final int
A constant representing the POP3 update state.Fields inherited from class org.apache.commons.net.SocketClient
_defaultPort_, _hostname_, _input_, _output_, _serverSocketFactory_, _socket_, _socketFactory_, _timeout_, connectTimeout, NETASCII_EOL, remoteInetSocketAddress
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Performs connection initialization and sets state toAUTHORIZATION_STATE
.void
Disconnects the client from the server, and sets the state toDISCONNECTED_STATE
.void
Retrieves the additional lines of a multi-line server reply.protected ProtocolCommandSupport
Provide command support to super-classReturns the reply to the last command sent to the server.String[]
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
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.Methods inherited from class org.apache.commons.net.SocketClient
addProtocolCommandListener, applySocketAttributes, checkOpenOutputStream, connect, connect, connect, connect, connect, connect, createCommandSupport, fireCommandSent, fireReplyReceived, getCharset, getCharsetName, getConnectTimeout, getDefaultPort, getDefaultTimeout, 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, verifyRemote
-
Field Details
-
DEFAULT_PORT
The default POP3 port. Set to 110 according to RFC 1288.- See Also:
-
DISCONNECTED_STATE
A constant representing the state where the client is not yet connected to a POP3 server.- See Also:
-
AUTHORIZATION_STATE
A constant representing the POP3 authorization state.- See Also:
-
TRANSACTION_STATE
A constant representing the POP3 transaction state.- See Also:
-
UPDATE_STATE
A constant representing the POP3 update state.- See Also:
-
_commandSupport_
A ProtocolCommandSupport object used to manage the registering of ProtocolCommandListeners and the firing of ProtocolCommandEvents.
-
-
Constructor Details
-
POP3
public POP3()The default POP3Client constructor. Initializes the state toDISCONNECTED_STATE
.
-
-
Method Details
-
_connectAction_
Performs connection initialization and sets state toAUTHORIZATION_STATE
.- Overrides:
_connectAction_
in classSocketClient
- Throws:
IOException
- (SocketException) if a problem occurs with the socket
-
disconnect
Disconnects the client from the server, and sets the state toDISCONNECTED_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 classSocketClient
- Throws:
IOException
- If there is an error in disconnecting.
-
getAdditionalReply
Retrieves the additional lines of a multi-line server reply.- Throws:
IOException
- on error
-
getCommandSupport
Provide command support to super-class- Overrides:
getCommandSupport
in classSocketClient
- Returns:
- the CommandSupport instance, may be
null
-
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 callgetAdditionalReply()
to fetch the rest of the reply, and then callgetReplyString
again. You only have to worry about this if you are implementing your own client using thesendCommand
methods.- Returns:
- The last server response.
-
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 callgetAdditionalReply()
to fetch the rest of the reply, and then callgetReplyStrings
again. You only have to worry about this if you are implementing your own client using thesendCommand
methods.- Returns:
- The last server response.
-
getState
Returns the current POP3 client state.- Returns:
- The current POP3 client state.
-
removeProtocolCommandistener
Removes a ProtocolCommandListener. Delegates this incorrectly named method - removeProtocolCommandistener (note the missing "L")- to the correct methodSocketClient.removeProtocolCommandListener(org.apache.commons.net.ProtocolCommandListener)
- Parameters:
listener
- The ProtocolCommandListener to remove
-
sendCommand
Sends a command with no arguments to the server and returns the reply code.- Parameters:
command
- The POP3 command to send (one of the POP3Command constants).- Returns:
- The server reply code (either
POP3Reply.OK
,POP3Reply.ERROR
orPOP3Reply.OK_INT
). - Throws:
IOException
- on error
-
sendCommand
Sends a command an arguments to the server and returns the reply code.- Parameters:
command
- The POP3 command to send (one of the POP3Command constants).args
- The command arguments.- Returns:
- The server reply code (either
POP3Reply.OK
,POP3Reply.ERROR
orPOP3Reply.OK_INT
). - Throws:
IOException
- on error
-
sendCommand
Sends a command with no arguments to the server and returns the reply code.- Parameters:
command
- The POP3 command to send.- Returns:
- The server reply code (either
POP3Reply.OK
,POP3Reply.ERROR
orPOP3Reply.OK_INT
). - Throws:
IOException
- on error
-
sendCommand
Sends a command an arguments to the server and returns the reply code.- Parameters:
command
- The POP3 command to send.args
- The command arguments.- Returns:
- The server reply code (either
POP3Reply.OK
,POP3Reply.ERROR
orPOP3Reply.OK_INT
). - Throws:
IOException
- on error
-
setState
Sets the internal POP3 state.- Parameters:
state
- the new state. This must be one of the_STATE
constants.
-