1 package org.apache.commons.net.telnet;
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 * The TelnetCommand class cannot be instantiated and only serves as a
59 * storehouse for telnet command constants.
60 * @author Daniel F. Savarese
61 * @see org.apache.commons.net.telnet.Telnet
62 * @see org.apache.commons.net.telnet.TelnetClient
63 */
64
65 public final class TelnetCommand
66 {
67 /**** The maximum value a command code can have. This value is 255. ***/
68 public static final int MAX_COMMAND_VALUE = 255;
69
70 /**** Interpret As Command code. Value is 255 according to RFC 854. ***/
71 public static final int IAC = 255;
72
73 /**** Don't use option code. Value is 254 according to RFC 854. ***/
74 public static final int DONT = 254;
75
76 /**** Request to use option code. Value is 253 according to RFC 854. ***/
77 public static final int DO = 253;
78
79 /**** Refuse to use option code. Value is 252 according to RFC 854. ***/
80 public static final int WONT = 252;
81
82 /**** Agree to use option code. Value is 251 according to RFC 854. ***/
83 public static final int WILL = 251;
84
85 /**** Start subnegotiation code. Value is 250 according to RFC 854. ***/
86 public static final int SB = 250;
87
88 /**** Go Ahead code. Value is 249 according to RFC 854. ***/
89 public static final int GA = 249;
90
91 /**** Erase Line code. Value is 248 according to RFC 854. ***/
92 public static final int EL = 248;
93
94 /**** Erase Character code. Value is 247 according to RFC 854. ***/
95 public static final int EC = 247;
96
97 /**** Are You There code. Value is 246 according to RFC 854. ***/
98 public static final int AYT = 246;
99
100 /**** Abort Output code. Value is 245 according to RFC 854. ***/
101 public static final int AO = 245;
102
103 /**** Interrupt Process code. Value is 244 according to RFC 854. ***/
104 public static final int IP = 244;
105
106 /**** Break code. Value is 243 according to RFC 854. ***/
107 public static final int BREAK = 243;
108
109 /**** Data mark code. Value is 242 according to RFC 854. ***/
110 public static final int DM = 242;
111
112 /**** No Operation code. Value is 241 according to RFC 854. ***/
113 public static final int NOP = 241;
114
115 /**** End subnegotiation code. Value is 240 according to RFC 854. ***/
116 public static final int SE = 240;
117
118 /**** End of record code. Value is 239. ***/
119 public static final int EOR = 239;
120
121 /**** Abort code. Value is 238. ***/
122 public static final int ABORT = 238;
123
124 /**** Suspend process code. Value is 237. ***/
125 public static final int SUSP = 237;
126
127 /**** End of file code. Value is 236. ***/
128 public static final int EOF = 236;
129
130 /**** Synchronize code. Value is 242. ***/
131 public static final int SYNCH = 242;
132
133 /**** String representations of commands. ***/
134 private static final String __commandString[] = {
135 "IAC", "DONT", "DO", "WONT", "WILL", "SB", "GA", "EL", "EC", "AYT",
136 "AO", "IP", "BRK", "DMARK", "NOP", "SE", "EOR", "ABORT", "SUSP", "EOF"
137 };
138
139 private static final int __FIRST_COMMAND = IAC;
140 private static final int __LAST_COMMAND = EOF;
141
142 /****
143 * Returns the string representation of the telnet protocol command
144 * corresponding to the given command code.
145 * <p>
146 * @param The command code of the telnet protocol command.
147 * @return The string representation of the telnet protocol command.
148 ***/
149 public static final String getCommand(int code)
150 {
151 return __commandString[__FIRST_COMMAND - code];
152 }
153
154 /****
155 * Determines if a given command code is valid. Returns true if valid,
156 * false if not.
157 * <p>
158 * @param code The command code to test.
159 * @return True if the command code is valid, false if not.
160 **/
161 public static final boolean isValidCommand(int code)
162 {
163 return (code <= __FIRST_COMMAND && code >= __LAST_COMMAND);
164 }
165
166 // Cannot be instantiated
167 private TelnetCommand()
168 { }
169 }
This page was automatically generated by Maven