Source Code Cross Referenced for TelnetOptionHandler.java in  » Net » Apache-commons-net-1.4.1 » org » apache » commons » net » telnet » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » Apache commons net 1.4.1 » org.apache.commons.net.telnet 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2003-2004 The Apache Software Foundation
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *     http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        package org.apache.commons.net.telnet;
017:
018:        /***
019:         * The TelnetOptionHandler class is the base class to be used
020:         * for implementing handlers for telnet options.
021:         * <p>
022:         * TelnetOptionHandler implements basic option handling
023:         * functionality and defines abstract methods that must be
024:         * implemented to define subnegotiation behaviour.
025:         * <p>
026:         * @author Bruno D'Avanzo
027:         ***/
028:        public abstract class TelnetOptionHandler {
029:            /***
030:             * Option code
031:             ***/
032:            private int optionCode = -1;
033:
034:            /***
035:             * true if the option should be activated on the local side
036:             ***/
037:            private boolean initialLocal = false;
038:
039:            /***
040:             * true if the option should be activated on the remote side
041:             ***/
042:            private boolean initialRemote = false;
043:
044:            /***
045:             * true if the option should be accepted on the local side
046:             ***/
047:            private boolean acceptLocal = false;
048:
049:            /***
050:             * true if the option should be accepted on the remote side
051:             ***/
052:            private boolean acceptRemote = false;
053:
054:            /***
055:             * true if the option is active on the local side
056:             ***/
057:            private boolean doFlag = false;
058:
059:            /***
060:             * true if the option is active on the remote side
061:             ***/
062:            private boolean willFlag = false;
063:
064:            /***
065:             * Constructor for the TelnetOptionHandler. Allows defining desired
066:             * initial setting for local/remote activation of this option and
067:             * behaviour in case a local/remote activation request for this
068:             * option is received.
069:             * <p>
070:             * @param optcode - Option code.
071:             * @param initlocal - if set to true, a WILL is sent upon connection.
072:             * @param initremote - if set to true, a DO is sent upon connection.
073:             * @param acceptlocal - if set to true, any DO request is accepted.
074:             * @param acceptremote - if set to true, any WILL request is accepted.
075:             ***/
076:            public TelnetOptionHandler(int optcode, boolean initlocal,
077:                    boolean initremote, boolean acceptlocal,
078:                    boolean acceptremote) {
079:                optionCode = optcode;
080:                initialLocal = initlocal;
081:                initialRemote = initremote;
082:                acceptLocal = acceptlocal;
083:                acceptRemote = acceptremote;
084:            }
085:
086:            /***
087:             * Returns the option code for this option.
088:             * <p>
089:             * @return Option code.
090:             ***/
091:            public int getOptionCode() {
092:                return (optionCode);
093:            }
094:
095:            /***
096:             * Returns a boolean indicating whether to accept a DO
097:             * request coming from the other end.
098:             * <p>
099:             * @return true if a DO request shall be accepted.
100:             ***/
101:            public boolean getAcceptLocal() {
102:                return (acceptLocal);
103:            }
104:
105:            /***
106:             * Returns a boolean indicating whether to accept a WILL
107:             * request coming from the other end.
108:             * <p>
109:             * @return true if a WILL request shall be accepted.
110:             ***/
111:            public boolean getAcceptRemote() {
112:                return (acceptRemote);
113:            }
114:
115:            /***
116:             * Set behaviour of the option for DO requests coming from
117:             * the other end.
118:             * <p>
119:             * @param accept - if true, subsequent DO requests will be accepted.
120:             ***/
121:            public void setAcceptLocal(boolean accept) {
122:                acceptLocal = accept;
123:            }
124:
125:            /***
126:             * Set behaviour of the option for WILL requests coming from
127:             * the other end.
128:             * <p>
129:             * @param accept - if true, subsequent WILL requests will be accepted.
130:             ***/
131:            public void setAcceptRemote(boolean accept) {
132:                acceptRemote = accept;
133:            }
134:
135:            /***
136:             * Returns a boolean indicating whether to send a WILL request
137:             * to the other end upon connection.
138:             * <p>
139:             * @return true if a WILL request shall be sent upon connection.
140:             ***/
141:            public boolean getInitLocal() {
142:                return (initialLocal);
143:            }
144:
145:            /***
146:             * Returns a boolean indicating whether to send a DO request
147:             * to the other end upon connection.
148:             * <p>
149:             * @return true if a DO request shall be sent upon connection.
150:             ***/
151:            public boolean getInitRemote() {
152:                return (initialRemote);
153:            }
154:
155:            /***
156:             * Tells this option whether to send a WILL request upon connection.
157:             * <p>
158:             * @param init - if true, a WILL request will be sent upon subsequent
159:             * connections.
160:             ***/
161:            public void setInitLocal(boolean init) {
162:                initialLocal = init;
163:            }
164:
165:            /***
166:             * Tells this option whether to send a DO request upon connection.
167:             * <p>
168:             * @param init - if true, a DO request will be sent upon subsequent
169:             * connections.
170:             ***/
171:            public void setInitRemote(boolean init) {
172:                initialRemote = init;
173:            }
174:
175:            /***
176:             * Method called upon reception of a subnegotiation for this option
177:             * coming from the other end.
178:             * Must be implemented by the actual TelnetOptionHandler to specify
179:             * which response must be sent for the subnegotiation request.
180:             * <p>
181:             * @param suboptionData - the sequence received, whithout IAC SB & IAC SE
182:             * @param suboptionLength - the length of data in suboption_data
183:             * <p>
184:             * @return response to be sent to the subnegotiation sequence. TelnetClient
185:             * will add IAC SB & IAC SE. null means no response
186:             ***/
187:            public abstract int[] answerSubnegotiation(int suboptionData[],
188:                    int suboptionLength);
189:
190:            /***
191:             * This method is invoked whenever this option is acknowledged active on
192:             * the local end (TelnetClient sent a WILL, remote side sent a DO).
193:             * The method is used to specify a subnegotiation sequence that will be
194:             * sent by TelnetClient when the option is activated.
195:             * <p>
196:             * @return subnegotiation sequence to be sent by TelnetClient. TelnetClient
197:             * will add IAC SB & IAC SE. null means no subnegotiation.
198:             ***/
199:            public abstract int[] startSubnegotiationLocal();
200:
201:            /***
202:             * This method is invoked whenever this option is acknowledged active on
203:             * the remote end (TelnetClient sent a DO, remote side sent a WILL).
204:             * The method is used to specify a subnegotiation sequence that will be
205:             * sent by TelnetClient when the option is activated.
206:             * <p>
207:             * @return subnegotiation sequence to be sent by TelnetClient. TelnetClient
208:             * will add IAC SB & IAC SE. null means no subnegotiation.
209:             ***/
210:            public abstract int[] startSubnegotiationRemote();
211:
212:            /***
213:             * Returns a boolean indicating whether a WILL request sent to the other
214:             * side has been acknowledged.
215:             * <p>
216:             * @return true if a WILL sent to the other side has been acknowledged.
217:             ***/
218:            boolean getWill() {
219:                return willFlag;
220:            }
221:
222:            /***
223:             * Tells this option whether a WILL request sent to the other
224:             * side has been acknowledged (invoked by TelnetClient).
225:             * <p>
226:             * @param state - if true, a WILL request has been acknowledged.
227:             ***/
228:            void setWill(boolean state) {
229:                willFlag = state;
230:            }
231:
232:            /***
233:             * Returns a boolean indicating whether a DO request sent to the other
234:             * side has been acknowledged.
235:             * <p>
236:             * @return true if a DO sent to the other side has been acknowledged.
237:             ***/
238:            boolean getDo() {
239:                return doFlag;
240:            }
241:
242:            /***
243:             * Tells this option whether a DO request sent to the other
244:             * side has been acknowledged (invoked by TelnetClient).
245:             * <p>
246:             * @param state - if true, a DO request has been acknowledged.
247:             ***/
248:            void setDo(boolean state) {
249:                doFlag = state;
250:            }
251:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.