Fields Summary |
---|
public static final int | DEFAULT_PORTThe default POP3 port. Set to 110 according to RFC 1288. |
public static final int | DISCONNECTED_STATEA constant representing the state where the client is not yet connected
to a POP3 server. |
public static final int | AUTHORIZATION_STATEA constant representing the POP3 authorization state. |
public static final int | TRANSACTION_STATEA constant representing the POP3 transaction state. |
public static final int | UPDATE_STATEA constant representing the POP3 update state. |
static final String | _OK |
static final String | _ERROR |
private static final String | __DEFAULT_ENCODING |
private int | __popState |
private BufferedWriter | __writer |
private StringBuffer | __commandBuffer |
BufferedReader | _reader |
int | _replyCode |
String | _lastReplyLine |
Vector | _replyLines |
protected org.apache.commons.net.ProtocolCommandSupport | _commandSupport_A ProtocolCommandSupport object used to manage the registering of
ProtocolCommandListeners and te firing of ProtocolCommandEvents. |
Methods Summary |
---|
private void | __getReply()
String line;
_replyLines.setSize(0);
line = _reader.readLine();
if (line == null)
throw new EOFException("Connection closed without indication.");
if (line.startsWith(_OK))
_replyCode = POP3Reply.OK;
else if (line.startsWith(_ERROR))
_replyCode = POP3Reply.ERROR;
else
throw new
MalformedServerReplyException(
"Received invalid POP3 protocol response from server.");
_replyLines.addElement(line);
_lastReplyLine = line;
if (_commandSupport_.getListenerCount() > 0)
_commandSupport_.fireReplyReceived(_replyCode, getReplyString());
|
protected void | _connectAction_()Performs connection initialization and sets state to
AUTHORIZATION_STATE .
super._connectAction_();
_reader =
new BufferedReader(new InputStreamReader(_input_,
__DEFAULT_ENCODING));
__writer =
new BufferedWriter(new OutputStreamWriter(_output_,
__DEFAULT_ENCODING));
__getReply();
setState(AUTHORIZATION_STATE);
|
public void | addProtocolCommandListener(org.apache.commons.net.ProtocolCommandListener listener)Adds a ProtocolCommandListener. Delegates this task to
{@link #_commandSupport_ _commandSupport_ }.
_commandSupport_.addProtocolCommandListener(listener);
|
public void | disconnect()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.
super.disconnect();
_reader = null;
__writer = null;
_lastReplyLine = null;
_replyLines.setSize(0);
setState(DISCONNECTED_STATE);
|
public void | getAdditionalReply()Retrieves the additional lines of a multi-line server reply.
String line;
line = _reader.readLine();
while (line != null)
{
_replyLines.addElement(line);
if (line.equals("."))
break;
line = _reader.readLine();
}
|
public java.lang.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
{@link #getAdditionalReply 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 {@link #sendCommand sendCommand } methods.
Enumeration en;
StringBuffer buffer = new StringBuffer(256);
en = _replyLines.elements();
while (en.hasMoreElements())
{
buffer.append((String)en.nextElement());
buffer.append(SocketClient.NETASCII_EOL);
}
return buffer.toString();
|
public java.lang.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
{@link #getAdditionalReply 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 {@link #sendCommand sendCommand } methods.
String[] lines;
lines = new String[_replyLines.size()];
_replyLines.copyInto(lines);
return lines;
|
public int | getState()Returns the current POP3 client state.
return __popState;
|
public void | removeProtocolCommandistener(org.apache.commons.net.ProtocolCommandListener listener)Removes a ProtocolCommandListener. Delegates this task to
{@link #_commandSupport_ _commandSupport_ }.
_commandSupport_.removeProtocolCommandListener(listener);
|
public int | sendCommand(java.lang.String command, java.lang.String args)Sends a command an arguments to the server and returns the reply code.
String message;
__commandBuffer.setLength(0);
__commandBuffer.append(command);
if (args != null)
{
__commandBuffer.append(' ");
__commandBuffer.append(args);
}
__commandBuffer.append(SocketClient.NETASCII_EOL);
__writer.write(message = __commandBuffer.toString());
__writer.flush();
if (_commandSupport_.getListenerCount() > 0)
_commandSupport_.fireCommandSent(command, message);
__getReply();
return _replyCode;
|
public int | sendCommand(java.lang.String command)Sends a command with no arguments to the server and returns the
reply code.
return sendCommand(command, null);
|
public int | sendCommand(int command, java.lang.String args)Sends a command an arguments to the server and returns the reply code.
return sendCommand(POP3Command._commands[command], args);
|
public int | sendCommand(int command)Sends a command with no arguments to the server and returns the
reply code.
return sendCommand(POP3Command._commands[command], null);
|
public void | setState(int state)Sets POP3 client state. This must be one of the
_STATE constants.
__popState = state;
|