NNTPCommand.java

  1. /*
  2.  * Licensed to the Apache Software Foundation (ASF) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * The ASF licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *      http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */

  17. package org.apache.commons.net.nntp;

  18. /**
  19.  * NNTPCommand stores a set of constants for NNTP command codes. To interpret the meaning of the codes, familiarity with RFC 977 is assumed.
  20.  */
  21. public final class NNTPCommand {

  22.     /** NNTP command code {@value}. */
  23.     public static final int ARTICLE = 0;

  24.     /** NNTP command code {@value}. */
  25.     public static final int BODY = 1;

  26.     /** NNTP command code {@value}. */
  27.     public static final int GROUP = 2;

  28.     /** NNTP command code {@value}. */
  29.     public static final int HEAD = 3;

  30.     /** NNTP command code {@value}. */
  31.     public static final int HELP = 4;

  32.     /** NNTP command code {@value}. */
  33.     public static final int IHAVE = 5;

  34.     /** NNTP command code {@value}. */
  35.     public static final int LAST = 6;

  36.     /** NNTP command code {@value}. */
  37.     public static final int LIST = 7;

  38.     /** NNTP command code {@value}. */
  39.     public static final int NEWGROUPS = 8;

  40.     /** NNTP command code {@value}. */
  41.     public static final int NEWNEWS = 9;

  42.     /** NNTP command code {@value}. */
  43.     public static final int NEXT = 10;

  44.     /** NNTP command code {@value}. */
  45.     public static final int POST = 11;

  46.     /** NNTP command code {@value}. */
  47.     public static final int QUIT = 12;

  48.     /** NNTP command code {@value}. */
  49.     public static final int SLAVE = 13;

  50.     /** NNTP command code {@value}. */
  51.     public static final int STAT = 14;

  52.     /** NNTP command code {@value}. */
  53.     public static final int AUTHINFO = 15;

  54.     /** NNTP command code {@value}. */
  55.     public static final int XOVER = 16;

  56.     /** NNTP command code {@value}. */
  57.     public static final int XHDR = 17;

  58.     private static final String[] commands = { "ARTICLE", "BODY", "GROUP", "HEAD", "HELP", "IHAVE", "LAST", "LIST", "NEWGROUPS", "NEWNEWS", "NEXT", "POST",
  59.             "QUIT", "SLAVE", "STAT", "AUTHINFO", "XOVER", "XHDR" };

  60.     /**
  61.      * Gets the NNTP protocol command string corresponding to a specified command code.
  62.      *
  63.      * @param command The command code.
  64.      * @return The NNTP protcol command string corresponding to a specified command code.
  65.      */
  66.     public static String getCommand(final int command) {
  67.         return commands[command];
  68.     }

  69.     /** Cannot be instantiated. */
  70.     private NNTPCommand() {
  71.     }

  72. }