/* */ package NET.worlds.scape; /* */ /* */ import NET.worlds.console.Console; /* */ import NET.worlds.console.Gamma; /* */ import java.io.IOException; /* */ import java.text.MessageFormat; /* */ import java.util.Enumeration; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public abstract class SetPropertyAction /* */ extends Action /* */ { /* */ SuperRoot _target; /* */ String _targetName; /* */ String _roomName; /* */ String _propName; /* 36 */ private int _propIndex = -1; /* */ /* */ /* */ /* */ /* 41 */ private String _paramName = null; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public SuperRoot getTarget() /* */ { /* 60 */ if ((this._target == null) && (this._targetName != null)) { /* 61 */ Room r = null; /* 62 */ if (this._roomName != null) { /* 63 */ World w = getWorld(); /* 64 */ if (w != null) /* 65 */ r = w.getRoom(this._roomName); /* */ } else { /* 67 */ r = getRoom(); } /* 68 */ if (r != null) { /* 69 */ Enumeration list = r.getDeepOwned(); /* 70 */ this._target = SuperRoot.nameSearch(list, this._targetName); /* */ } /* */ } /* */ /* 74 */ if (this._target != null) /* 75 */ return this._target; /* 76 */ return getOwner(); /* */ } /* */ /* */ /* 80 */ protected boolean useParam() { return this._paramName != null; } /* */ /* 82 */ protected String paramName() { return this._paramName; } /* */ /* */ protected String param() /* */ { /* 86 */ return this._paramName == null ? /* 87 */ null : /* 88 */ Gamma.getParam(this._paramName); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ static int index(int index, String name, Object target) /* */ { /* 97 */ if ((index == -1) && (name != null)) { /* 98 */ Enumeration pe = new EnumProperties(target); /* 99 */ while (pe.hasMoreElements()) { /* 100 */ Property prop = (Property)pe.nextElement(); /* 101 */ if (prop.getName().equals(name)) { /* 102 */ index = prop.getIndex(); /* 103 */ break; /* */ } /* */ } /* */ } /* 107 */ return index; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public static Object propHelper(int mode, Object value, String name, SuperRoot target) /* */ { /* 116 */ Object ret = null; /* 117 */ int i = index(-1, name, target); /* 118 */ if (i != -1) { /* */ try { /* 120 */ ret = target.properties(i, 0, mode, value); /* */ } catch (NoSuchPropertyException localNoSuchPropertyException) {} /* */ } /* 123 */ return ret; /* */ } /* */ /* */ /* */ private Object propHelper(int mode, Object value) /* */ { /* 129 */ SuperRoot target = getTarget(); /* */ /* 131 */ Object ret = null; /* 132 */ if ((this._propIndex = index(this._propIndex, this._propName, target)) != -1) { /* */ try { /* 134 */ ret = target.properties(this._propIndex, 0, mode, value); /* */ } catch (NoSuchPropertyException nspe) { /* 136 */ if ($assertionsDisabled) break label220; } throw new AssertionError(); /* */ } /* 138 */ else if (target == null) { /* 139 */ Console.println( /* 140 */ getName() + Console.message("null-target")); /* */ } /* 142 */ else if (this._propName == null) { /* 143 */ Object[] arguments = { new String(getName()), /* 144 */ new String(getTarget().getName()) }; /* 145 */ Console.println(MessageFormat.format( /* 146 */ Console.message("null-property"), arguments)); /* */ } /* */ else { /* 149 */ Object[] arguments = { new String(getName()), /* 150 */ new String(this._propName), new String(getTarget().getName()) }; /* 151 */ Console.println(MessageFormat.format( /* 152 */ Console.message("non-property"), arguments)); } /* */ label220: /* 154 */ return ret; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ protected final void set(Object value) /* */ { /* 163 */ propHelper(2, value); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ protected final Object get() /* */ { /* 173 */ return propHelper(1, null); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ protected final void add(Object value) /* */ { /* 182 */ propHelper(3, value); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ protected final void remove(Object value) /* */ { /* 192 */ propHelper(4, value); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ protected final Property enumerate() /* */ { /* 202 */ return (Property)propHelper(0, null); /* */ } /* */ /* */ /* */ /* */ public Object properties(int index, int offset, int mode, Object value) /* */ throws NoSuchPropertyException /* */ { /* 210 */ Object ret = null; /* 211 */ switch (index - offset) { /* */ case 0: /* 213 */ if (mode == 0) { /* 214 */ Property p = new Property(this, index, "Target"); /* 215 */ p.allowSetNull(); /* 216 */ ret = ObjPropertyEditor.make(p, getRoom(), /* 217 */ "NET.worlds.scape.SuperRoot"); /* 218 */ } else if (mode == 1) { /* 219 */ ret = getTarget(); /* 220 */ } else if (mode == 2) { /* 221 */ this._target = ((SuperRoot)value); /* 222 */ this._propIndex = -1; /* */ } /* 224 */ break; /* */ case 1: /* 226 */ if (mode == 0) { /* 227 */ ret = StringPropertyEditor.make( /* 228 */ new Property(this, index, "Target Room")); /* 229 */ } else if (mode == 1) { /* 230 */ ret = this._roomName; /* */ } /* 232 */ else if (mode == 4) { /* 233 */ this._roomName = null; /* 234 */ } else if (mode == 2) { /* 235 */ this._roomName = ((String)value); /* 236 */ this._target = null; /* */ } /* 238 */ break; /* */ case 2: /* 240 */ if (mode == 0) { /* 241 */ Property p = new Property(this, index, "Target Name"); /* 242 */ p.allowSetNull(); /* 243 */ ret = StringPropertyEditor.make(p); /* 244 */ } else if (mode == 1) { /* 245 */ ret = this._targetName; /* */ } /* 247 */ else if (mode == 4) { /* 248 */ this._targetName = null; /* 249 */ } else if (mode == 2) { /* 250 */ this._targetName = ((String)value); /* 251 */ this._target = null; /* */ } /* 253 */ break; /* */ case 3: /* 255 */ if (mode == 0) /* */ { /* */ /* 258 */ ret = new Property(this, index, "Property Name"); /* 259 */ if (getTarget() != null) { /* 260 */ ret = PropPropEditor.make((Property)ret, getTarget(), true); /* */ } /* 262 */ } else if (mode == 1) { /* 263 */ SuperRoot t = getTarget(); /* 264 */ if (((this._propIndex = index(this._propIndex, this._propName, t)) == -1) || /* 265 */ (t == null)) { /* 266 */ ret = null; /* */ } else { /* 268 */ ret = enumerate(); /* */ } /* 270 */ } else if (mode == 2) { /* 271 */ if (value == null) { /* 272 */ this._propIndex = -1; /* 273 */ this._propName = null; /* 274 */ } else if ((value instanceof String)) { /* 275 */ this._propIndex = -1; /* 276 */ this._propName = ((String)value); /* */ } else { /* 278 */ this._propIndex = ((Property)value).getIndex(); /* 279 */ this._propName = ((Property)value).getName(); /* */ } /* */ } /* 282 */ break; /* */ case 4: /* 284 */ if (mode == 0) { /* 285 */ ret = BooleanPropertyEditor.make(new Property(this, index, /* 286 */ "Use parameter"), /* 287 */ "Use 'Set To' value", /* 288 */ "Use parameter"); /* */ } /* 290 */ else if (mode == 1) { /* 291 */ ret = new Boolean(this._paramName != null); /* */ } /* 293 */ else if (mode == 2) { /* 294 */ if (((Boolean)value).booleanValue()) { /* 295 */ if (this._paramName == null) { /* 296 */ this._paramName = ""; /* */ } /* */ } else { /* 299 */ this._paramName = null; /* */ } /* */ } /* 302 */ break; /* */ case 5: /* 304 */ if (mode == 0) { /* 305 */ ret = new Property(this, index, "Parameter Name"); /* 306 */ if (this._paramName != null) { /* 307 */ ret = StringPropertyEditor.make((Property)ret); /* */ } /* 309 */ } else if (mode == 1) { /* 310 */ ret = this._paramName == null ? "" : this._paramName; /* */ } /* 312 */ else if (mode == 2) { /* 313 */ this._paramName = ((String)value); /* */ } /* 315 */ break; /* */ default: /* 317 */ ret = super.properties(index, offset + 6, mode, value); /* */ } /* 319 */ return ret; /* */ } /* */ /* 322 */ private static Object classCookie = new Object(); /* */ /* */ public void saveState(Saver s) throws IOException /* */ { /* 326 */ s.saveVersion(4, classCookie); /* 327 */ super.saveState(s); /* 328 */ s.saveMaybeNull(getTarget()); /* 329 */ s.saveString(this._roomName); /* 330 */ s.saveString(this._targetName); /* 331 */ s.saveString(this._propName); /* 332 */ s.saveString(this._paramName); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ protected void setPropertyActionRestoreState(Restorer r) /* */ throws IOException, TooNewException /* */ { /* 342 */ switch (r.restoreVersion(classCookie)) { /* */ case 4: /* 344 */ super.restoreState(r); /* 345 */ this._target = ((SuperRoot)r.restoreMaybeNull()); /* 346 */ this._roomName = r.restoreString(); /* 347 */ this._targetName = r.restoreString(); /* 348 */ this._propName = r.restoreString(); /* 349 */ this._paramName = r.restoreString(); /* 350 */ break; /* */ /* */ case 3: /* 353 */ super.restoreState(r); /* 354 */ this._target = ((SuperRoot)r.restoreMaybeNull()); /* 355 */ this._propName = r.restoreString(); /* 356 */ this._paramName = r.restoreString(); /* 357 */ break; /* */ /* */ case 2: /* 360 */ super.restoreState(r); /* 361 */ this._target = ((SuperRoot)r.restoreMaybeNull()); /* 362 */ this._propName = r.restoreString(); /* 363 */ break; /* */ /* */ case 1: /* 366 */ super.restoreState(r); /* 367 */ this._target = ((SuperRoot)r.restore()); /* 368 */ this._propName = r.restoreString(); /* 369 */ break; /* */ default: /* 371 */ throw new TooNewException(); /* */ } /* */ } /* */ /* */ public void restoreState(Restorer r) throws IOException, TooNewException /* */ { /* 377 */ setPropertyActionRestoreState(r); /* */ } /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\SetPropertyAction.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */