summaryrefslogtreecommitdiff
path: root/NET/worlds/console/AddHandler.java
blob: 4ecc96a2a97bc062d5202bd00eb0f0b5c1b7070d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*     */ package NET.worlds.console;
/*     */ 
/*     */ import NET.worlds.scape.BumpEventTemp;
/*     */ import NET.worlds.scape.BumpHandler;
/*     */ import NET.worlds.scape.NoSuchPropertyException;
/*     */ import NET.worlds.scape.Portal;
/*     */ import NET.worlds.scape.Restorer;
/*     */ import NET.worlds.scape.Room;
/*     */ import NET.worlds.scape.Saver;
/*     */ import NET.worlds.scape.SuperRoot;
/*     */ import NET.worlds.scape.TooNewException;
/*     */ import NET.worlds.scape.VectorProperty;
/*     */ import java.io.IOException;
/*     */ import java.util.Enumeration;
/*     */ import java.util.Vector;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class AddHandler
/*     */   extends SuperRoot
/*     */   implements BumpHandler
/*     */ {
/*  39 */   private Vector<SuperRoot> handlers = new Vector(1);
/*     */   
/*     */   public AddHandler() {}
/*     */   
/*     */   public AddHandler(SuperRoot newhandler)
/*     */   {
/*  45 */     this.handlers.addElement(newhandler);
/*     */   }
/*     */   
/*     */   public boolean handle(BumpEventTemp e) {
/*  49 */     Room sc = ((Portal)e.target).farSide().getRoom();
/*  50 */     assert (((sc instanceof Staircase)) || ((sc instanceof Stair)));
/*  51 */     Enumeration<SuperRoot> enh = this.handlers.elements();
/*  52 */     while (enh.hasMoreElements()) {
/*  53 */       sc.addHandler((SuperRoot)enh.nextElement());
/*     */     }
/*  55 */     return true;
/*     */   }
/*     */   
/*  58 */   private static Object classCookie = new Object();
/*     */   
/*     */   public void saveState(Saver s) throws IOException
/*     */   {
/*  62 */     s.saveVersion(2, classCookie);
/*  63 */     super.saveState(s);
/*  64 */     s.saveVector(this.handlers);
/*     */   }
/*     */   
/*     */   public void restoreState(Restorer r) throws IOException, TooNewException
/*     */   {
/*  69 */     switch (r.restoreVersion(classCookie)) {
/*     */     case 2: 
/*  71 */       super.restoreState(r);
/*  72 */       this.handlers = r.restoreVectorSuperRoot();
/*  73 */       break;
/*     */     case 1: 
/*  75 */       super.restoreState(r);
/*     */     
/*     */     case 0: 
/*  78 */       if (r.restoreBoolean())
/*  79 */         this.handlers.addElement((SuperRoot)r.restore());
/*  80 */       break;
/*     */     default: 
/*  82 */       throw new TooNewException();
/*     */     }
/*     */     
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public Object properties(int index, int offset, int mode, Object value)
/*     */     throws NoSuchPropertyException
/*     */   {
/*  92 */     Object ret = null;
/*     */     
/*  94 */     switch (index - offset) {
/*     */     case 0: 
/*  96 */       if (mode == 0) {
/*  97 */         ret = new VectorProperty(this, index, "Handlers to Add");
/*  98 */       } else if (mode == 1) {
/*  99 */         ret = this.handlers.clone();
/* 100 */       } else if (mode == 4) {
/* 101 */         this.handlers.removeElement(value);
/* 102 */       } else if (mode == 3)
/* 103 */         this.handlers.addElement((SuperRoot)value);
/* 104 */       break;
/*     */     default: 
/* 106 */       ret = super.properties(index, offset + 1, mode, value);
/*     */     }
/*     */     
/* 109 */     return ret;
/*     */   }
/*     */ }


/* Location:              C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\AddHandler.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */