Methods Summary |
---|
private void | __getReply()
_replyString = _reader_.readLine();
if (_replyString == null)
throw new NNTPConnectionClosedException(
"Connection closed without indication.");
// In case we run into an anomaly we don't want fatal index exceptions
// to be thrown.
if (_replyString.length() < 3)
throw new MalformedServerReplyException(
"Truncated server reply: " + _replyString);
try
{
_replyCode = Integer.parseInt(_replyString.substring(0, 3));
}
catch (NumberFormatException e)
{
throw new MalformedServerReplyException(
"Could not parse response code.\nServer Reply: " + _replyString);
}
if (_commandSupport_.getListenerCount() > 0)
_commandSupport_.fireReplyReceived(_replyCode, _replyString +
SocketClient.NETASCII_EOL);
if (_replyCode == NNTPReply.SERVICE_DISCONTINUED)
throw new NNTPConnectionClosedException(
"NNTP response 400 received. Server closed connection.");
|
protected void | _connectAction_()Initiates control connections and gets initial reply, determining
if the client is allowed to post to the server. Initializes
{@link #_reader_} and {@link #_writer_} to wrap
{@link SocketClient#_input_} and {@link SocketClient#_output_}.
super._connectAction_();
_reader_ =
new BufferedReader(new InputStreamReader(_input_,
__DEFAULT_ENCODING));
_writer_ =
new BufferedWriter(new OutputStreamWriter(_output_,
__DEFAULT_ENCODING));
__getReply();
_isAllowedToPost = (_replyCode == NNTPReply.SERVER_READY_POSTING_ALLOWED);
|
public void | addProtocolCommandListener(org.apache.commons.net.ProtocolCommandListener listener)Adds a ProtocolCommandListener. Delegates this task to
{@link #_commandSupport_ _commandSupport_ }.
_commandSupport_.addProtocolCommandListener(listener);
|
public int | article(java.lang.String messageId)A convenience method to send the NNTP ARTICLE command to the server,
receive the initial reply, and return the reply code.
return sendCommand(NNTPCommand.ARTICLE, messageId);
|
public int | article(int articleNumber)A convenience method to send the NNTP ARTICLE command to the server,
receive the initial reply, and return the reply code.
return sendCommand(NNTPCommand.ARTICLE, Integer.toString(articleNumber));
|
public int | article()A convenience method to send the NNTP ARTICLE command to the server,
receive the initial reply, and return the reply code.
return sendCommand(NNTPCommand.ARTICLE);
|
public int | authinfoPass(java.lang.String password)A convenience method to send the AUTHINFO PASS command to the server,
receive the reply, and return the reply code. If this step is
required, it should immediately follow the AUTHINFO USER command
(See RFC 2980)
String passParameter = "PASS " + password;
return sendCommand(NNTPCommand.AUTHINFO, passParameter);
|
public int | authinfoUser(java.lang.String username)A convenience method to send the AUTHINFO USER command to the server,
receive the reply, and return the reply code. (See RFC 2980)
String userParameter = "USER " + username;
return sendCommand(NNTPCommand.AUTHINFO, userParameter);
|
public int | body(java.lang.String messageId)A convenience method to send the NNTP BODY command to the server,
receive the initial reply, and return the reply code.
return sendCommand(NNTPCommand.BODY, messageId);
|
public int | body(int articleNumber)A convenience method to send the NNTP BODY command to the server,
receive the initial reply, and return the reply code.
return sendCommand(NNTPCommand.BODY, Integer.toString(articleNumber));
|
public int | body()A convenience method to send the NNTP BODY command to the server,
receive the initial reply, and return the reply code.
return sendCommand(NNTPCommand.BODY);
|
public void | disconnect()Closes the connection to the NNTP server and sets to null
some internal data so that the memory may be reclaimed by the
garbage collector. The reply text and code information from the
last command is voided so that the memory it used may be reclaimed.
super.disconnect();
_reader_ = null;
_writer_ = null;
_replyString = null;
_isAllowedToPost = false;
|
public int | getReply()Fetches a reply from the NNTP server and returns the integer reply
code. After calling this method, the actual reply text can be accessed
from {@link #getReplyString getReplyString }. Only use this
method if you are implementing your own NNTP client or if you need to
fetch a secondary response from the NNTP server.
__getReply();
return _replyCode;
|
public int | getReplyCode()Returns the integer value of the reply code of the last NNTP reply.
You will usually only use this method after you connect to the
NNTP server to check that the connection was successful since
connect is of type void.
return _replyCode;
|
public java.lang.String | getReplyString()Returns the entire text of the last NNTP server response exactly
as it was received, not including the end of line marker.
return _replyString;
|
public int | group(java.lang.String newsgroup)A convenience method to send the NNTP GROUP command to the server,
receive the reply, and return the reply code.
return sendCommand(NNTPCommand.GROUP, newsgroup);
|
public int | head(java.lang.String messageId)A convenience method to send the NNTP HEAD command to the server,
receive the initial reply, and return the reply code.
return sendCommand(NNTPCommand.HEAD, messageId);
|
public int | head(int articleNumber)A convenience method to send the NNTP HEAD command to the server,
receive the initial reply, and return the reply code.
return sendCommand(NNTPCommand.HEAD, Integer.toString(articleNumber));
|
public int | head()A convenience method to send the NNTP HEAD command to the server,
receive the initial reply, and return the reply code.
return sendCommand(NNTPCommand.HEAD);
|
public int | help()A convenience method to send the NNTP HELP command to the server,
receive the reply, and return the reply code.
return sendCommand(NNTPCommand.HELP);
|
public int | ihave(java.lang.String messageId)A convenience method to send the NNTP IHAVE command to the server,
receive the reply, and return the reply code.
return sendCommand(NNTPCommand.IHAVE, messageId);
|
public boolean | isAllowedToPost()Indicates whether or not the client is allowed to post articles to
the server it is currently connected to.
return _isAllowedToPost;
|
public int | last()A convenience method to send the NNTP LAST command to the server,
receive the reply, and return the reply code.
return sendCommand(NNTPCommand.LAST);
|
public int | list()A convenience method to send the NNTP LIST command to the server,
receive the reply, and return the reply code.
return sendCommand(NNTPCommand.LIST);
|
public int | listActive(java.lang.String wildmat)A convenience wrapper for the extended LIST command that takes
an argument, allowing us to selectively list multiple groups.
StringBuffer command = new StringBuffer("ACTIVE ");
command.append(wildmat);
return sendCommand(NNTPCommand.LIST, command.toString());
|
public int | newgroups(java.lang.String date, java.lang.String time, boolean GMT, java.lang.String distributions)A convenience method to send the NNTP NEWGROUPS command to the server,
receive the reply, and return the reply code.
StringBuffer buffer = new StringBuffer();
buffer.append(date);
buffer.append(' ");
buffer.append(time);
if (GMT)
{
buffer.append(' ");
buffer.append("GMT");
}
if (distributions != null)
{
buffer.append(" <");
buffer.append(distributions);
buffer.append('>");
}
return sendCommand(NNTPCommand.NEWGROUPS, buffer.toString());
|
public int | newnews(java.lang.String newsgroups, java.lang.String date, java.lang.String time, boolean GMT, java.lang.String distributions)A convenience method to send the NNTP NEWGROUPS command to the server,
receive the reply, and return the reply code.
StringBuffer buffer = new StringBuffer();
buffer.append(newsgroups);
buffer.append(' ");
buffer.append(date);
buffer.append(' ");
buffer.append(time);
if (GMT)
{
buffer.append(' ");
buffer.append("GMT");
}
if (distributions != null)
{
buffer.append(" <");
buffer.append(distributions);
buffer.append('>");
}
return sendCommand(NNTPCommand.NEWNEWS, buffer.toString());
|
public int | next()A convenience method to send the NNTP NEXT command to the server,
receive the reply, and return the reply code.
return sendCommand(NNTPCommand.NEXT);
|
public int | post()A convenience method to send the NNTP POST command to the server,
receive the reply, and return the reply code.
return sendCommand(NNTPCommand.POST);
|
public int | quit()A convenience method to send the NNTP QUIT command to the server,
receive the reply, and return the reply code.
return sendCommand(NNTPCommand.QUIT);
|
public void | removeProtocolCommandListener(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)Sends an NNTP command with no arguments to the server, waits for a
reply and returns the numerical response code. After invocation, for
more detailed information, the actual reply text can be accessed by
calling {@link #getReplyString getReplyString }.
return sendCommand(command, null);
|
public int | sendCommand(int command)Sends an NNTP command with no arguments to the server, waits for a
reply and returns the numerical response code. After invocation, for
more detailed information, the actual reply text can be accessed by
calling {@link #getReplyString getReplyString }.
return sendCommand(command, null);
|
public int | sendCommand(java.lang.String command, java.lang.String args)Sends an NNTP command to the server, waits for a reply and returns the
numerical response code. After invocation, for more detailed
information, the actual reply text can be accessed by calling
{@link #getReplyString getReplyString }.
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(int command, java.lang.String args)Sends an NNTP command to the server, waits for a reply and returns the
numerical response code. After invocation, for more detailed
information, the actual reply text can be accessed by calling
{@link #getReplyString getReplyString }.
return sendCommand(NNTPCommand._commands[command], args);
|
public int | stat(java.lang.String messageId)A convenience method to send the NNTP STAT command to the server,
receive the initial reply, and return the reply code.
return sendCommand(NNTPCommand.STAT, messageId);
|
public int | stat(int articleNumber)A convenience method to send the NNTP STAT command to the server,
receive the initial reply, and return the reply code.
return sendCommand(NNTPCommand.STAT, Integer.toString(articleNumber));
|
public int | stat()A convenience method to send the NNTP STAT command to the server,
receive the initial reply, and return the reply code.
return sendCommand(NNTPCommand.STAT);
|
public int | xhdr(java.lang.String header, java.lang.String selectedArticles)A convenience method to send the NNTP XHDR command to the server,
receive the reply, and return the reply code.
StringBuffer command = new StringBuffer(header);
command.append(" ");
command.append(selectedArticles);
return sendCommand(NNTPCommand.XHDR, command.toString());
|
public int | xover(java.lang.String selectedArticles)A convenience method to send the NNTP XOVER command to the server,
receive the reply, and return the reply code.
return sendCommand(NNTPCommand.XOVER, selectedArticles);
|