001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018package org.apache.commons.net.nntp;
019
020/**
021 * NNTPCommand stores a set of constants for NNTP command codes. To interpret the meaning of the codes, familiarity with RFC 977 is assumed.
022 */
023public final class NNTPCommand {
024
025    /** NNTP command code {@value}. */
026    public static final int ARTICLE = 0;
027
028    /** NNTP command code {@value}. */
029    public static final int BODY = 1;
030
031    /** NNTP command code {@value}. */
032    public static final int GROUP = 2;
033
034    /** NNTP command code {@value}. */
035    public static final int HEAD = 3;
036
037    /** NNTP command code {@value}. */
038    public static final int HELP = 4;
039
040    /** NNTP command code {@value}. */
041    public static final int IHAVE = 5;
042
043    /** NNTP command code {@value}. */
044    public static final int LAST = 6;
045
046    /** NNTP command code {@value}. */
047    public static final int LIST = 7;
048
049    /** NNTP command code {@value}. */
050    public static final int NEWGROUPS = 8;
051
052    /** NNTP command code {@value}. */
053    public static final int NEWNEWS = 9;
054
055    /** NNTP command code {@value}. */
056    public static final int NEXT = 10;
057
058    /** NNTP command code {@value}. */
059    public static final int POST = 11;
060
061    /** NNTP command code {@value}. */
062    public static final int QUIT = 12;
063
064    /** NNTP command code {@value}. */
065    public static final int SLAVE = 13;
066
067    /** NNTP command code {@value}. */
068    public static final int STAT = 14;
069
070    /** NNTP command code {@value}. */
071    public static final int AUTHINFO = 15;
072
073    /** NNTP command code {@value}. */
074    public static final int XOVER = 16;
075
076    /** NNTP command code {@value}. */
077    public static final int XHDR = 17;
078
079    private static final String[] commands = { "ARTICLE", "BODY", "GROUP", "HEAD", "HELP", "IHAVE", "LAST", "LIST", "NEWGROUPS", "NEWNEWS", "NEXT", "POST",
080            "QUIT", "SLAVE", "STAT", "AUTHINFO", "XOVER", "XHDR" };
081
082    /**
083     * Gets the NNTP protocol command string corresponding to a specified command code.
084     *
085     * @param command The command code.
086     * @return The NNTP protcol command string corresponding to a specified command code.
087     */
088    public static String getCommand(final int command) {
089        return commands[command];
090    }
091
092    /** Cannot be instantiated. */
093    private NNTPCommand() {
094    }
095
096}