FileDocCategorySizeDatePackage
NNTP.javaAPI DocApache Commons NET 1.4.1 API43005Sat Dec 03 10:05:48 GMT 2005org.apache.commons.net.nntp

NNTP

public class NNTP extends org.apache.commons.net.SocketClient
The NNTP class is not meant to be used by itself and is provided only so that you may easily implement your own NNTP client if you so desire. If you have no need to perform your own implementation, you should use {@link org.apache.commons.net.nntp.NNTPClient}. The NNTP class is made public to provide access to various NNTP constants and to make it easier for adventurous programmers (or those with special needs) to interact with the NNTP protocol and implement their own clients. A set of methods with names corresponding to the NNTP command names are provided to facilitate this interaction.

You should keep in mind that the NNTP server may choose to prematurely close a connection if the client has been idle for longer than a given time period or if the server is being shutdown by the operator or some other reason. The NNTP class will detect a premature NNTP server connection closing when it receives a {@link org.apache.commons.net.nntp.NNTPReply#SERVICE_DISCONTINUED NNTPReply.SERVICE_DISCONTINUED } response to a command. When that occurs, the NNTP class method encountering that reply will throw an {@link org.apache.commons.net.nntp.NNTPConnectionClosedException} . NNTPConectionClosedException is a subclass of IOException and therefore need not be caught separately, but if you are going to catch it separately, its catch block must appear before the more general IOException catch block. When you encounter an {@link org.apache.commons.net.nntp.NNTPConnectionClosedException} , you must disconnect the connection with {@link #disconnect disconnect() } to properly clean up the system resources used by NNTP. Before disconnecting, you may check the last reply code and text with {@link #getReplyCode getReplyCode } and {@link #getReplyString getReplyString }.

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 {@link org.apache.commons.net.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.

author
Daniel F. Savarese
author
Rory Winston
author
Ted Wise
see
NNTPClient
see
NNTPConnectionClosedException
see
org.apache.commons.net.MalformedServerReplyException

Fields Summary
public static final int
DEFAULT_PORT
The default NNTP port. Its value is 119 according to RFC 977.
private static final String
__DEFAULT_ENCODING
private StringBuffer
__commandBuffer
boolean
_isAllowedToPost
int
_replyCode
String
_replyString
protected BufferedReader
_reader_
Wraps {@link SocketClient#_input_} to communicate with server. Initialized by {@link #_connectAction_}. All server reads should be done through this variable.
protected BufferedWriter
_writer_
Wraps {@link SocketClient#_output_} to communicate with server. Initialized by {@link #_connectAction_}. All server reads should be done through this variable.
protected org.apache.commons.net.ProtocolCommandSupport
_commandSupport_
A ProtocolCommandSupport object used to manage the registering of ProtocolCommandListeners and te firing of ProtocolCommandEvents.
Constructors Summary
public NNTP()
The default NNTP constructor. Sets the default port to DEFAULT_PORT and initializes internal data structures for saving NNTP reply information.


                              
     
    
        setDefaultPort(DEFAULT_PORT);
        __commandBuffer = new StringBuffer();
        _replyString = null;
        _reader_ = null;
        _writer_ = null;
        _isAllowedToPost = false;
        _commandSupport_ = new ProtocolCommandSupport(this);
    
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 voidaddProtocolCommandListener(org.apache.commons.net.ProtocolCommandListener listener)
Adds a ProtocolCommandListener. Delegates this task to {@link #_commandSupport_ _commandSupport_ }.

param
listener The ProtocolCommandListener to add.

        _commandSupport_.addProtocolCommandListener(listener);
    
public intarticle(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.

param
messageId The message identifier of the requested article, including the encapsulating < and > characters.
return
The reply code received from the server.
exception
NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason causing the server to send NNTP reply code 400. This exception may be caught either as an IOException or independently as itself.
exception
IOException If an I/O error occurs while either sending the command or receiving the server reply.

        return sendCommand(NNTPCommand.ARTICLE, messageId);
    
public intarticle(int articleNumber)
A convenience method to send the NNTP ARTICLE command to the server, receive the initial reply, and return the reply code.

param
articleNumber The number of the article to request from the currently selected newsgroup.
return
The reply code received from the server.
exception
NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason causing the server to send NNTP reply code 400. This exception may be caught either as an IOException or independently as itself.
exception
IOException If an I/O error occurs while either sending the command or receiving the server reply.

        return sendCommand(NNTPCommand.ARTICLE, Integer.toString(articleNumber));
    
public intarticle()
A convenience method to send the NNTP ARTICLE command to the server, receive the initial reply, and return the reply code.

return
The reply code received from the server.
exception
NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason causing the server to send NNTP reply code 400. This exception may be caught either as an IOException or independently as itself.
exception
IOException If an I/O error occurs while either sending the command or receiving the server reply.

        return sendCommand(NNTPCommand.ARTICLE);
    
public intauthinfoPass(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)

param
password a valid password.
return
The reply code received from the server. The server should return a 281 or 502 for this command.
exception
NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason causing the server to send NNTP reply code 400. This exception may be caught either as an IOException or independently as itself.
exception
IOException If an I/O error occurs while either sending the command or receiving the server reply.

        String passParameter = "PASS " + password;
        return sendCommand(NNTPCommand.AUTHINFO, passParameter);
    
public intauthinfoUser(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)

param
username A valid username.
return
The reply code received from the server. The server should return a 381 or 281 for this command.
exception
NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason causing the server to send NNTP reply code 400. This exception may be caught either as an IOException or independently as itself.
exception
IOException If an I/O error occurs while either sending the command or receiving the server reply.

        String userParameter = "USER " + username;
        return sendCommand(NNTPCommand.AUTHINFO, userParameter);
    
public intbody(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.

param
messageId The message identifier of the requested article, including the encapsulating < and > characters.
return
The reply code received from the server.
exception
NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason causing the server to send NNTP reply code 400. This exception may be caught either as an IOException or independently as itself.
exception
IOException If an I/O error occurs while either sending the command or receiving the server reply.

        return sendCommand(NNTPCommand.BODY, messageId);
    
public intbody(int articleNumber)
A convenience method to send the NNTP BODY command to the server, receive the initial reply, and return the reply code.

param
articleNumber The number of the article to request from the currently selected newsgroup.
return
The reply code received from the server.
exception
NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason causing the server to send NNTP reply code 400. This exception may be caught either as an IOException or independently as itself.
exception
IOException If an I/O error occurs while either sending the command or receiving the server reply.

        return sendCommand(NNTPCommand.BODY, Integer.toString(articleNumber));
    
public intbody()
A convenience method to send the NNTP BODY command to the server, receive the initial reply, and return the reply code.

return
The reply code received from the server.
exception
NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason causing the server to send NNTP reply code 400. This exception may be caught either as an IOException or independently as itself.
exception
IOException If an I/O error occurs while either sending the command or receiving the server reply.

        return sendCommand(NNTPCommand.BODY);
    
public voiddisconnect()
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.

exception
IOException If an error occurs while disconnecting.

        super.disconnect();
        _reader_ = null;
        _writer_ = null;
        _replyString = null;
        _isAllowedToPost = false;
    
public intgetReply()
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.

return
The integer value of the reply code of the fetched NNTP reply. in response to the command.
exception
NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason causing the server to send NNTP reply code 400. This exception may be caught either as an IOException or independently as itself.
exception
IOException If an I/O error occurs while receiving the server reply.

        __getReply();
        return _replyCode;
    
public intgetReplyCode()
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
The integer value of the reply code of the last NNTP reply.

        return _replyCode;
    
public java.lang.StringgetReplyString()
Returns the entire text of the last NNTP server response exactly as it was received, not including the end of line marker.

return
The entire text from the last NNTP response as a String.

        return _replyString;
    
public intgroup(java.lang.String newsgroup)
A convenience method to send the NNTP GROUP command to the server, receive the reply, and return the reply code.

param
newsgroup The name of the newsgroup to select.
return
The reply code received from the server.
exception
NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason causing the server to send NNTP reply code 400. This exception may be caught either as an IOException or independently as itself.
exception
IOException If an I/O error occurs while either sending the command or receiving the server reply.

        return sendCommand(NNTPCommand.GROUP, newsgroup);
    
public inthead(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.

param
messageId The message identifier of the requested article, including the encapsulating < and > characters.
return
The reply code received from the server.
exception
NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason causing the server to send NNTP reply code 400. This exception may be caught either as an IOException or independently as itself.
exception
IOException If an I/O error occurs while either sending the command or receiving the server reply.

        return sendCommand(NNTPCommand.HEAD, messageId);
    
public inthead(int articleNumber)
A convenience method to send the NNTP HEAD command to the server, receive the initial reply, and return the reply code.

param
articleNumber The number of the article to request from the currently selected newsgroup.
return
The reply code received from the server.
exception
NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason causing the server to send NNTP reply code 400. This exception may be caught either as an IOException or independently as itself.
exception
IOException If an I/O error occurs while either sending the command or receiving the server reply.

        return sendCommand(NNTPCommand.HEAD, Integer.toString(articleNumber));
    
public inthead()
A convenience method to send the NNTP HEAD command to the server, receive the initial reply, and return the reply code.

return
The reply code received from the server.
exception
NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason causing the server to send NNTP reply code 400. This exception may be caught either as an IOException or independently as itself.
exception
IOException If an I/O error occurs while either sending the command or receiving the server reply.

        return sendCommand(NNTPCommand.HEAD);
    
public inthelp()
A convenience method to send the NNTP HELP command to the server, receive the reply, and return the reply code.

return
The reply code received from the server.
exception
NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason causing the server to send NNTP reply code 400. This exception may be caught either as an IOException or independently as itself.
exception
IOException If an I/O error occurs while either sending the command or receiving the server reply.

        return sendCommand(NNTPCommand.HELP);
    
public intihave(java.lang.String messageId)
A convenience method to send the NNTP IHAVE command to the server, receive the reply, and return the reply code.

param
messageId The article identifier, including the encapsulating < and > characters.
return
The reply code received from the server.
exception
NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason causing the server to send NNTP reply code 400. This exception may be caught either as an IOException or independently as itself.
exception
IOException If an I/O error occurs while either sending the command or receiving the server reply.

        return sendCommand(NNTPCommand.IHAVE, messageId);
    
public booleanisAllowedToPost()
Indicates whether or not the client is allowed to post articles to the server it is currently connected to.

return
True if the client can post articles to the server, false otherwise.

        return _isAllowedToPost;
    
public intlast()
A convenience method to send the NNTP LAST command to the server, receive the reply, and return the reply code.

return
The reply code received from the server.
exception
NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason causing the server to send NNTP reply code 400. This exception may be caught either as an IOException or independently as itself.
exception
IOException If an I/O error occurs while either sending the command or receiving the server reply.

        return sendCommand(NNTPCommand.LAST);
    
public intlist()
A convenience method to send the NNTP LIST command to the server, receive the reply, and return the reply code.

return
The reply code received from the server.
exception
NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason causing the server to send NNTP reply code 400. This exception may be caught either as an IOException or independently as itself.
exception
IOException If an I/O error occurs while either sending the command or receiving the server reply.

        return sendCommand(NNTPCommand.LIST);
    
public intlistActive(java.lang.String wildmat)
A convenience wrapper for the extended LIST command that takes an argument, allowing us to selectively list multiple groups.

param
wildmat A wildmat (pseudo-regex) pattern. See RFC 2980 for details.
return
the reply code received from the server.
throws
IOException

        StringBuffer command = new StringBuffer("ACTIVE ");
        command.append(wildmat);
        return sendCommand(NNTPCommand.LIST, command.toString());
    
public intnewgroups(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.

param
date The date after which to check for new groups. Date format is YYMMDD
param
time The time after which to check for new groups. Time format is HHMMSS using a 24-hour clock.
param
GMT True if the time is in GMT, false if local server time.
param
distributions Comma-separated distribution list to check for new groups. Set to null if no distributions.
return
The reply code received from the server.
exception
NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason causing the server to send NNTP reply code 400. This exception may be caught either as an IOException or independently as itself.
exception
IOException If an I/O error occurs while either sending the command or receiving the server reply.

        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 intnewnews(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.

param
newsgroups A comma-separated list of newsgroups to check for new news.
param
date The date after which to check for new news. Date format is YYMMDD
param
time The time after which to check for new news. Time format is HHMMSS using a 24-hour clock.
param
GMT True if the time is in GMT, false if local server time.
param
distributions Comma-separated distribution list to check for new news. Set to null if no distributions.
return
The reply code received from the server.
exception
NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason causing the server to send NNTP reply code 400. This exception may be caught either as an IOException or independently as itself.
exception
IOException If an I/O error occurs while either sending the command or receiving the server reply.

        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 intnext()
A convenience method to send the NNTP NEXT command to the server, receive the reply, and return the reply code.

return
The reply code received from the server.
exception
NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason causing the server to send NNTP reply code 400. This exception may be caught either as an IOException or independently as itself.
exception
IOException If an I/O error occurs while either sending the command or receiving the server reply.

        return sendCommand(NNTPCommand.NEXT);
    
public intpost()
A convenience method to send the NNTP POST command to the server, receive the reply, and return the reply code.

return
The reply code received from the server.
exception
NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason causing the server to send NNTP reply code 400. This exception may be caught either as an IOException or independently as itself.
exception
IOException If an I/O error occurs while either sending the command or receiving the server reply.

        return sendCommand(NNTPCommand.POST);
    
public intquit()
A convenience method to send the NNTP QUIT command to the server, receive the reply, and return the reply code.

return
The reply code received from the server.
exception
NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason causing the server to send NNTP reply code 400. This exception may be caught either as an IOException or independently as itself.
exception
IOException If an I/O error occurs while either sending the command or receiving the server reply.

        return sendCommand(NNTPCommand.QUIT);
    
public voidremoveProtocolCommandListener(org.apache.commons.net.ProtocolCommandListener listener)
Removes a ProtocolCommandListener. Delegates this task to {@link #_commandSupport_ _commandSupport_ }.

param
listener The ProtocolCommandListener to remove.

        _commandSupport_.removeProtocolCommandListener(listener);
    
public intsendCommand(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 }.

param
command The text representation of the NNTP command to send.
return
The integer value of the NNTP reply code returned by the server in response to the command. in response to the command.
exception
NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason causing the server to send NNTP reply code 400. This exception may be caught either as an IOException or independently as itself.
exception
IOException If an I/O error occurs while either sending the command or receiving the server reply.

        return sendCommand(command, null);
    
public intsendCommand(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 }.

param
command The NNTPCommand constant corresponding to the NNTP command to send.
return
The integer value of the NNTP reply code returned by the server in response to the command. in response to the command.
exception
NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason causing the server to send NNTP reply code 400. This exception may be caught either as an IOException or independently as itself.
exception
IOException If an I/O error occurs while either sending the command or receiving the server reply.

        return sendCommand(command, null);
    
public intsendCommand(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 }.

param
command The text representation of the NNTP command to send.
param
args The arguments to the NNTP command. If this parameter is set to null, then the command is sent with no argument.
return
The integer value of the NNTP reply code returned by the server in response to the command.
exception
NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason causing the server to send NNTP reply code 400. This exception may be caught either as an IOException or independently as itself.
exception
IOException If an I/O error occurs while either sending the command or receiving the server reply.

        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 intsendCommand(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 }.

param
command The NNTPCommand constant corresponding to the NNTP command to send.
param
args The arguments to the NNTP command. If this parameter is set to null, then the command is sent with no argument.
return
The integer value of the NNTP reply code returned by the server in response to the command. in response to the command.
exception
NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason causing the server to send NNTP reply code 400. This exception may be caught either as an IOException or independently as itself.
exception
IOException If an I/O error occurs while either sending the command or receiving the server reply.

        return sendCommand(NNTPCommand._commands[command], args);
    
public intstat(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.

param
messageId The message identifier of the requested article, including the encapsulating < and > characters.
return
The reply code received from the server.
exception
NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason causing the server to send NNTP reply code 400. This exception may be caught either as an IOException or independently as itself.
exception
IOException If an I/O error occurs while either sending the command or receiving the server reply.

        return sendCommand(NNTPCommand.STAT, messageId);
    
public intstat(int articleNumber)
A convenience method to send the NNTP STAT command to the server, receive the initial reply, and return the reply code.

param
articleNumber The number of the article to request from the currently selected newsgroup.
return
The reply code received from the server.
exception
NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason causing the server to send NNTP reply code 400. This exception may be caught either as an IOException or independently as itself.
exception
IOException If an I/O error occurs while either sending the command or receiving the server reply.

        return sendCommand(NNTPCommand.STAT, Integer.toString(articleNumber));
    
public intstat()
A convenience method to send the NNTP STAT command to the server, receive the initial reply, and return the reply code.

return
The reply code received from the server.
exception
NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason causing the server to send NNTP reply code 400. This exception may be caught either as an IOException or independently as itself.
exception
IOException If an I/O error occurs while either sending the command or receiving the server reply.

        return sendCommand(NNTPCommand.STAT);
    
public intxhdr(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.

param
header a String naming a header line (e.g., "subject"). See RFC-1036 for a list of valid header lines.
param
selectedArticles a String representation of the range of article headers required. This may be an article number, or a range of article numbers in the form "XXXX-YYYY", where XXXX and YYYY are valid article numbers in the current group. It also may be of the form "XXX-", meaning "return XXX and all following articles" In this revision, the last format is not possible (yet).
return
The reply code received from the server.
exception
NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason causing the server to send NNTP reply code 400. This exception may be caught either as an IOException or independently as itself.
exception
IOException If an I/O error occurs while either sending the command or receiving the server reply.

        StringBuffer command = new StringBuffer(header);
        command.append(" ");
        command.append(selectedArticles);
        return sendCommand(NNTPCommand.XHDR, command.toString());
    
public intxover(java.lang.String selectedArticles)
A convenience method to send the NNTP XOVER command to the server, receive the reply, and return the reply code.

param
selectedArticles a String representation of the range of article headers required. This may be an article number, or a range of article numbers in the form "XXXX-YYYY", where XXXX and YYYY are valid article numbers in the current group. It also may be of the form "XXX-", meaning "return XXX and all following articles" In this revision, the last format is not possible (yet).
return
The reply code received from the server.
exception
NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason causing the server to send NNTP reply code 400. This exception may be caught either as an IOException or independently as itself.
exception
IOException If an I/O error occurs while either sending the command or receiving the server reply.

        return sendCommand(NNTPCommand.XOVER, selectedArticles);