KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > spoon > examples > resource > src > Resource


1 package spoon.examples.resource.src;
2
3 /**
4  * This class is a dummy resource for testing Spoon analysis capabilities.
5  * Implicit rules are that it must not be read or closed before it is opened,
6  * and it cannot be opened twice or more.
7  */

8 public class Resource {
9
10     private boolean isOpen = false;
11
12     public void open() {
13         isOpen = true;
14     }
15
16     public void close() {
17         isOpen = false;
18     }
19
20     public void read() {
21         if (!isOpen) {
22             throw new RuntimeException JavaDoc("resource is not open");
23         }
24         // do something
25
}
26
27 }
28
Popular Tags