KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > util > io > MockChannel


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.util.io;
5
6 import java.io.IOException JavaDoc;
7 import java.nio.channels.Channel JavaDoc;
8 import java.nio.channels.ClosedChannelException JavaDoc;
9
10 public class MockChannel implements Channel JavaDoc {
11
12   private boolean isOpen = true;
13
14   public final synchronized boolean isOpen() {
15     return isOpen;
16   }
17
18   public final synchronized void close() {
19     isOpen = false;
20   }
21
22   protected final synchronized void checkOpen() throws IOException JavaDoc {
23     if (!isOpen()) { throw new ClosedChannelException JavaDoc(); }
24   }
25 }
26
Popular Tags