Example usage for org.apache.commons.net.nntp NNTPCommand HEAD

List of usage examples for org.apache.commons.net.nntp NNTPCommand HEAD

Introduction

In this page you can find the example usage for org.apache.commons.net.nntp NNTPCommand HEAD.

Prototype

int HEAD

To view the source code for org.apache.commons.net.nntp NNTPCommand HEAD.

Click Source Link

Usage

From source file:net.longfalcon.newsj.nntp.client.CustomNNTPClient.java

/***
 * Retrieves an article header from the NNTP server.  The article is
 * referenced/*  ww  w.  j  ava2 s  .c  om*/
 * by its unique article identifier (including the enclosing &lt and &gt).
 * The article number and identifier contained in the server reply
 * are returned through an ArticleInfo.  The <code> articleId </code>
 * field of the ArticleInfo cannot always be trusted because some
 * NNTP servers do not correctly follow the RFC 977 reply format.
 * <p>
 * A DotTerminatedMessageReader is returned from which the article can
 * be read.  If the article does not exist, null is returned.
 * <p>
 * You must not issue any commands to the NNTP server (i.e., call any
 * other methods) until you finish reading the message from the returned
 * BufferedReader instance.
 * The NNTP protocol uses the same stream for issuing commands as it does
 * for returning results.  Therefore the returned BufferedReader actually reads
 * directly from the NNTP connection.  After the end of message has been
 * reached, new commands can be executed and their replies read.  If
 * you do not follow these requirements, your program will not work
 * properly.
 * <p>
 * @param articleId  The unique article identifier of the article whose
 *    header is being retrieved.  If this parameter is null, the
 *    header of the currently selected article is retrieved.
 * @param pointer    A parameter through which to return the article's
 *   number and unique id.  The articleId field cannot always be trusted
 *   because of server deviations from RFC 977 reply formats.  You may
 *   set this parameter to null if you do not desire to retrieve the
 *   returned article information.
 * @return A DotTerminatedMessageReader instance from which the article
 *         header can be read.  null if the article does not exist.
 * @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 a
 *      command to the server or receiving a reply from the server.
 ***/
@Override
public BufferedReader retrieveArticleHeader(String articleId, ArticleInfo pointer) throws IOException {
    return __retrieve(NNTPCommand.HEAD, articleId, pointer);

}

From source file:net.longfalcon.newsj.nntp.client.CustomNNTPClient.java

/***
 * Retrieves an article header from the currently selected newsgroup.  The
 * article is referenced by its article number.
 * The article number and identifier contained in the server reply
 * are returned through an ArticleInfo.  The <code> articleId </code>
 * field of the ArticleInfo cannot always be trusted because some
 * NNTP servers do not correctly follow the RFC 977 reply format.
 * <p>//from w w w .ja v  a 2s .  co  m
 * A DotTerminatedMessageReader is returned from which the article can
 * be read.  If the article does not exist, null is returned.
 * <p>
 * You must not issue any commands to the NNTP server (i.e., call any
 * other methods) until you finish reading the message from the returned
 * BufferedReader instance.
 * The NNTP protocol uses the same stream for issuing commands as it does
 * for returning results.  Therefore the returned BufferedReader actually reads
 * directly from the NNTP connection.  After the end of message has been
 * reached, new commands can be executed and their replies read.  If
 * you do not follow these requirements, your program will not work
 * properly.
 * <p>
 * @param articleNumber  The number of the the article whose header is
 *     being retrieved.
 * @param pointer    A parameter through which to return the article's
 *   number and unique id.  The articleId field cannot always be trusted
 *   because of server deviations from RFC 977 reply formats.  You may
 *   set this parameter to null if you do not desire to retrieve the
 *   returned article information.
 * @return A DotTerminatedMessageReader instance from which the article
 *         header can be read.  null if the article does not exist.
 * @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 a
 *      command to the server or receiving a reply from the server.
 ***/
@Override
public BufferedReader retrieveArticleHeader(long articleNumber, ArticleInfo pointer) throws IOException {
    return __retrieve(NNTPCommand.HEAD, articleNumber, pointer);
}