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: | 85 |  | Methods: | 7
| NCLOC: | 41 |  | 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
SynchToAsynchChannelFactoryAdaptor.java | 50% | 66.7% | 71.4% | 65.2% |

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 |  |
      **/
18 |  |
     package org.activeio.adapter;
19 |  |
20 |  |
     import java.io.IOException;
21 |  |
     import java.net.URI;
22 |  |
23 |  |
     import org.activeio.AsynchChannel;
24 |  |
     import org.activeio.AsynchChannelFactory;
25 |  |
     import org.activeio.AsynchChannelServer;
26 |  |
     import org.activeio.ChannelFactory;
27 |  |
     import org.activeio.SynchChannelFactory;
28 |  |
29 |  |
     import EDU.oswego.cs.dl.util.concurrent.Executor;
30 |  |
31 |  |
     /**
32 |  |
      * @version $Revision$
33 |  |
      */
34 |  |
     public class SynchToAsynchChannelFactoryAdaptor implements AsynchChannelFactory {
35 |  |
36 |  |
         private final SynchChannelFactory synchChannelFactory;
37 |  |
         private final Executor executor;
38 |  |
39 | 2 |
         static public AsynchChannelFactory adapt(SynchChannelFactory channelFactory) {
40 | 2 |
             return adapt(channelFactory, ChannelFactory.DEFAULT_EXECUTOR);
41 |  |
         }
42 |  |
43 | 20 |
         static public AsynchChannelFactory adapt(SynchChannelFactory channelFactory, Executor executor ) {
44 |  |
45 |  |
             // It might not need adapting
46 | 20 |
             if( channelFactory instanceof AsynchChannelFactory ) {
47 | 0 |
                 return (AsynchChannelFactory) channelFactory;
48 |  |
             }
49 |  |
50 |  |
             // Can we just just undo the adaptor
51 | 20 |
             if( channelFactory.getClass() == AsynchToSynchChannelFactoryAdaptor.class ) {
52 | 0 |
                 return ((AsynchToSynchChannelFactoryAdaptor)channelFactory).getAsynchChannelFactory();
53 |  |
             }
54 |  |
55 | 20 |
             return new SynchToAsynchChannelFactoryAdaptor((SynchChannelFactory)channelFactory, executor);
56 |  |
         }
57 |  |
58 |  |
         /**
59 |  |
          * @deprecated {@see #adapt(SynchChannelFactory)}
60 |  |
          */
61 | 0 |
         public SynchToAsynchChannelFactoryAdaptor(final SynchChannelFactory next) {
62 | 0 |
             this(next, ChannelFactory.DEFAULT_EXECUTOR);
63 |  |
         }
64 |  |
65 |  |
         /**
66 |  |
          * @deprecated {@see #adapt(SynchChannelFactory, Executor)}
67 |  |
          */
68 | 20 |
         public SynchToAsynchChannelFactoryAdaptor(final SynchChannelFactory next, Executor executor) {
69 | 20 |
             this.synchChannelFactory = next;
70 | 20 |
             this.executor = executor;
71 |  |
         }
72 |  |
73 | 2 |
         public AsynchChannel openAsynchChannel(URI location) throws IOException {
74 | 2 |
             return SynchToAsynchChannelAdapter.adapt(synchChannelFactory.openSynchChannel(location),executor);
75 |  |
         }
76 |  |
77 | 20 |
         public AsynchChannelServer bindAsynchChannel(URI location) throws IOException {
78 | 20 |
             return new SynchToAsynchChannelServerAdapter(synchChannelFactory.bindSynchChannel(location),executor);
79 |  |
         }
80 |  |
81 | 0 |
         public SynchChannelFactory getSynchChannelFactory() {
82 | 0 |
             return synchChannelFactory;
83 |  |
         }
84 |  |
     }
85 |  |