1 55 56 package org.apache.bsf.debug.meta; 57 58 import java.rmi.RemoteException ; 59 import java.io.*; 60 import java.net.*; 61 62 import org.apache.bsf.debug.jsdi.*; 63 import org.apache.bsf.debug.util.*; 64 65 public class JsObjectStub extends Stub implements JsObject { 66 public JsObjectStub( 67 SocketConnection con, 68 int tid, 69 int uid) { 70 super(con,tid, uid); 71 } 72 73 78 public boolean isNotFound() { 79 return this == Stub.NOT_FOUND; 80 } 81 82 85 public boolean isUndefined() { 86 return this == Stub.UNDEFINED; 87 } 88 89 97 public void define(String propertyName, Object value, int attributes) 98 throws RemoteException { 99 ResultCell cell; 100 try { 101 cell = m_con.prepareOutgoingInvoke(this,DebugConstants.JS_OBJECT_TID,DebugConstants.JO_DEFINE); 102 cell.writeObject(propertyName); 103 cell.writeObject(value); 104 cell.writeInt(attributes); 105 106 cell.waitForCompletion(); 107 } catch (Exception ex) { 108 throw new RemoteException ("Marshalling error", ex); 109 } 110 } 111 140 public void delete(int index) throws RemoteException { 141 ResultCell cell; 142 143 try { 144 cell = m_con.prepareOutgoingInvoke(this,DebugConstants.JS_OBJECT_TID,DebugConstants.JO_DELETE_BY_INDEX); 145 cell.writeInt(index); 146 147 cell.waitForCompletion(); 148 149 } catch (Exception ex) { 150 throw new RemoteException ("Marshalling error", ex); 151 } 152 } 153 175 public void delete(String name) throws RemoteException { 176 ResultCell cell; 177 178 try { 179 cell = m_con.prepareOutgoingInvoke(this,DebugConstants.JS_OBJECT_TID,DebugConstants.JO_DELETE_BY_NAME); 180 cell.writeObject(name); 181 182 cell.waitForCompletion(); 183 184 } catch (Exception ex) { 185 throw new RemoteException ("Marshalling error", ex); 186 } 187 } 188 189 226 public Object get(String name) throws RemoteException { 227 ResultCell cell; 228 229 try { 230 cell = m_con.prepareOutgoingInvoke(this,DebugConstants.JS_OBJECT_TID,DebugConstants.JO_GET_BY_NAME); 231 cell.writeObject(name); 232 233 return cell.waitForObject(); 234 235 } catch (IOException ex) { 236 throw new RemoteException ("Marshalling error", ex); 237 } catch (Exception ex) { 238 throw new RemoteException ("Error at server", ex); 239 } 240 } 241 public Object get(int index) throws RemoteException { 242 ResultCell cell; 243 try { 244 cell= m_con.prepareOutgoingInvoke(this,DebugConstants.JS_OBJECT_TID,DebugConstants.JO_GET_BY_INDEX); 245 cell.writeInt(index); 246 247 return cell.waitForObject(); 248 249 } catch (IOException ex) { 250 throw new RemoteException ("Marshalling error", ex); 251 } catch (Exception ex) { 252 throw new RemoteException ("Error at server", ex); 253 } 254 } 255 256 262 public String getClassName() throws RemoteException { 263 ResultCell cell; 264 try { 265 cell = m_con.prepareOutgoingInvoke(this,DebugConstants.JS_OBJECT_TID,DebugConstants.JO_GET_CLASSNAME); 266 return (String ) cell.waitForValueObject(); 267 } catch (IOException ex) { 268 throw new RemoteException ("Marshalling error", ex); 269 } catch (Exception ex) { 270 throw new RemoteException ("Error at server", ex); 271 } 272 } 273 274 287 public Object getDefaultValue(Class hint) throws RemoteException { 288 ResultCell cell; 289 try { 290 cell= m_con.prepareOutgoingInvoke(this,DebugConstants.JS_OBJECT_TID,DebugConstants.JO_GET_DEFAULT_VALUE); 291 cell.writeObject(hint.getName()); 292 293 return (JsObject) cell.waitForObject(); 294 295 } catch (IOException ex) { 296 throw new RemoteException ("Marshalling error", ex); 297 } catch (Exception ex) { 298 throw new RemoteException ("Error at server", ex); 299 } 300 } 301 302 318 public Object [] getIds(boolean all) throws RemoteException { 319 ResultCell cell; 320 try { 321 cell = m_con.prepareOutgoingInvoke(this,DebugConstants.JS_OBJECT_TID,DebugConstants.JO_GET_IDS); 322 cell.writeBoolean(all); 323 324 return (Object []) cell.waitForValueObject(); 325 326 } catch (IOException ex) { 327 throw new RemoteException ("Marshalling error", ex); 328 } catch (Exception ex) { 329 throw new RemoteException ("Error at server", ex); 330 } 331 } 332 333 337 public JsObject getPrototype() throws RemoteException { 338 ResultCell cell; 339 try { 340 cell = m_con.prepareOutgoingInvoke(this,DebugConstants.JS_OBJECT_TID,DebugConstants.JO_GET_PROTOTYPE); 341 return (JsObject) cell.waitForObject(); 342 } catch (IOException ex) { 343 throw new RemoteException ("Marshalling error", ex); 344 } catch (Exception ex) { 345 throw new RemoteException ("Error at server", ex); 346 } 347 } 348 349 359 public JsObject getScope() throws RemoteException { 360 ResultCell cell; 361 try { 362 cell = m_con.prepareOutgoingInvoke(this,DebugConstants.JS_OBJECT_TID,DebugConstants.JO_GET_SCOPE); 363 return (JsObject) cell.waitForObject(); 364 365 } catch (IOException ex) { 366 throw new RemoteException ("Marshalling error", ex); 367 } catch (Exception ex) { 368 throw new RemoteException ("Error at server", ex); 369 } 370 } 371 372 384 public boolean has(int index) throws RemoteException { 385 ResultCell cell; 386 try { 387 cell = m_con.prepareOutgoingInvoke(this,DebugConstants.JS_OBJECT_TID,DebugConstants.JO_HAS_BY_INDEX); 388 cell.writeInt(index); 389 return cell.waitForBooleanValue(); 390 } catch (IOException ex) { 391 throw new RemoteException ("Marshalling error", ex); 392 } catch (Exception ex) { 393 throw new RemoteException ("Error at server", ex); 394 } 395 } 396 397 409 public boolean has(String name) throws RemoteException { 410 ResultCell cell; 411 try { 412 cell = m_con.prepareOutgoingInvoke(this,DebugConstants.JS_OBJECT_TID,DebugConstants.JO_HAS_BY_NAME); 413 cell.writeObject(name); 414 415 return cell.waitForBooleanValue(); 416 417 } catch (IOException ex) { 418 throw new RemoteException ("Marshalling error", ex); 419 } catch (Exception ex) { 420 throw new RemoteException ("Error at server", ex); 421 } 422 } 423 424 443 public boolean hasInstance(JsObject instance) throws RemoteException { 444 ResultCell cell; 445 JsObjectStub stub = (JsObjectStub) instance; 446 try { 447 cell = m_con.prepareOutgoingInvoke(this,DebugConstants.JS_OBJECT_TID,DebugConstants.JO_HAS_INSTANCE); 448 cell.writeObject(stub); 449 return cell.waitForBooleanValue(); 450 451 } catch (IOException ex) { 452 throw new RemoteException ("Marshalling error", ex); 453 } catch (Exception ex) { 454 throw new RemoteException ("Error at server", ex); 455 } 456 } 457 public boolean isA(int cmd) throws RemoteException { 458 ResultCell cell; 459 try { 460 cell = m_con.prepareOutgoingInvoke(this,DebugConstants.JS_OBJECT_TID,cmd); 461 return cell.waitForBooleanValue(); 462 463 } catch (IOException ex) { 464 throw new RemoteException ("Marshalling error", ex); 465 } catch (Exception ex) { 466 throw new RemoteException ("Error at server", ex); 467 } 468 } 469 public boolean isFunction() throws RemoteException { 470 return isA(DebugConstants.JO_FUNCTION); 471 } 472 public boolean isScript() throws RemoteException { 473 return isA(DebugConstants.JO_SCRIPT); 474 } 475 476 485 public void put(int index, Object value) throws RemoteException { 486 ResultCell cell; 487 try { 488 cell = m_con.prepareOutgoingInvoke(this,DebugConstants.JS_OBJECT_TID,DebugConstants.JO_PUT_BY_INDEX); 489 cell.writeInt(index); 490 cell.writeObject(value); 491 492 cell.waitForCompletion(); 493 494 } catch (IOException ex) { 495 throw new RemoteException ("Marshalling error", ex); 496 } catch (Exception ex) { 497 throw new RemoteException ("Error at server", ex); 498 } 499 } 500 501 530 public void put(String name, Object value) throws RemoteException { 531 ResultCell cell; 532 try { 533 cell = m_con.prepareOutgoingInvoke(this,DebugConstants.JS_OBJECT_TID,DebugConstants.JO_PUT_BY_NAME); 534 cell.writeObject(name); 535 cell.writeObject(value); 536 537 cell.waitForCompletion(); 538 } catch (IOException ex) { 539 throw new RemoteException ("Marshalling error", ex); 540 } catch (Exception ex) { 541 throw new RemoteException ("Error at server", ex); 542 } 543 } 544 545 549 public void setPrototype(JsObject prototype) throws RemoteException { 550 ResultCell cell; 551 try { 552 cell = m_con.prepareOutgoingInvoke(this,DebugConstants.JS_OBJECT_TID,DebugConstants.JO_SET_PROTOTYPE); 553 cell.writeObject(prototype); 554 cell.waitForCompletion(); 555 556 } catch (IOException ex) { 557 throw new RemoteException ("Marshalling error", ex); 558 } catch (Exception ex) { 559 throw new RemoteException ("Error at server", ex); 560 } 561 } 562 563 567 public void setScope(JsObject scope) throws RemoteException { 568 ResultCell cell; 569 try { 570 cell = m_con.prepareOutgoingInvoke(this,DebugConstants.JS_OBJECT_TID,DebugConstants.JO_SET_SCOPE); 571 cell.writeObject(scope); 572 cell.waitForCompletion(); 573 574 } catch (IOException ex) { 575 throw new RemoteException ("Marshalling error", ex); 576 } catch (Exception ex) { 577 throw new RemoteException ("Error at server", ex); 578 } 579 } 580 } 581 | Popular Tags |