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 18 package org.apache.commons.net.nntp; 19 20 /** 21 * NNTPCommand stores a set of constants for NNTP command codes. To interpret the meaning of the codes, familiarity with RFC 977 is assumed. 22 */ 23 public final class NNTPCommand { 24 25 /** NNTP command code {@value}. */ 26 public static final int ARTICLE = 0; 27 28 /** NNTP command code {@value}. */ 29 public static final int BODY = 1; 30 31 /** NNTP command code {@value}. */ 32 public static final int GROUP = 2; 33 34 /** NNTP command code {@value}. */ 35 public static final int HEAD = 3; 36 37 /** NNTP command code {@value}. */ 38 public static final int HELP = 4; 39 40 /** NNTP command code {@value}. */ 41 public static final int IHAVE = 5; 42 43 /** NNTP command code {@value}. */ 44 public static final int LAST = 6; 45 46 /** NNTP command code {@value}. */ 47 public static final int LIST = 7; 48 49 /** NNTP command code {@value}. */ 50 public static final int NEWGROUPS = 8; 51 52 /** NNTP command code {@value}. */ 53 public static final int NEWNEWS = 9; 54 55 /** NNTP command code {@value}. */ 56 public static final int NEXT = 10; 57 58 /** NNTP command code {@value}. */ 59 public static final int POST = 11; 60 61 /** NNTP command code {@value}. */ 62 public static final int QUIT = 12; 63 64 /** NNTP command code {@value}. */ 65 public static final int SLAVE = 13; 66 67 /** NNTP command code {@value}. */ 68 public static final int STAT = 14; 69 70 /** NNTP command code {@value}. */ 71 public static final int AUTHINFO = 15; 72 73 /** NNTP command code {@value}. */ 74 public static final int XOVER = 16; 75 76 /** NNTP command code {@value}. */ 77 public static final int XHDR = 17; 78 79 private static final String[] commands = { "ARTICLE", "BODY", "GROUP", "HEAD", "HELP", "IHAVE", "LAST", "LIST", "NEWGROUPS", "NEWNEWS", "NEXT", "POST", 80 "QUIT", "SLAVE", "STAT", "AUTHINFO", "XOVER", "XHDR" }; 81 82 /** 83 * Gets the NNTP protocol command string corresponding to a specified command code. 84 * 85 * @param command The command code. 86 * @return The NNTP protcol command string corresponding to a specified command code. 87 */ 88 public static String getCommand(final int command) { 89 return commands[command]; 90 } 91 92 /** Cannot be instantiated. */ 93 private NNTPCommand() { 94 } 95 96 }