001package Torello.Browser; 002 003import java.util.*; 004import javax.json.*; 005import javax.json.stream.*; 006import java.io.*; 007 008import java.lang.reflect.Method; 009import java.lang.reflect.Parameter; 010import java.util.function.Function; 011 012import Torello.Java.Additional.*; 013import Torello.Java.JSON.*; 014 015import static Torello.Java.JSON.JFlag.*; 016 017import Torello.Java.StrCmpr; 018import Torello.JavaDoc.StaticFunctional; 019import Torello.JavaDoc.JDHeaderBackgroundImg; 020import Torello.JavaDoc.Excuse; 021 022/** 023 * <SPAN CLASS=COPIEDJDK><B>Query and modify DOM storage.</B></SPAN> 024 * 025 * <EMBED CLASS='external-html' DATA-FILE-ID=CODE_GEN_NOTE> 026 */ 027@StaticFunctional(Excused={"counter"}, Excuses={Excuse.CONFIGURATION}) 028@JDHeaderBackgroundImg(EmbedTagFileID="WOOD_PLANK_NOTE") 029public class DOMStorage 030{ 031 // ******************************************************************************************** 032 // ******************************************************************************************** 033 // Class Header Stuff 034 // ******************************************************************************************** 035 // ******************************************************************************************** 036 037 038 // No Pubic Constructors 039 private DOMStorage () { } 040 041 // These two Vector's are used by all the "Methods" exported by this class. java.lang.reflect 042 // is used to generate the JSON String's. It saves thousands of lines of Auto-Generated Code. 043 private static final Map<String, Vector<String>> parameterNames = new HashMap<>(); 044 private static final Map<String, Vector<Class<?>>> parameterTypes = new HashMap<>(); 045 046 // Some Methods do not take any parameters - for instance all the "enable()" and "disable()" 047 // I simply could not get ride of RAW-TYPES and UNCHECKED warnings... so there are now, 048 // offically, two empty-vectors. One for String's, and the other for Classes. 049 050 private static final Vector<String> EMPTY_VEC_STR = new Vector<>(); 051 private static final Vector<Class<?>> EMPTY_VEC_CLASS = new Vector<>(); 052 053 static 054 { 055 for (Method m : DOMStorage.class.getMethods()) 056 { 057 // This doesn't work! The parameter names are all "arg0" ... "argN" 058 // It works for java.lang.reflect.Field, BUT NOT java.lang.reflect.Parameter! 059 // 060 // Vector<String> parameterNamesList = new Vector<>(); -- NOPE! 061 062 Vector<Class<?>> parameterTypesList = new Vector<>(); 063 064 for (Parameter p : m.getParameters()) parameterTypesList.add(p.getType()); 065 066 parameterTypes.put( 067 m.getName(), 068 (parameterTypesList.size() > 0) ? parameterTypesList : EMPTY_VEC_CLASS 069 ); 070 } 071 } 072 073 static 074 { 075 Vector<String> v = null; 076 077 v = new Vector<String>(1); 078 parameterNames.put("clear", v); 079 Collections.addAll(v, new String[] 080 { "storageId", }); 081 082 parameterNames.put("disable", EMPTY_VEC_STR); 083 084 parameterNames.put("enable", EMPTY_VEC_STR); 085 086 v = new Vector<String>(1); 087 parameterNames.put("getDOMStorageItems", v); 088 Collections.addAll(v, new String[] 089 { "storageId", }); 090 091 v = new Vector<String>(2); 092 parameterNames.put("removeDOMStorageItem", v); 093 Collections.addAll(v, new String[] 094 { "storageId", "key", }); 095 096 v = new Vector<String>(3); 097 parameterNames.put("setDOMStorageItem", v); 098 Collections.addAll(v, new String[] 099 { "storageId", "key", "value", }); 100 } 101 102 103 // ******************************************************************************************** 104 // ******************************************************************************************** 105 // Types - Static Inner Classes 106 // ******************************************************************************************** 107 // ******************************************************************************************** 108 109 // public static class Item => String[] 110 111 /** DOM Storage identifier. */ 112 public static class StorageId 113 extends BaseType 114 implements java.io.Serializable 115 { 116 /** For Object Serialization. java.io.Serializable */ 117 protected static final long serialVersionUID = 1; 118 119 public boolean[] optionals() 120 { return new boolean[] { false, false, }; } 121 122 /** Security origin for the storage. */ 123 public final String securityOrigin; 124 125 /** Whether the storage is local storage (not session storage). */ 126 public final boolean isLocalStorage; 127 128 /** 129 * Constructor 130 * 131 * @param securityOrigin Security origin for the storage. 132 * 133 * @param isLocalStorage Whether the storage is local storage (not session storage). 134 */ 135 public StorageId(String securityOrigin, boolean isLocalStorage) 136 { 137 // Exception-Check(s) to ensure that if any parameters which are not declared as 138 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 139 140 if (securityOrigin == null) BRDPC.throwNPE("securityOrigin"); 141 142 this.securityOrigin = securityOrigin; 143 this.isLocalStorage = isLocalStorage; 144 } 145 146 /** 147 * JSON Object Constructor 148 * @param jo A Json-Object having data about an instance of {@code 'StorageId'}. 149 */ 150 public StorageId (JsonObject jo) 151 { 152 this.securityOrigin = ReadJSON.getString(jo, "securityOrigin", false, true); 153 this.isLocalStorage = ReadPrimJSON.getBoolean(jo, "isLocalStorage"); 154 } 155 156 157 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 158 public boolean equals(Object other) 159 { 160 if (other == null) return false; 161 if (other.getClass() != this.getClass()) return false; 162 163 StorageId o = (StorageId) other; 164 165 return 166 Objects.equals(this.securityOrigin, o.securityOrigin) 167 && (this.isLocalStorage == o.isLocalStorage); 168 } 169 170 /** Generates a Hash-Code for {@code 'this'} instance */ 171 public int hashCode() 172 { 173 return 174 Objects.hashCode(this.securityOrigin) 175 + (this.isLocalStorage ? 1 : 0); 176 } 177 } 178 179 /** <CODE>[No Description Provided by Google]</CODE> */ 180 public static class domStorageItemAdded 181 extends BrowserEvent 182 implements java.io.Serializable 183 { 184 /** For Object Serialization. java.io.Serializable */ 185 protected static final long serialVersionUID = 1; 186 187 public boolean[] optionals() 188 { return new boolean[] { false, false, false, }; } 189 190 /** <CODE>[No Description Provided by Google]</CODE> */ 191 public final DOMStorage.StorageId storageId; 192 193 /** <CODE>[No Description Provided by Google]</CODE> */ 194 public final String key; 195 196 /** <CODE>[No Description Provided by Google]</CODE> */ 197 public final String newValue; 198 199 /** 200 * Constructor 201 * 202 * @param storageId - 203 * 204 * @param key - 205 * 206 * @param newValue - 207 */ 208 public domStorageItemAdded(DOMStorage.StorageId storageId, String key, String newValue) 209 { 210 super("DOMStorage", "domStorageItemAdded", 3); 211 212 // Exception-Check(s) to ensure that if any parameters which are not declared as 213 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 214 215 if (storageId == null) BRDPC.throwNPE("storageId"); 216 if (key == null) BRDPC.throwNPE("key"); 217 if (newValue == null) BRDPC.throwNPE("newValue"); 218 219 this.storageId = storageId; 220 this.key = key; 221 this.newValue = newValue; 222 } 223 224 /** 225 * JSON Object Constructor 226 * @param jo A Json-Object having data about an instance of {@code 'domStorageItemAdded'}. 227 */ 228 public domStorageItemAdded (JsonObject jo) 229 { 230 super("DOMStorage", "domStorageItemAdded", 3); 231 232 this.storageId = ReadJSON.getObject(jo, "storageId", DOMStorage.StorageId.class, false, true); 233 this.key = ReadJSON.getString(jo, "key", false, true); 234 this.newValue = ReadJSON.getString(jo, "newValue", false, true); 235 } 236 237 238 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 239 public boolean equals(Object other) 240 { 241 if (other == null) return false; 242 if (other.getClass() != this.getClass()) return false; 243 244 domStorageItemAdded o = (domStorageItemAdded) other; 245 246 return 247 Objects.equals(this.storageId, o.storageId) 248 && Objects.equals(this.key, o.key) 249 && Objects.equals(this.newValue, o.newValue); 250 } 251 252 /** Generates a Hash-Code for {@code 'this'} instance */ 253 public int hashCode() 254 { 255 return 256 this.storageId.hashCode() 257 + Objects.hashCode(this.key) 258 + Objects.hashCode(this.newValue); 259 } 260 } 261 262 /** <CODE>[No Description Provided by Google]</CODE> */ 263 public static class domStorageItemRemoved 264 extends BrowserEvent 265 implements java.io.Serializable 266 { 267 /** For Object Serialization. java.io.Serializable */ 268 protected static final long serialVersionUID = 1; 269 270 public boolean[] optionals() 271 { return new boolean[] { false, false, }; } 272 273 /** <CODE>[No Description Provided by Google]</CODE> */ 274 public final DOMStorage.StorageId storageId; 275 276 /** <CODE>[No Description Provided by Google]</CODE> */ 277 public final String key; 278 279 /** 280 * Constructor 281 * 282 * @param storageId - 283 * 284 * @param key - 285 */ 286 public domStorageItemRemoved(DOMStorage.StorageId storageId, String key) 287 { 288 super("DOMStorage", "domStorageItemRemoved", 2); 289 290 // Exception-Check(s) to ensure that if any parameters which are not declared as 291 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 292 293 if (storageId == null) BRDPC.throwNPE("storageId"); 294 if (key == null) BRDPC.throwNPE("key"); 295 296 this.storageId = storageId; 297 this.key = key; 298 } 299 300 /** 301 * JSON Object Constructor 302 * @param jo A Json-Object having data about an instance of {@code 'domStorageItemRemoved'}. 303 */ 304 public domStorageItemRemoved (JsonObject jo) 305 { 306 super("DOMStorage", "domStorageItemRemoved", 2); 307 308 this.storageId = ReadJSON.getObject(jo, "storageId", DOMStorage.StorageId.class, false, true); 309 this.key = ReadJSON.getString(jo, "key", false, true); 310 } 311 312 313 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 314 public boolean equals(Object other) 315 { 316 if (other == null) return false; 317 if (other.getClass() != this.getClass()) return false; 318 319 domStorageItemRemoved o = (domStorageItemRemoved) other; 320 321 return 322 Objects.equals(this.storageId, o.storageId) 323 && Objects.equals(this.key, o.key); 324 } 325 326 /** Generates a Hash-Code for {@code 'this'} instance */ 327 public int hashCode() 328 { 329 return 330 this.storageId.hashCode() 331 + Objects.hashCode(this.key); 332 } 333 } 334 335 /** <CODE>[No Description Provided by Google]</CODE> */ 336 public static class domStorageItemUpdated 337 extends BrowserEvent 338 implements java.io.Serializable 339 { 340 /** For Object Serialization. java.io.Serializable */ 341 protected static final long serialVersionUID = 1; 342 343 public boolean[] optionals() 344 { return new boolean[] { false, false, false, false, }; } 345 346 /** <CODE>[No Description Provided by Google]</CODE> */ 347 public final DOMStorage.StorageId storageId; 348 349 /** <CODE>[No Description Provided by Google]</CODE> */ 350 public final String key; 351 352 /** <CODE>[No Description Provided by Google]</CODE> */ 353 public final String oldValue; 354 355 /** <CODE>[No Description Provided by Google]</CODE> */ 356 public final String newValue; 357 358 /** 359 * Constructor 360 * 361 * @param storageId - 362 * 363 * @param key - 364 * 365 * @param oldValue - 366 * 367 * @param newValue - 368 */ 369 public domStorageItemUpdated 370 (DOMStorage.StorageId storageId, String key, String oldValue, String newValue) 371 { 372 super("DOMStorage", "domStorageItemUpdated", 4); 373 374 // Exception-Check(s) to ensure that if any parameters which are not declared as 375 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 376 377 if (storageId == null) BRDPC.throwNPE("storageId"); 378 if (key == null) BRDPC.throwNPE("key"); 379 if (oldValue == null) BRDPC.throwNPE("oldValue"); 380 if (newValue == null) BRDPC.throwNPE("newValue"); 381 382 this.storageId = storageId; 383 this.key = key; 384 this.oldValue = oldValue; 385 this.newValue = newValue; 386 } 387 388 /** 389 * JSON Object Constructor 390 * @param jo A Json-Object having data about an instance of {@code 'domStorageItemUpdated'}. 391 */ 392 public domStorageItemUpdated (JsonObject jo) 393 { 394 super("DOMStorage", "domStorageItemUpdated", 4); 395 396 this.storageId = ReadJSON.getObject(jo, "storageId", DOMStorage.StorageId.class, false, true); 397 this.key = ReadJSON.getString(jo, "key", false, true); 398 this.oldValue = ReadJSON.getString(jo, "oldValue", false, true); 399 this.newValue = ReadJSON.getString(jo, "newValue", false, true); 400 } 401 402 403 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 404 public boolean equals(Object other) 405 { 406 if (other == null) return false; 407 if (other.getClass() != this.getClass()) return false; 408 409 domStorageItemUpdated o = (domStorageItemUpdated) other; 410 411 return 412 Objects.equals(this.storageId, o.storageId) 413 && Objects.equals(this.key, o.key) 414 && Objects.equals(this.oldValue, o.oldValue) 415 && Objects.equals(this.newValue, o.newValue); 416 } 417 418 /** Generates a Hash-Code for {@code 'this'} instance */ 419 public int hashCode() 420 { 421 return 422 this.storageId.hashCode() 423 + Objects.hashCode(this.key) 424 + Objects.hashCode(this.oldValue) 425 + Objects.hashCode(this.newValue); 426 } 427 } 428 429 /** <CODE>[No Description Provided by Google]</CODE> */ 430 public static class domStorageItemsCleared 431 extends BrowserEvent 432 implements java.io.Serializable 433 { 434 /** For Object Serialization. java.io.Serializable */ 435 protected static final long serialVersionUID = 1; 436 437 public boolean[] optionals() 438 { return new boolean[] { false, }; } 439 440 /** <CODE>[No Description Provided by Google]</CODE> */ 441 public final DOMStorage.StorageId storageId; 442 443 /** 444 * Constructor 445 * 446 * @param storageId - 447 */ 448 public domStorageItemsCleared(DOMStorage.StorageId storageId) 449 { 450 super("DOMStorage", "domStorageItemsCleared", 1); 451 452 // Exception-Check(s) to ensure that if any parameters which are not declared as 453 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 454 455 if (storageId == null) BRDPC.throwNPE("storageId"); 456 457 this.storageId = storageId; 458 } 459 460 /** 461 * JSON Object Constructor 462 * @param jo A Json-Object having data about an instance of {@code 'domStorageItemsCleared'}. 463 */ 464 public domStorageItemsCleared (JsonObject jo) 465 { 466 super("DOMStorage", "domStorageItemsCleared", 1); 467 468 this.storageId = ReadJSON.getObject(jo, "storageId", DOMStorage.StorageId.class, false, true); 469 } 470 471 472 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 473 public boolean equals(Object other) 474 { 475 if (other == null) return false; 476 if (other.getClass() != this.getClass()) return false; 477 478 domStorageItemsCleared o = (domStorageItemsCleared) other; 479 480 return 481 Objects.equals(this.storageId, o.storageId); 482 } 483 484 /** Generates a Hash-Code for {@code 'this'} instance */ 485 public int hashCode() 486 { 487 return 488 this.storageId.hashCode(); 489 } 490 } 491 492 493 // Counter for keeping the WebSocket Request ID's distinct. 494 private static int counter = 1; 495 496 /** 497 * <CODE>[No Description Provided by Google]</CODE> 498 * 499 * @param storageId - 500 * 501 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 502 * {@link Ret0}></CODE> 503 * 504 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 505 * browser receives the invocation-request. 506 * 507 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 508 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 509 * {@code >} to ensure the Browser Function has run to completion. 510 */ 511 public static Script<String, JsonObject, Ret0> clear(DOMStorage.StorageId storageId) 512 { 513 // Exception-Check(s) to ensure that if any parameters which are not declared as 514 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 515 516 if (storageId == null) BRDPC.throwNPE("storageId"); 517 518 final int webSocketID = 18000000 + counter++; 519 final boolean[] optionals = { false, }; 520 521 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 522 String requestJSON = WriteJSON.get( 523 parameterTypes.get("clear"), 524 parameterNames.get("clear"), 525 optionals, webSocketID, 526 "DOMStorage.clear", 527 storageId 528 ); 529 530 // This Remote Command does not have a Return-Value. 531 return new Script<> 532 (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues); 533 } 534 535 /** 536 * Disables storage tracking, prevents storage events from being sent to the client. 537 * 538 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 539 * {@link Ret0}></CODE> 540 * 541 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 542 * browser receives the invocation-request. 543 * 544 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 545 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 546 * {@code >} to ensure the Browser Function has run to completion. 547 */ 548 public static Script<String, JsonObject, Ret0> disable() 549 { 550 final int webSocketID = 18001000 + counter++; 551 final boolean[] optionals = new boolean[0]; 552 553 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 554 String requestJSON = WriteJSON.get( 555 parameterTypes.get("disable"), 556 parameterNames.get("disable"), 557 optionals, webSocketID, 558 "DOMStorage.disable" 559 ); 560 561 // This Remote Command does not have a Return-Value. 562 return new Script<> 563 (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues); 564 } 565 566 /** 567 * Enables storage tracking, storage events will now be delivered to the client. 568 * 569 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 570 * {@link Ret0}></CODE> 571 * 572 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 573 * browser receives the invocation-request. 574 * 575 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 576 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 577 * {@code >} to ensure the Browser Function has run to completion. 578 */ 579 public static Script<String, JsonObject, Ret0> enable() 580 { 581 final int webSocketID = 18002000 + counter++; 582 final boolean[] optionals = new boolean[0]; 583 584 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 585 String requestJSON = WriteJSON.get( 586 parameterTypes.get("enable"), 587 parameterNames.get("enable"), 588 optionals, webSocketID, 589 "DOMStorage.enable" 590 ); 591 592 // This Remote Command does not have a Return-Value. 593 return new Script<> 594 (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues); 595 } 596 597 /** 598 * <CODE>[No Description Provided by Google]</CODE> 599 * 600 * @param storageId - 601 * 602 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 603 * String[][]></CODE> 604 * 605 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 606 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 607 * String[][]></CODE> will be returned. 608 * 609 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 610 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 611 * may be retrieved.</I> 612 * 613 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 614 * <BR /><BR /><UL CLASS=JDUL> 615 * <LI><CODE>String[][] (<B>entries</B></CODE>) 616 * <BR />- 617 * </LI> 618 * </UL> */ 619 public static Script<String, JsonObject, String[][]> getDOMStorageItems 620 (DOMStorage.StorageId storageId) 621 { 622 // Exception-Check(s) to ensure that if any parameters which are not declared as 623 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 624 625 if (storageId == null) BRDPC.throwNPE("storageId"); 626 627 final int webSocketID = 18003000 + counter++; 628 final boolean[] optionals = { false, }; 629 630 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 631 String requestJSON = WriteJSON.get( 632 parameterTypes.get("getDOMStorageItems"), 633 parameterNames.get("getDOMStorageItems"), 634 optionals, webSocketID, 635 "DOMStorage.getDOMStorageItems", 636 storageId 637 ); 638 639 // 'JSON Binding' ... Converts Browser Response-JSON to 'String[][]' 640 Function<JsonObject, String[][]> responseProcessor = (JsonObject jo) -> 641 (jo.getJsonArray("entries") == null) 642 ? null 643 : RJArrDimN.strArr(jo.getJsonArray("entries"), null, 0, String[][].class); 644 645 // Pass the 'defaultSender' to Script-Constructor 646 // The sender that is used can be changed before executing script. 647 return new Script<>(BRDPC.defaultSender, webSocketID, requestJSON, responseProcessor); 648 } 649 650 /** 651 * <CODE>[No Description Provided by Google]</CODE> 652 * 653 * @param storageId - 654 * 655 * @param key - 656 * 657 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 658 * {@link Ret0}></CODE> 659 * 660 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 661 * browser receives the invocation-request. 662 * 663 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 664 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 665 * {@code >} to ensure the Browser Function has run to completion. 666 */ 667 public static Script<String, JsonObject, Ret0> removeDOMStorageItem 668 (DOMStorage.StorageId storageId, String key) 669 { 670 // Exception-Check(s) to ensure that if any parameters which are not declared as 671 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 672 673 if (storageId == null) BRDPC.throwNPE("storageId"); 674 if (key == null) BRDPC.throwNPE("key"); 675 676 final int webSocketID = 18004000 + counter++; 677 final boolean[] optionals = { false, false, }; 678 679 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 680 String requestJSON = WriteJSON.get( 681 parameterTypes.get("removeDOMStorageItem"), 682 parameterNames.get("removeDOMStorageItem"), 683 optionals, webSocketID, 684 "DOMStorage.removeDOMStorageItem", 685 storageId, key 686 ); 687 688 // This Remote Command does not have a Return-Value. 689 return new Script<> 690 (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues); 691 } 692 693 /** 694 * <CODE>[No Description Provided by Google]</CODE> 695 * 696 * @param storageId - 697 * 698 * @param key - 699 * 700 * @param value - 701 * 702 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 703 * {@link Ret0}></CODE> 704 * 705 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 706 * browser receives the invocation-request. 707 * 708 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 709 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 710 * {@code >} to ensure the Browser Function has run to completion. 711 */ 712 public static Script<String, JsonObject, Ret0> setDOMStorageItem 713 (DOMStorage.StorageId storageId, String key, String value) 714 { 715 // Exception-Check(s) to ensure that if any parameters which are not declared as 716 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 717 718 if (storageId == null) BRDPC.throwNPE("storageId"); 719 if (key == null) BRDPC.throwNPE("key"); 720 if (value == null) BRDPC.throwNPE("value"); 721 722 final int webSocketID = 18005000 + counter++; 723 final boolean[] optionals = { false, false, false, }; 724 725 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 726 String requestJSON = WriteJSON.get( 727 parameterTypes.get("setDOMStorageItem"), 728 parameterNames.get("setDOMStorageItem"), 729 optionals, webSocketID, 730 "DOMStorage.setDOMStorageItem", 731 storageId, key, value 732 ); 733 734 // This Remote Command does not have a Return-Value. 735 return new Script<> 736 (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues); 737 } 738 739}