    View Javadoc
    1   package org.apache.commons.net.nntp;
    2
    3   /* ====================================================================
    4    * The Apache Software License, Version 1.1
    5    *
    6    * Copyright (c) 2001 The Apache Software Foundation.  All rights
    7    * reserved.
    8    *
    9    * Redistribution and use in source and binary forms, with or without
    10   * modification, are permitted provided that the following conditions
    11   * are met:
    12   *
    13   * 1. Redistributions of source code must retain the above copyright
    14   *    notice, this list of conditions and the following disclaimer.
    15   *
    16   * 2. Redistributions in binary form must reproduce the above copyright
    17   *    notice, this list of conditions and the following disclaimer in
    18   *    the documentation and/or other materials provided with the
    19   *    distribution.
    20   *
    21   * 3. The end-user documentation included with the redistribution,
    22   *    if any, must include the following acknowledgment:
    23   *       "This product includes software developed by the
    24   *        Apache Software Foundation (http://www.apache.org/)."
    25   *    Alternately, this acknowledgment may appear in the software itself,
    26   *    if and wherever such third-party acknowledgments normally appear.
    27   *
    28   * 4. The names "Apache" and "Apache Software Foundation" and
    29   *    "Apache Commons" must not be used to endorse or promote products
    30   *    derived from this software without prior written permission. For
    31   *    written permission, please contact apache@apache.org.
    32   *
    33   * 5. Products derived from this software may not be called "Apache",
    34   *    nor may "Apache" appear in their name, without
    35   *    prior written permission of the Apache Software Foundation.
    36   *
    37   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
    38   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    39   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    40   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
    41   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    42   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    43   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
    44   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    45   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    46   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
    47   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    48   * SUCH DAMAGE.
    49   * ====================================================================
    50   *
    51   * This software consists of voluntary contributions made by many
    52   * individuals on behalf of the Apache Software Foundation.  For more
    53   * information on the Apache Software Foundation, please see
    54   * <http://www.apache.org/>;.
    55   */
    56
    57  /****
    58   * NNTPReply stores a set of constants for NNTP reply codes.  To interpret
    59   * the meaning of the codes, familiarity with RFC 977 is assumed.
    60   * The mnemonic constant names are transcriptions from the code descriptions
    61   * of RFC 977.  For those who think in terms of the actual reply code values,
    62   * a set of CODE_NUM constants are provided where NUM is the numerical value
    63   * of the code.
    64   * <p>
    65   * <p>
    66   * @author Daniel F. Savarese
    67   ***/
    68
    69  public final class NNTPReply
    70  {
    71
    72      public static final int CODE_100 = 100;
    73      public static final int CODE_199 = 199;
    74      public static final int CODE_200 = 200;
    75      public static final int CODE_201 = 201;
    76      public static final int CODE_202 = 202;
    77      public static final int CODE_205 = 205;
    78      public static final int CODE_211 = 211;
    79      public static final int CODE_215 = 215;
    80      public static final int CODE_220 = 220;
    81      public static final int CODE_221 = 221;
    82      public static final int CODE_222 = 222;
    83      public static final int CODE_223 = 223;
    84      public static final int CODE_230 = 230;
    85      public static final int CODE_231 = 231;
    86      public static final int CODE_235 = 235;
    87      public static final int CODE_240 = 240;
    88      public static final int CODE_335 = 335;
    89      public static final int CODE_340 = 340;
    90      public static final int CODE_400 = 400;
    91      public static final int CODE_411 = 411;
    92      public static final int CODE_412 = 412;
    93      public static final int CODE_420 = 420;
    94      public static final int CODE_421 = 421;
    95      public static final int CODE_422 = 422;
    96      public static final int CODE_423 = 423;
    97      public static final int CODE_430 = 430;
    98      public static final int CODE_435 = 435;
    99      public static final int CODE_436 = 436;
    100     public static final int CODE_437 = 437;
    101     public static final int CODE_440 = 440;
    102     public static final int CODE_441 = 441;
    103     public static final int CODE_500 = 500;
    104     public static final int CODE_501 = 501;
    105     public static final int CODE_502 = 502;
    106     public static final int CODE_503 = 503;
    107
    108     public static final int HELP_TEXT_FOLLOWS = CODE_100;
    109     public static final int DEBUG_OUTPUT = CODE_199;
    110     public static final int SERVER_READY_POSTING_ALLOWED = CODE_200;
    111     public static final int SERVER_READY_POSTING_NOT_ALLOWED = CODE_201;
    112     public static final int SLAVE_STATUS_NOTED = CODE_202;
    113     public static final int CLOSING_CONNECTION = CODE_205;
    114     public static final int GROUP_SELECTED = CODE_211;
    115     public static final int ARTICLE_RETRIEVED_HEAD_AND_BODY_FOLLOW = CODE_220;
    116     public static final int ARTICLE_RETRIEVED_HEAD_FOLLOWS = CODE_221;
    117     public static final int ARTICLE_RETRIEVED_BODY_FOLLOWS = CODE_222;
    118     public static final int ARTICLE_RETRIEVED_REQUEST_TEXT_SEPARATELY = CODE_223;
    119     public static final int ARTICLE_LIST_BY_MESSAGE_ID_FOLLOWS = CODE_230;
    120     public static final int NEW_NEWSGROUP_LIST_FOLLOWS = CODE_231;
    121     public static final int ARTICLE_TRANSFERRED_OK = CODE_235;
    122     public static final int ARTICLE_POSTED_OK = CODE_240;
    123     public static final int SEND_ARTICLE_TO_TRANSFER = CODE_335;
    124     public static final int SEND_ARTICLE_TO_POST = CODE_340;
    125     public static final int SERVICE_DISCONTINUED = CODE_400;
    126     public static final int NO_SUCH_NEWSGROUP = CODE_411;
    127     public static final int NO_NEWSGROUP_SELECTED = CODE_412;
    128     public static final int NO_CURRENT_ARTICLE_SELECTED = CODE_420;
    129     public static final int NO_NEXT_ARTICLE = CODE_421;
    130     public static final int NO_PREVIOUS_ARTICLE = CODE_422;
    131     public static final int NO_SUCH_ARTICLE_NUMBER = CODE_423;
    132     public static final int NO_SUCH_ARTICLE_FOUND = CODE_430;
    133     public static final int ARTICLE_NOT_WANTED = CODE_435;
    134     public static final int TRANSFER_FAILED = CODE_436;
    135     public static final int ARTICLE_REJECTED = CODE_437;
    136     public static final int POSTING_NOT_ALLOWED = CODE_440;
    137     public static final int POSTING_FAILED = CODE_441;
    138     public static final int COMMAND_NOT_RECOGNIZED = CODE_500;
    139     public static final int COMMAND_SYNTAX_ERROR = CODE_501;
    140     public static final int PERMISSION_DENIED = CODE_502;
    141     public static final int PROGRAM_FAULT = CODE_503;
    142
    143     // Cannot be instantiated
    144
    145     private NNTPReply()
    146     {}
    147
    148     /****
    149      * Determine if a reply code is an informational response.  All
    150      * codes beginning with a 1 are positive informational responses.
    151      * Informational responses are used to provide human readable
    152      * information such as help text.
    153      * <p>
    154      * @param reply  The reply code to test.
    155      * @return True if a reply code is an informational response, false
    156      *         if not.
    157      ***/
    158     public static boolean isInformational(int reply)
    159     {
    160         return (reply >= 100 && reply < 200);
    161     }
    162
    163     /****
    164      * Determine if a reply code is a positive completion response.  All
    165      * codes beginning with a 2 are positive completion responses.
    166      * The NNTP server will send a positive completion response on the final
    167      * successful completion of a command.
    168      * <p>
    169      * @param reply  The reply code to test.
    170      * @return True if a reply code is a postive completion response, false
    171      *         if not.
    172      ***/
    173     public static boolean isPositiveCompletion(int reply)
    174     {
    175         return (reply >= 200 && reply < 300);
    176     }
    177
    178     /****
    179      * Determine if a reply code is a positive intermediate response.  All
    180      * codes beginning with a 3 are positive intermediate responses.
    181      * The NNTP server will send a positive intermediate response on the
    182      * successful completion of one part of a multi-part command or
    183      * sequence of commands.  For example, after a successful POST command,
    184      * a positive intermediate response will be sent to indicate that the
    185      * server is ready to receive the article to be posted.
    186      * <p>
    187      * @param reply  The reply code to test.
    188      * @return True if a reply code is a postive intermediate response, false
    189      *         if not.
    190      ***/
    191     public static boolean isPositiveIntermediate(int reply)
    192     {
    193         return (reply >= 300 && reply < 400);
    194     }
    195
    196     /****
    197      * Determine if a reply code is a negative transient response.  All
    198      * codes beginning with a 4 are negative transient responses.
    199      * The NNTP server will send a negative transient response on the
    200      * failure of a correctly formatted command that could not be performed
    201      * for some reason.  For example, retrieving an article that does not
    202      * exist will result in a negative transient response.
    203      * <p>
    204      * @param reply  The reply code to test.
    205      * @return True if a reply code is a negative transient response, false
    206      *         if not.
    207      ***/
    208     public static boolean isNegativeTransient(int reply)
    209     {
    210         return (reply >= 400 && reply < 500);
    211     }
    212
    213     /****
    214      * Determine if a reply code is a negative permanent response.  All
    215      * codes beginning with a 5 are negative permanent responses.
    216      * The NNTP server will send a negative permanent response when
    217      * it does not implement a command, a command is incorrectly formatted,
    218      * or a serious program error occurs.
    219      * <p>
    220      * @param reply  The reply code to test.
    221      * @return True if a reply code is a negative permanent response, false
    222      *         if not.
    223      ***/
    224     public static boolean isNegativePermanent(int reply)
    225     {
    226         return (reply >= 500 && reply < 600);
    227     }
    228
    229 }

This page was automatically generated by Maven