KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > net > telnet > TelnetOption


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

16 package org.apache.commons.net.telnet;
17
18 /***
19  * The TelnetOption class cannot be instantiated and only serves as a
20  * storehouse for telnet option constants.
21  * <p>
22  * Details regarding Telnet option specification can be found in RFC 855.
23  * <p>
24  * <p>
25  * @author Daniel F. Savarese
26  * @see org.apache.commons.net.telnet.Telnet
27  * @see org.apache.commons.net.telnet.TelnetClient
28  ***/

29
30 public class TelnetOption
31 {
32     /*** The maximum value an option code can have. This value is 255. ***/
33     public static final int MAX_OPTION_VALUE = 255;
34
35     public static int BINARY = 0;
36
37     public static int ECHO = 1;
38
39     public static int PREPARE_TO_RECONNECT = 2;
40
41     public static int SUPPRESS_GO_AHEAD = 3;
42
43     public static int APPROXIMATE_MESSAGE_SIZE = 4;
44
45     public static int STATUS = 5;
46
47     public static int TIMING_MARK = 6;
48
49     public static int REMOTE_CONTROLLED_TRANSMISSION = 7;
50
51     public static int NEGOTIATE_OUTPUT_LINE_WIDTH = 8;
52
53     public static int NEGOTIATE_OUTPUT_PAGE_SIZE = 9;
54
55     public static int NEGOTIATE_CARRIAGE_RETURN = 10;
56
57     public static int NEGOTIATE_HORIZONTAL_TAB_STOP = 11;
58
59     public static int NEGOTIATE_HORIZONTAL_TAB = 12;
60
61     public static int NEGOTIATE_FORMFEED = 13;
62
63     public static int NEGOTIATE_VERTICAL_TAB_STOP = 14;
64
65     public static int NEGOTIATE_VERTICAL_TAB = 15;
66
67     public static int NEGOTIATE_LINEFEED = 16;
68
69     public static int EXTENDED_ASCII = 17;
70
71     public static int FORCE_LOGOUT = 18;
72
73     public static int BYTE_MACRO = 19;
74
75     public static int DATA_ENTRY_TERMINAL = 20;
76
77     public static int SUPDUP = 21;
78
79     public static int SUPDUP_OUTPUT = 22;
80
81     public static int SEND_LOCATION = 23;
82
83     public static int TERMINAL_TYPE = 24;
84
85     public static int END_OF_RECORD = 25;
86
87     public static int TACACS_USER_IDENTIFICATION = 26;
88
89     public static int OUTPUT_MARKING = 27;
90
91     public static int TERMINAL_LOCATION_NUMBER = 28;
92
93     public static int REGIME_3270 = 29;
94
95     public static int X3_PAD = 30;
96
97     public static int WINDOW_SIZE = 31;
98
99     public static int TERMINAL_SPEED = 32;
100
101     public static int REMOTE_FLOW_CONTROL = 33;
102
103     public static int LINEMODE = 34;
104
105     public static int X_DISPLAY_LOCATION = 35;
106
107     public static int OLD_ENVIRONMENT_VARIABLES = 36;
108
109     public static int AUTHENTICATION = 37;
110
111     public static int ENCRYPTION = 38;
112
113     public static int NEW_ENVIRONMENT_VARIABLES = 39;
114
115     public static int EXTENDED_OPTIONS_LIST = 255;
116
117     private static int __FIRST_OPTION = BINARY;
118     private static int __LAST_OPTION = EXTENDED_OPTIONS_LIST;
119
120     private static final String JavaDoc __optionString[] = {
121                 "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME", "STATUS",
122                 "TIMING MARK", "RCTE", "NAOL", "NAOP", "NAOCRD", "NAOHTS", "NAOHTD",
123                 "NAOFFD", "NAOVTS", "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT",
124                 "BYTE MACRO", "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
125                 "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD", "TACACS UID",
126                 "OUTPUT MARKING", "TTYLOC", "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED",
127                 "LFLOW", "LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
128                 "ENCRYPT", "NEW-ENVIRON", "TN3270E", "XAUTH", "CHARSET", "RSP",
129                 "Com Port Control", "Suppress Local Echo", "Start TLS",
130                 "KERMIT", "SEND-URL", "FORWARD_X", "", "", "",
131                 "", "", "", "", "", "", "", "", "", "",
132                 "", "", "", "", "", "", "", "", "", "",
133                 "", "", "", "", "", "", "", "", "", "",
134                 "", "", "", "", "", "", "", "", "", "",
135                 "", "", "", "", "", "", "", "", "", "",
136                 "", "", "", "", "", "", "", "", "", "",
137                 "", "", "", "", "", "", "", "", "", "",
138                 "", "", "", "", "", "", "", "", "", "",
139                 "", "", "", "", "", "TELOPT PRAGMA LOGON", "TELOPT SSPI LOGON",
140                 "TELOPT PRAGMA HEARTBEAT", "", "", "", "",
141                 "", "", "", "", "", "", "", "", "", "",
142                 "", "", "", "", "", "", "", "", "", "",
143                 "", "", "", "", "", "", "", "", "", "",
144                 "", "", "", "", "", "", "", "", "", "",
145                 "", "", "", "", "", "", "", "", "", "",
146                 "", "", "", "", "", "", "", "", "", "",
147                 "", "", "", "", "", "", "", "", "", "",
148                 "", "", "", "", "", "", "", "", "", "",
149                 "", "", "", "", "", "", "", "", "", "",
150                 "", "", "", "", "", "", "", "", "", "",
151                 "", "", "", "", "", "", "", "", "", "",
152                 "Extended-Options-List"
153             };
154
155
156     /***
157      * Returns the string representation of the telnet protocol option
158      * corresponding to the given option code.
159      * <p>
160      * @param code The option code of the telnet protocol option
161      * @return The string representation of the telnet protocol option.
162      ***/

163     public static final String JavaDoc getOption(int code)
164     {
165         if(__optionString[code].length() == 0)
166         {
167             return "UNASSIGNED";
168         }
169         else
170         {
171             return __optionString[code];
172         }
173     }
174
175
176     /***
177      * Determines if a given option code is valid. Returns true if valid,
178      * false if not.
179      * <p>
180      * @param code The option code to test.
181      * @return True if the option code is valid, false if not.
182      **/

183     public static final boolean isValidOption(int code)
184     {
185         return (code <= __LAST_OPTION);
186     }
187
188     // Cannot be instantiated
189
private TelnetOption()
190     { }
191 }
192
Popular Tags