ActiveIO - 1.0

Clover coverage report - ActiveIO - 1.0 Coverage timestamp: Fri Apr 22 2005 14:27:22 PDT FRAMES NO FRAMES |
file stats: | LOC: | 127 |  | Methods: | 13
| NCLOC: | 55 |  | Classes: | 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
Source file | Conditionals | Statements | Methods | TOTAL
FilterAsynchChannel.java | 62.5% | 77.3% | 84.6% | 76.7% |

1 |  |
     /**
2 |  |
      *
3 |  |
      * Copyright 2004 Hiram Chirino
4 |  |
      *
5 |  |
      *  Licensed under the Apache License, Version 2.0 (the "License");
6 |  |
      *  you may not use this file except in compliance with the License.
7 |  |
      *  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 |  |
     package org.activeio;
18 |  |
19 |  |
     import java.io.IOException;
20 |  |
21 |  |
22 |  |
     /**
23 |  |
      * A AsynchChannelFilter can be used as a filter between a {@see org.activeio.AsynchChannel}
24 |  |
      * and it's {@see org.activeio.ChannelConsumer}.  Most {@see org.activeio.AsynchChannel}
25 |  |
      * that are not directly accessing the network will extends the AsynchChannelFilter since they act as a
26 |  |
      * filter between the client and the network.  O
27 |  |
      *
28 |  |
      * @version $Revision$
29 |  |
      */
30 |  |
     public class FilterAsynchChannel implements AsynchChannel, AsynchChannelListener {
31 |  |
32 |  |
         final protected AsynchChannel next;
33 |  |
         protected AsynchChannelListener channelListener;
34 |  |
35 | 42 |
         public FilterAsynchChannel(AsynchChannel next) {
36 | 42 |
             this.next = next;
37 |  |
         }
38 |  |
39 |  |
         /**
40 |  |
          */
41 | 50 |
         public void setAsynchChannelListener(AsynchChannelListener channelListener) {
42 | 50 |
             this.channelListener = channelListener;
43 | 50 |
             if (channelListener == null)
44 | 12 |
                 next.setAsynchChannelListener(null);
45 |  |
             else
46 | 38 |
                 next.setAsynchChannelListener(this);
47 |  |
         }
48 |  |
49 |  |
         /**
50 |  |
          * @see org.activeio.Channel#write(org.activeio.channel.Packet)
51 |  |
          */
52 | 0 |
         public void write(Packet packet) throws IOException {
53 | 0 |
             next.write(packet);
54 |  |
         }
55 |  |
56 |  |
         /**
57 |  |
          * @see org.activeio.Channel#flush()
58 |  |
          */
59 | 10 |
         public void flush() throws IOException {
60 | 10 |
             next.flush();
61 |  |
         }
62 |  |
63 |  |
         /**
64 |  |
          * @see org.activeio.Disposable#dispose()
65 |  |
          */
66 | 18 |
         public void dispose() {
67 | 18 |
             next.dispose();
68 |  |
         }
69 |  |
70 |  |
         /**
71 |  |
          * @see org.activeio.Service#start()
72 |  |
          * @throws IOException if the next channel has not been set.
73 |  |
          */
74 | 38 |
         public void start() throws IOException {
75 | 38 |
             if( next == null )
76 | 0 |
                 throw new IOException("The next channel has not been set.");
77 | 38 |
             if( channelListener ==null )
78 | 0 |
                 throw new IOException("The UpPacketListener has not been set.");
79 | 38 |
             next.start();
80 |  |
         }
81 |  |
82 |  |
         /**
83 |  |
          * @see org.activeio.Service#stop(long)
84 |  |
          */
85 | 12 |
         public void stop(long timeout) throws IOException {
86 | 12 |
             next.stop(timeout);
87 |  |
         }
88 |  |
89 |  |
         /**
90 |  |
          * @see org.activeio.AsynchChannelListener#onPacket(org.activeio.channel.Packet)
91 |  |
          */
92 | 2038 |
         public void onPacket(Packet packet) {
93 | 2038 |
             channelListener.onPacket(packet);
94 |  |
         }
95 |  |
96 |  |
         /**
97 |  |
          * @see org.activeio.AsynchChannelListener#onPacketError(org.activeio.channel.ChannelException)
98 |  |
          */
99 | 14 |
         public void onPacketError(IOException error) {
100 | 14 |
             channelListener.onPacketError(error);
101 |  |
         }
102 |  |
103 |  |
         /**
104 |  |
          * @return Returns the next.
105 |  |
          */
106 | 2036 |
         public AsynchChannel getNext() {
107 | 2036 |
             return next;
108 |  |
         }
109 |  |
110 |  |
         /**
111 |  |
          * @return Returns the packetListener.
112 |  |
          */
113 | 12 |
         public AsynchChannelListener getAsynchChannelListener() {
114 | 12 |
             return channelListener;
115 |  |
         }
116 |  |
117 | 16 |
         public Object narrow(Class target) {
118 | 16 |
             if( target.isAssignableFrom(getClass()) ) {
119 | 0 |
                 return this;
120 |  |
             }
121 | 16 |
             return next.narrow(target);
122 |  |
         }
123 |  |
124 | 0 |
         public String toString() {
125 | 0 |
             return next.toString();
126 |  |
         }
127 |  |
     }