Coverage report

| %line | %branch
--- | --- | ---
org.apache.commons.net.telnet.TerminalTypeOptionHandler |
94% |
95% |

1 |  |
     /*
2 |  |
      * Copyright 2003-2004 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 |  |
      * Implements the telnet terminal type option RFC 1091.
20 |  |
      * <p>
21 |  |
      * @author Bruno D'Avanzo
22 |  |
      ***/
23 |  |
     public class TerminalTypeOptionHandler extends TelnetOptionHandler
24 |  |
     {
25 |  |
         /***
26 |  |
          * Terminal type
27 |  |
          ***/
28 | 46 |
         private String termType = null;
29 |  |
30 |  |
         /***
31 |  |
          * Terminal type option
32 |  |
          ***/
33 |  |
         protected static final int TERMINAL_TYPE = 24;
34 |  |
35 |  |
         /***
36 |  |
          * Send (for subnegotiation)
37 |  |
          ***/
38 |  |
         protected static final int TERMINAL_TYPE_SEND =  1;
39 |  |
40 |  |
         /***
41 |  |
          * Is (for subnegotiation)
42 |  |
          ***/
43 |  |
         protected static final int TERMINAL_TYPE_IS =  0;
44 |  |
45 |  |
         /***
46 |  |
          * Constructor for the TerminalTypeOptionHandler. Allows defining desired
47 |  |
          * initial setting for local/remote activation of this option and
48 |  |
          * behaviour in case a local/remote activation request for this
49 |  |
          * option is received.
50 |  |
          * <p>
51 |  |
          * @param termtype - terminal type that will be negotiated.
52 |  |
          * @param initlocal - if set to true, a WILL is sent upon connection.
53 |  |
          * @param initremote - if set to true, a DO is sent upon connection.
54 |  |
          * @param acceptlocal - if set to true, any DO request is accepted.
55 |  |
          * @param acceptremote - if set to true, any WILL request is accepted.
56 |  |
          ***/
57 |  |
         public TerminalTypeOptionHandler(String termtype,
58 |  |
                                     boolean initlocal,
59 |  |
                                     boolean initremote,
60 |  |
                                     boolean acceptlocal,
61 |  |
                                     boolean acceptremote)
62 |  |
         {
63 | 36 |
             super(TelnetOption.TERMINAL_TYPE, initlocal, initremote,
64 |  |
                                           acceptlocal, acceptremote);
65 | 36 |
             termType = termtype;
66 | 36 |
         }
67 |  |
68 |  |
         /***
69 |  |
          * Constructor for the TerminalTypeOptionHandler. Initial and accept
70 |  |
          * behaviour flags are set to false
71 |  |
          * <p>
72 |  |
          * @param termtype - terminal type that will be negotiated.
73 |  |
          ***/
74 |  |
         public TerminalTypeOptionHandler(String termtype)
75 |  |
         {
76 | 10 |
             super(TelnetOption.TERMINAL_TYPE, false, false, false, false);
77 | 10 |
             termType = termtype;
78 | 10 |
         }
79 |  |
80 |  |
         /***
81 |  |
          * Implements the abstract method of TelnetOptionHandler.
82 |  |
          * <p>
83 |  |
          * @param suboptionData - the sequence received, whithout IAC SB & IAC SE
84 |  |
          * @param suboptionLength - the length of data in suboption_data
85 |  |
          * <p>
86 |  |
          * @return terminal type information
87 |  |
          ***/
88 |  |
         public int[] answerSubnegotiation(class="keyword">int suboptionData[], class="keyword">int suboptionLength)
89 |  |
         {
90 | 6 |
             if ((suboptionData != null) && (suboptionLength > 1)
91 |  |
                 && (termType != null))
92 |  |
             {
93 | 6 |
                 if ((suboptionData[0] == TERMINAL_TYPE)
94 |  |
                     && (suboptionData[1] == TERMINAL_TYPE_SEND))
95 |  |
                 {
96 | 6 |
                     int response[] = new class="keyword">int[termType.length() + 2];
97 |  |
98 | 6 |
                     response[0] = TERMINAL_TYPE;
99 | 6 |
                     response[1] = TERMINAL_TYPE_IS;
100 |  |
101 | 34 |
                     for (int ii = 0; ii < termType.length(); ii++)
102 |  |
                     {
103 | 28 |
                         response[ii + 2] = (int) termType.charAt(ii);
104 |  |
                     }
105 |  |
106 | 6 |
                     return response;
107 |  |
                 }
108 |  |
             }
109 | 0 |
             return null;
110 |  |
         }
111 |  |
112 |  |
         /***
113 |  |
          * Implements the abstract method of TelnetOptionHandler.
114 |  |
          * <p>
115 |  |
          * @return always null (no response to subnegotiation)
116 |  |
          ***/
117 |  |
         public int[] startSubnegotiationLocal()
118 |  |
         {
119 | 6 |
             return null;
120 |  |
         }
121 |  |
122 |  |
         /***
123 |  |
          * Implements the abstract method of TelnetOptionHandler.
124 |  |
          * <p>
125 |  |
          * @return always null (no response to subnegotiation)
126 |  |
          ***/
127 |  |
         public int[] startSubnegotiationRemote()
128 |  |
         {
129 | 2 |
             return null;
130 |  |
         }
131 |  |
     }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.