001package Torello.Browser.BrowserAPI; 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.Browser.BrowserEvent; 013import Torello.Browser.JavaScriptAPI.*; 014import Torello.Browser.helper.*; 015 016import Torello.Java.Additional.*; 017import Torello.Java.JSON.*; 018 019import static Torello.Java.JSON.JFlag.*; 020 021import Torello.Java.StrCmpr; 022import Torello.JavaDoc.StaticFunctional; 023import Torello.JavaDoc.JDHeaderBackgroundImg; 024import Torello.JavaDoc.Excuse; 025 026/** 027 * <SPAN CLASS=COPIEDJDK><B><CODE>[No Description Provided by Google]</CODE></B></SPAN> 028 * 029 * <EMBED CLASS='external-html' DATA-FILE-ID=CODE_GEN_NOTE> 030 */ 031@StaticFunctional(Excused={"counter"}, Excuses={Excuse.CONFIGURATION}) 032@JDHeaderBackgroundImg(EmbedTagFileID="WOOD_PLANK_NOTE") 033public class ServiceWorker 034{ 035 // ******************************************************************************************** 036 // ******************************************************************************************** 037 // Class Header Stuff 038 // ******************************************************************************************** 039 // ******************************************************************************************** 040 041 042 // No Pubic Constructors 043 private ServiceWorker () { } 044 045 // These two Vector's are used by all the "Methods" exported by this class. java.lang.reflect 046 // is used to generate the JSON String's. It saves thousands of lines of Auto-Generated Code. 047 private static final Map<String, Vector<String>> parameterNames = new HashMap<>(); 048 private static final Map<String, Vector<Class<?>>> parameterTypes = new HashMap<>(); 049 050 // Some Methods do not take any parameters - for instance all the "enable()" and "disable()" 051 // I simply could not get ride of RAW-TYPES and UNCHECKED warnings... so there are now, 052 // offically, two empty-vectors. One for String's, and the other for Classes. 053 054 private static final Vector<String> EMPTY_VEC_STR = new Vector<>(); 055 private static final Vector<Class<?>> EMPTY_VEC_CLASS = new Vector<>(); 056 057 static 058 { 059 for (Method m : ServiceWorker.class.getMethods()) 060 { 061 // This doesn't work! The parameter names are all "arg0" ... "argN" 062 // It works for java.lang.reflect.Field, BUT NOT java.lang.reflect.Parameter! 063 // 064 // Vector<String> parameterNamesList = new Vector<>(); -- NOPE! 065 066 Vector<Class<?>> parameterTypesList = new Vector<>(); 067 068 for (Parameter p : m.getParameters()) parameterTypesList.add(p.getType()); 069 070 parameterTypes.put( 071 m.getName(), 072 (parameterTypesList.size() > 0) ? parameterTypesList : EMPTY_VEC_CLASS 073 ); 074 } 075 } 076 077 static 078 { 079 Vector<String> v = null; 080 081 v = new Vector<String>(3); 082 parameterNames.put("deliverPushMessage", v); 083 Collections.addAll(v, new String[] 084 { "origin", "registrationId", "data", }); 085 086 parameterNames.put("disable", EMPTY_VEC_STR); 087 088 v = new Vector<String>(4); 089 parameterNames.put("dispatchSyncEvent", v); 090 Collections.addAll(v, new String[] 091 { "origin", "registrationId", "tag", "lastChance", }); 092 093 v = new Vector<String>(3); 094 parameterNames.put("dispatchPeriodicSyncEvent", v); 095 Collections.addAll(v, new String[] 096 { "origin", "registrationId", "tag", }); 097 098 parameterNames.put("enable", EMPTY_VEC_STR); 099 100 v = new Vector<String>(1); 101 parameterNames.put("setForceUpdateOnPageLoad", v); 102 Collections.addAll(v, new String[] 103 { "forceUpdateOnPageLoad", }); 104 105 v = new Vector<String>(1); 106 parameterNames.put("skipWaiting", v); 107 Collections.addAll(v, new String[] 108 { "scopeURL", }); 109 110 v = new Vector<String>(1); 111 parameterNames.put("startWorker", v); 112 Collections.addAll(v, new String[] 113 { "scopeURL", }); 114 115 parameterNames.put("stopAllWorkers", EMPTY_VEC_STR); 116 117 v = new Vector<String>(1); 118 parameterNames.put("stopWorker", v); 119 Collections.addAll(v, new String[] 120 { "versionId", }); 121 122 v = new Vector<String>(1); 123 parameterNames.put("unregister", v); 124 Collections.addAll(v, new String[] 125 { "scopeURL", }); 126 127 v = new Vector<String>(1); 128 parameterNames.put("updateRegistration", v); 129 Collections.addAll(v, new String[] 130 { "scopeURL", }); 131 } 132 133 134 // ******************************************************************************************** 135 // ******************************************************************************************** 136 // Types - Static Inner Classes 137 // ******************************************************************************************** 138 // ******************************************************************************************** 139 140 // public static class RegistrationID => String 141 142 /** <CODE>[No Description Provided by Google]</CODE> */ 143 public static final String[] ServiceWorkerVersionRunningStatus = 144 { "stopped", "starting", "running", "stopping", }; 145 146 /** <CODE>[No Description Provided by Google]</CODE> */ 147 public static final String[] ServiceWorkerVersionStatus = 148 { "new", "installing", "installed", "activating", "activated", "redundant", }; 149 150 /** ServiceWorker registration. */ 151 public static class ServiceWorkerRegistration 152 extends BaseType 153 implements java.io.Serializable 154 { 155 /** For Object Serialization. java.io.Serializable */ 156 protected static final long serialVersionUID = 1; 157 158 public boolean[] optionals() 159 { return new boolean[] { false, false, false, }; } 160 161 /** <CODE>[No Description Provided by Google]</CODE> */ 162 public final String registrationId; 163 164 /** <CODE>[No Description Provided by Google]</CODE> */ 165 public final String scopeURL; 166 167 /** <CODE>[No Description Provided by Google]</CODE> */ 168 public final boolean isDeleted; 169 170 /** 171 * Constructor 172 * 173 * @param registrationId - 174 * 175 * @param scopeURL - 176 * 177 * @param isDeleted - 178 */ 179 public ServiceWorkerRegistration 180 (String registrationId, String scopeURL, boolean isDeleted) 181 { 182 // Exception-Check(s) to ensure that if any parameters which are not declared as 183 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 184 185 if (registrationId == null) THROWS.throwNPE("registrationId"); 186 if (scopeURL == null) THROWS.throwNPE("scopeURL"); 187 188 this.registrationId = registrationId; 189 this.scopeURL = scopeURL; 190 this.isDeleted = isDeleted; 191 } 192 193 /** 194 * JSON Object Constructor 195 * @param jo A Json-Object having data about an instance of {@code 'ServiceWorkerRegistration'}. 196 */ 197 public ServiceWorkerRegistration (JsonObject jo) 198 { 199 this.registrationId = ReadJSON.getString(jo, "registrationId", false, true); 200 this.scopeURL = ReadJSON.getString(jo, "scopeURL", false, true); 201 this.isDeleted = ReadPrimJSON.getBoolean(jo, "isDeleted"); 202 } 203 204 205 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 206 public boolean equals(Object other) 207 { 208 if (this == other) return true; 209 if (other == null) return false; 210 if (other.getClass() != this.getClass()) return false; 211 212 ServiceWorkerRegistration o = (ServiceWorkerRegistration) other; 213 214 return 215 Objects.equals(this.registrationId, o.registrationId) 216 && Objects.equals(this.scopeURL, o.scopeURL) 217 && (this.isDeleted == o.isDeleted); 218 } 219 220 /** Generates a Hash-Code for {@code 'this'} instance */ 221 public int hashCode() 222 { 223 return 224 Objects.hashCode(this.registrationId) 225 + Objects.hashCode(this.scopeURL) 226 + (this.isDeleted ? 1 : 0); 227 } 228 } 229 230 /** ServiceWorker version. */ 231 public static class ServiceWorkerVersion 232 extends BaseType 233 implements java.io.Serializable 234 { 235 /** For Object Serialization. java.io.Serializable */ 236 protected static final long serialVersionUID = 1; 237 238 public boolean[] optionals() 239 { return new boolean[] { false, false, false, false, false, true, true, true, true, true, }; } 240 241 /** <CODE>[No Description Provided by Google]</CODE> */ 242 public final String versionId; 243 244 /** <CODE>[No Description Provided by Google]</CODE> */ 245 public final String registrationId; 246 247 /** <CODE>[No Description Provided by Google]</CODE> */ 248 public final String scriptURL; 249 250 /** <CODE>[No Description Provided by Google]</CODE> */ 251 public final String runningStatus; 252 253 /** <CODE>[No Description Provided by Google]</CODE> */ 254 public final String status; 255 256 /** 257 * The Last-Modified header value of the main script. 258 * <BR /><B CLASS=Opt>OPTIONAL</B> 259 */ 260 public final Number scriptLastModified; 261 262 /** 263 * The time at which the response headers of the main script were received from the server. 264 * For cached script it is the last time the cache entry was validated. 265 * <BR /><B CLASS=Opt>OPTIONAL</B> 266 */ 267 public final Number scriptResponseTime; 268 269 /** 270 * <CODE>[No Description Provided by Google]</CODE> 271 * <BR /><B CLASS=Opt>OPTIONAL</B> 272 */ 273 public final String[] controlledClients; 274 275 /** 276 * <CODE>[No Description Provided by Google]</CODE> 277 * <BR /><B CLASS=Opt>OPTIONAL</B> 278 */ 279 public final String targetId; 280 281 /** 282 * <CODE>[No Description Provided by Google]</CODE> 283 * <BR /><B CLASS=Opt>OPTIONAL</B> 284 */ 285 public final String routerRules; 286 287 /** 288 * Constructor 289 * 290 * @param versionId - 291 * 292 * @param registrationId - 293 * 294 * @param scriptURL - 295 * 296 * @param runningStatus - 297 * 298 * @param status - 299 * 300 * @param scriptLastModified The Last-Modified header value of the main script. 301 * <BR /><B CLASS=Opt>OPTIONAL</B> 302 * 303 * @param scriptResponseTime 304 * The time at which the response headers of the main script were received from the server. 305 * For cached script it is the last time the cache entry was validated. 306 * <BR /><B CLASS=Opt>OPTIONAL</B> 307 * 308 * @param controlledClients - 309 * <BR /><B CLASS=Opt>OPTIONAL</B> 310 * 311 * @param targetId - 312 * <BR /><B CLASS=Opt>OPTIONAL</B> 313 * 314 * @param routerRules - 315 * <BR /><B CLASS=Opt>OPTIONAL</B> 316 */ 317 public ServiceWorkerVersion( 318 String versionId, String registrationId, String scriptURL, String runningStatus, 319 String status, Number scriptLastModified, Number scriptResponseTime, 320 String[] controlledClients, String targetId, String routerRules 321 ) 322 { 323 // Exception-Check(s) to ensure that if any parameters which are not declared as 324 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 325 326 if (versionId == null) THROWS.throwNPE("versionId"); 327 if (registrationId == null) THROWS.throwNPE("registrationId"); 328 if (scriptURL == null) THROWS.throwNPE("scriptURL"); 329 if (runningStatus == null) THROWS.throwNPE("runningStatus"); 330 if (status == null) THROWS.throwNPE("status"); 331 332 // Exception-Check(s) to ensure that if any parameters which must adhere to a 333 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 334 335 THROWS.checkIAE("runningStatus", runningStatus, "ServiceWorker.ServiceWorkerVersionRunningStatus", ServiceWorker.ServiceWorkerVersionRunningStatus); 336 THROWS.checkIAE("status", status, "ServiceWorker.ServiceWorkerVersionStatus", ServiceWorker.ServiceWorkerVersionStatus); 337 338 this.versionId = versionId; 339 this.registrationId = registrationId; 340 this.scriptURL = scriptURL; 341 this.runningStatus = runningStatus; 342 this.status = status; 343 this.scriptLastModified = scriptLastModified; 344 this.scriptResponseTime = scriptResponseTime; 345 this.controlledClients = controlledClients; 346 this.targetId = targetId; 347 this.routerRules = routerRules; 348 } 349 350 /** 351 * JSON Object Constructor 352 * @param jo A Json-Object having data about an instance of {@code 'ServiceWorkerVersion'}. 353 */ 354 public ServiceWorkerVersion (JsonObject jo) 355 { 356 this.versionId = ReadJSON.getString(jo, "versionId", false, true); 357 this.registrationId = ReadJSON.getString(jo, "registrationId", false, true); 358 this.scriptURL = ReadJSON.getString(jo, "scriptURL", false, true); 359 this.runningStatus = ReadJSON.getString(jo, "runningStatus", false, true); 360 this.status = ReadJSON.getString(jo, "status", false, true); 361 this.scriptLastModified = ReadNumberJSON.get(jo, "scriptLastModified", true, false); 362 this.scriptResponseTime = ReadNumberJSON.get(jo, "scriptResponseTime", true, false); 363 this.controlledClients = (jo.getJsonArray("controlledClients") == null) 364 ? null 365 : RJArrIntoStream.strArr(jo.getJsonArray("controlledClients"), null, 0).toArray(String[]::new); 366 367 this.targetId = ReadJSON.getString(jo, "targetId", true, false); 368 this.routerRules = ReadJSON.getString(jo, "routerRules", true, false); 369 } 370 371 372 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 373 public boolean equals(Object other) 374 { 375 if (this == other) return true; 376 if (other == null) return false; 377 if (other.getClass() != this.getClass()) return false; 378 379 ServiceWorkerVersion o = (ServiceWorkerVersion) other; 380 381 return 382 Objects.equals(this.versionId, o.versionId) 383 && Objects.equals(this.registrationId, o.registrationId) 384 && Objects.equals(this.scriptURL, o.scriptURL) 385 && Objects.equals(this.runningStatus, o.runningStatus) 386 && Objects.equals(this.status, o.status) 387 && Objects.equals(this.scriptLastModified, o.scriptLastModified) 388 && Objects.equals(this.scriptResponseTime, o.scriptResponseTime) 389 && Arrays.deepEquals(this.controlledClients, o.controlledClients) 390 && Objects.equals(this.targetId, o.targetId) 391 && Objects.equals(this.routerRules, o.routerRules); 392 } 393 394 /** Generates a Hash-Code for {@code 'this'} instance */ 395 public int hashCode() 396 { 397 return 398 Objects.hashCode(this.versionId) 399 + Objects.hashCode(this.registrationId) 400 + Objects.hashCode(this.scriptURL) 401 + Objects.hashCode(this.runningStatus) 402 + Objects.hashCode(this.status) 403 + Objects.hashCode(this.scriptLastModified) 404 + Objects.hashCode(this.scriptResponseTime) 405 + Arrays.deepHashCode(this.controlledClients) 406 + Objects.hashCode(this.targetId) 407 + Objects.hashCode(this.routerRules); 408 } 409 } 410 411 /** ServiceWorker error message. */ 412 public static class ServiceWorkerErrorMessage 413 extends BaseType 414 implements java.io.Serializable 415 { 416 /** For Object Serialization. java.io.Serializable */ 417 protected static final long serialVersionUID = 1; 418 419 public boolean[] optionals() 420 { return new boolean[] { false, false, false, false, false, false, }; } 421 422 /** <CODE>[No Description Provided by Google]</CODE> */ 423 public final String errorMessage; 424 425 /** <CODE>[No Description Provided by Google]</CODE> */ 426 public final String registrationId; 427 428 /** <CODE>[No Description Provided by Google]</CODE> */ 429 public final String versionId; 430 431 /** <CODE>[No Description Provided by Google]</CODE> */ 432 public final String sourceURL; 433 434 /** <CODE>[No Description Provided by Google]</CODE> */ 435 public final int lineNumber; 436 437 /** <CODE>[No Description Provided by Google]</CODE> */ 438 public final int columnNumber; 439 440 /** 441 * Constructor 442 * 443 * @param errorMessage - 444 * 445 * @param registrationId - 446 * 447 * @param versionId - 448 * 449 * @param sourceURL - 450 * 451 * @param lineNumber - 452 * 453 * @param columnNumber - 454 */ 455 public ServiceWorkerErrorMessage( 456 String errorMessage, String registrationId, String versionId, String sourceURL, 457 int lineNumber, int columnNumber 458 ) 459 { 460 // Exception-Check(s) to ensure that if any parameters which are not declared as 461 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 462 463 if (errorMessage == null) THROWS.throwNPE("errorMessage"); 464 if (registrationId == null) THROWS.throwNPE("registrationId"); 465 if (versionId == null) THROWS.throwNPE("versionId"); 466 if (sourceURL == null) THROWS.throwNPE("sourceURL"); 467 468 this.errorMessage = errorMessage; 469 this.registrationId = registrationId; 470 this.versionId = versionId; 471 this.sourceURL = sourceURL; 472 this.lineNumber = lineNumber; 473 this.columnNumber = columnNumber; 474 } 475 476 /** 477 * JSON Object Constructor 478 * @param jo A Json-Object having data about an instance of {@code 'ServiceWorkerErrorMessage'}. 479 */ 480 public ServiceWorkerErrorMessage (JsonObject jo) 481 { 482 this.errorMessage = ReadJSON.getString(jo, "errorMessage", false, true); 483 this.registrationId = ReadJSON.getString(jo, "registrationId", false, true); 484 this.versionId = ReadJSON.getString(jo, "versionId", false, true); 485 this.sourceURL = ReadJSON.getString(jo, "sourceURL", false, true); 486 this.lineNumber = ReadPrimJSON.getInt(jo, "lineNumber"); 487 this.columnNumber = ReadPrimJSON.getInt(jo, "columnNumber"); 488 } 489 490 491 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 492 public boolean equals(Object other) 493 { 494 if (this == other) return true; 495 if (other == null) return false; 496 if (other.getClass() != this.getClass()) return false; 497 498 ServiceWorkerErrorMessage o = (ServiceWorkerErrorMessage) other; 499 500 return 501 Objects.equals(this.errorMessage, o.errorMessage) 502 && Objects.equals(this.registrationId, o.registrationId) 503 && Objects.equals(this.versionId, o.versionId) 504 && Objects.equals(this.sourceURL, o.sourceURL) 505 && (this.lineNumber == o.lineNumber) 506 && (this.columnNumber == o.columnNumber); 507 } 508 509 /** Generates a Hash-Code for {@code 'this'} instance */ 510 public int hashCode() 511 { 512 return 513 Objects.hashCode(this.errorMessage) 514 + Objects.hashCode(this.registrationId) 515 + Objects.hashCode(this.versionId) 516 + Objects.hashCode(this.sourceURL) 517 + this.lineNumber 518 + this.columnNumber; 519 } 520 } 521 522 /** <CODE>[No Description Provided by Google]</CODE> */ 523 public static class workerErrorReported 524 extends BrowserEvent 525 implements java.io.Serializable 526 { 527 /** For Object Serialization. java.io.Serializable */ 528 protected static final long serialVersionUID = 1; 529 530 public boolean[] optionals() 531 { return new boolean[] { false, }; } 532 533 /** <CODE>[No Description Provided by Google]</CODE> */ 534 public final ServiceWorker.ServiceWorkerErrorMessage errorMessage; 535 536 /** 537 * Constructor 538 * 539 * @param errorMessage - 540 */ 541 public workerErrorReported(ServiceWorker.ServiceWorkerErrorMessage errorMessage) 542 { 543 super("ServiceWorker", "workerErrorReported", 1); 544 545 // Exception-Check(s) to ensure that if any parameters which are not declared as 546 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 547 548 if (errorMessage == null) THROWS.throwNPE("errorMessage"); 549 550 this.errorMessage = errorMessage; 551 } 552 553 /** 554 * JSON Object Constructor 555 * @param jo A Json-Object having data about an instance of {@code 'workerErrorReported'}. 556 */ 557 public workerErrorReported (JsonObject jo) 558 { 559 super("ServiceWorker", "workerErrorReported", 1); 560 561 this.errorMessage = ReadJSON.getObject(jo, "errorMessage", ServiceWorker.ServiceWorkerErrorMessage.class, false, true); 562 } 563 564 565 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 566 public boolean equals(Object other) 567 { 568 if (this == other) return true; 569 if (other == null) return false; 570 if (other.getClass() != this.getClass()) return false; 571 572 workerErrorReported o = (workerErrorReported) other; 573 574 return 575 Objects.equals(this.errorMessage, o.errorMessage); 576 } 577 578 /** Generates a Hash-Code for {@code 'this'} instance */ 579 public int hashCode() 580 { 581 return 582 this.errorMessage.hashCode(); 583 } 584 } 585 586 /** <CODE>[No Description Provided by Google]</CODE> */ 587 public static class workerRegistrationUpdated 588 extends BrowserEvent 589 implements java.io.Serializable 590 { 591 /** For Object Serialization. java.io.Serializable */ 592 protected static final long serialVersionUID = 1; 593 594 public boolean[] optionals() 595 { return new boolean[] { false, }; } 596 597 /** <CODE>[No Description Provided by Google]</CODE> */ 598 public final ServiceWorker.ServiceWorkerRegistration[] registrations; 599 600 /** 601 * Constructor 602 * 603 * @param registrations - 604 */ 605 public workerRegistrationUpdated 606 (ServiceWorker.ServiceWorkerRegistration[] registrations) 607 { 608 super("ServiceWorker", "workerRegistrationUpdated", 1); 609 610 // Exception-Check(s) to ensure that if any parameters which are not declared as 611 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 612 613 if (registrations == null) THROWS.throwNPE("registrations"); 614 615 this.registrations = registrations; 616 } 617 618 /** 619 * JSON Object Constructor 620 * @param jo A Json-Object having data about an instance of {@code 'workerRegistrationUpdated'}. 621 */ 622 public workerRegistrationUpdated (JsonObject jo) 623 { 624 super("ServiceWorker", "workerRegistrationUpdated", 1); 625 626 this.registrations = (jo.getJsonArray("registrations") == null) 627 ? null 628 : RJArrIntoStream.objArr(jo.getJsonArray("registrations"), null, 0, ServiceWorker.ServiceWorkerRegistration.class).toArray(ServiceWorker.ServiceWorkerRegistration[]::new); 629 630 } 631 632 633 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 634 public boolean equals(Object other) 635 { 636 if (this == other) return true; 637 if (other == null) return false; 638 if (other.getClass() != this.getClass()) return false; 639 640 workerRegistrationUpdated o = (workerRegistrationUpdated) other; 641 642 return 643 Arrays.deepEquals(this.registrations, o.registrations); 644 } 645 646 /** Generates a Hash-Code for {@code 'this'} instance */ 647 public int hashCode() 648 { 649 return 650 Arrays.deepHashCode(this.registrations); 651 } 652 } 653 654 /** <CODE>[No Description Provided by Google]</CODE> */ 655 public static class workerVersionUpdated 656 extends BrowserEvent 657 implements java.io.Serializable 658 { 659 /** For Object Serialization. java.io.Serializable */ 660 protected static final long serialVersionUID = 1; 661 662 public boolean[] optionals() 663 { return new boolean[] { false, }; } 664 665 /** <CODE>[No Description Provided by Google]</CODE> */ 666 public final ServiceWorker.ServiceWorkerVersion[] versions; 667 668 /** 669 * Constructor 670 * 671 * @param versions - 672 */ 673 public workerVersionUpdated(ServiceWorker.ServiceWorkerVersion[] versions) 674 { 675 super("ServiceWorker", "workerVersionUpdated", 1); 676 677 // Exception-Check(s) to ensure that if any parameters which are not declared as 678 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 679 680 if (versions == null) THROWS.throwNPE("versions"); 681 682 this.versions = versions; 683 } 684 685 /** 686 * JSON Object Constructor 687 * @param jo A Json-Object having data about an instance of {@code 'workerVersionUpdated'}. 688 */ 689 public workerVersionUpdated (JsonObject jo) 690 { 691 super("ServiceWorker", "workerVersionUpdated", 1); 692 693 this.versions = (jo.getJsonArray("versions") == null) 694 ? null 695 : RJArrIntoStream.objArr(jo.getJsonArray("versions"), null, 0, ServiceWorker.ServiceWorkerVersion.class).toArray(ServiceWorker.ServiceWorkerVersion[]::new); 696 697 } 698 699 700 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 701 public boolean equals(Object other) 702 { 703 if (this == other) return true; 704 if (other == null) return false; 705 if (other.getClass() != this.getClass()) return false; 706 707 workerVersionUpdated o = (workerVersionUpdated) other; 708 709 return 710 Arrays.deepEquals(this.versions, o.versions); 711 } 712 713 /** Generates a Hash-Code for {@code 'this'} instance */ 714 public int hashCode() 715 { 716 return 717 Arrays.deepHashCode(this.versions); 718 } 719 } 720 721 722 // Counter for keeping the WebSocket Request ID's distinct. 723 private static int counter = 1; 724 725 /** 726 * <CODE>[No Description Provided by Google]</CODE> 727 * 728 * @param origin - 729 * 730 * @param registrationId - 731 * 732 * @param data - 733 * 734 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 735 * {@link Ret0}></CODE> 736 * 737 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 738 * browser receives the invocation-request. 739 * 740 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 741 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 742 * {@code >} to ensure the Browser Function has run to completion. 743 */ 744 public static Script<String, JsonObject, Ret0> deliverPushMessage 745 (String origin, String registrationId, String data) 746 { 747 // Exception-Check(s) to ensure that if any parameters which are not declared as 748 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 749 750 if (origin == null) THROWS.throwNPE("origin"); 751 if (registrationId == null) THROWS.throwNPE("registrationId"); 752 if (data == null) THROWS.throwNPE("data"); 753 754 final int webSocketID = 39000000 + counter++; 755 final boolean[] optionals = { false, false, false, }; 756 757 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 758 String requestJSON = WriteJSON.get( 759 parameterTypes.get("deliverPushMessage"), 760 parameterNames.get("deliverPushMessage"), 761 optionals, webSocketID, 762 "ServiceWorker.deliverPushMessage", 763 origin, registrationId, data 764 ); 765 766 // This Remote Command does not have a Return-Value. 767 return new Script<> 768 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 769 } 770 771 /** 772 * <CODE>[No Description Provided by Google]</CODE> 773 * 774 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 775 * {@link Ret0}></CODE> 776 * 777 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 778 * browser receives the invocation-request. 779 * 780 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 781 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 782 * {@code >} to ensure the Browser Function has run to completion. 783 */ 784 public static Script<String, JsonObject, Ret0> disable() 785 { 786 final int webSocketID = 39001000 + counter++; 787 final boolean[] optionals = new boolean[0]; 788 789 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 790 String requestJSON = WriteJSON.get( 791 parameterTypes.get("disable"), 792 parameterNames.get("disable"), 793 optionals, webSocketID, 794 "ServiceWorker.disable" 795 ); 796 797 // This Remote Command does not have a Return-Value. 798 return new Script<> 799 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 800 } 801 802 /** 803 * <CODE>[No Description Provided by Google]</CODE> 804 * 805 * @param origin - 806 * 807 * @param registrationId - 808 * 809 * @param tag - 810 * 811 * @param lastChance - 812 * 813 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 814 * {@link Ret0}></CODE> 815 * 816 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 817 * browser receives the invocation-request. 818 * 819 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 820 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 821 * {@code >} to ensure the Browser Function has run to completion. 822 */ 823 public static Script<String, JsonObject, Ret0> dispatchSyncEvent 824 (String origin, String registrationId, String tag, boolean lastChance) 825 { 826 // Exception-Check(s) to ensure that if any parameters which are not declared as 827 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 828 829 if (origin == null) THROWS.throwNPE("origin"); 830 if (registrationId == null) THROWS.throwNPE("registrationId"); 831 if (tag == null) THROWS.throwNPE("tag"); 832 833 final int webSocketID = 39002000 + counter++; 834 final boolean[] optionals = { false, false, false, false, }; 835 836 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 837 String requestJSON = WriteJSON.get( 838 parameterTypes.get("dispatchSyncEvent"), 839 parameterNames.get("dispatchSyncEvent"), 840 optionals, webSocketID, 841 "ServiceWorker.dispatchSyncEvent", 842 origin, registrationId, tag, lastChance 843 ); 844 845 // This Remote Command does not have a Return-Value. 846 return new Script<> 847 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 848 } 849 850 /** 851 * <CODE>[No Description Provided by Google]</CODE> 852 * 853 * @param origin - 854 * 855 * @param registrationId - 856 * 857 * @param tag - 858 * 859 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 860 * {@link Ret0}></CODE> 861 * 862 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 863 * browser receives the invocation-request. 864 * 865 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 866 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 867 * {@code >} to ensure the Browser Function has run to completion. 868 */ 869 public static Script<String, JsonObject, Ret0> dispatchPeriodicSyncEvent 870 (String origin, String registrationId, String tag) 871 { 872 // Exception-Check(s) to ensure that if any parameters which are not declared as 873 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 874 875 if (origin == null) THROWS.throwNPE("origin"); 876 if (registrationId == null) THROWS.throwNPE("registrationId"); 877 if (tag == null) THROWS.throwNPE("tag"); 878 879 final int webSocketID = 39003000 + counter++; 880 final boolean[] optionals = { false, false, false, }; 881 882 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 883 String requestJSON = WriteJSON.get( 884 parameterTypes.get("dispatchPeriodicSyncEvent"), 885 parameterNames.get("dispatchPeriodicSyncEvent"), 886 optionals, webSocketID, 887 "ServiceWorker.dispatchPeriodicSyncEvent", 888 origin, registrationId, tag 889 ); 890 891 // This Remote Command does not have a Return-Value. 892 return new Script<> 893 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 894 } 895 896 /** 897 * <CODE>[No Description Provided by Google]</CODE> 898 * 899 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 900 * {@link Ret0}></CODE> 901 * 902 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 903 * browser receives the invocation-request. 904 * 905 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 906 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 907 * {@code >} to ensure the Browser Function has run to completion. 908 */ 909 public static Script<String, JsonObject, Ret0> enable() 910 { 911 final int webSocketID = 39004000 + counter++; 912 final boolean[] optionals = new boolean[0]; 913 914 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 915 String requestJSON = WriteJSON.get( 916 parameterTypes.get("enable"), 917 parameterNames.get("enable"), 918 optionals, webSocketID, 919 "ServiceWorker.enable" 920 ); 921 922 // This Remote Command does not have a Return-Value. 923 return new Script<> 924 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 925 } 926 927 /** 928 * <CODE>[No Description Provided by Google]</CODE> 929 * 930 * @param forceUpdateOnPageLoad - 931 * 932 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 933 * {@link Ret0}></CODE> 934 * 935 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 936 * browser receives the invocation-request. 937 * 938 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 939 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 940 * {@code >} to ensure the Browser Function has run to completion. 941 */ 942 public static Script<String, JsonObject, Ret0> setForceUpdateOnPageLoad 943 (boolean forceUpdateOnPageLoad) 944 { 945 final int webSocketID = 39005000 + counter++; 946 final boolean[] optionals = { false, }; 947 948 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 949 String requestJSON = WriteJSON.get( 950 parameterTypes.get("setForceUpdateOnPageLoad"), 951 parameterNames.get("setForceUpdateOnPageLoad"), 952 optionals, webSocketID, 953 "ServiceWorker.setForceUpdateOnPageLoad", 954 forceUpdateOnPageLoad 955 ); 956 957 // This Remote Command does not have a Return-Value. 958 return new Script<> 959 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 960 } 961 962 /** 963 * <CODE>[No Description Provided by Google]</CODE> 964 * 965 * @param scopeURL - 966 * 967 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 968 * {@link Ret0}></CODE> 969 * 970 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 971 * browser receives the invocation-request. 972 * 973 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 974 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 975 * {@code >} to ensure the Browser Function has run to completion. 976 */ 977 public static Script<String, JsonObject, Ret0> skipWaiting(String scopeURL) 978 { 979 // Exception-Check(s) to ensure that if any parameters which are not declared as 980 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 981 982 if (scopeURL == null) THROWS.throwNPE("scopeURL"); 983 984 final int webSocketID = 39006000 + counter++; 985 final boolean[] optionals = { false, }; 986 987 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 988 String requestJSON = WriteJSON.get( 989 parameterTypes.get("skipWaiting"), 990 parameterNames.get("skipWaiting"), 991 optionals, webSocketID, 992 "ServiceWorker.skipWaiting", 993 scopeURL 994 ); 995 996 // This Remote Command does not have a Return-Value. 997 return new Script<> 998 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 999 } 1000 1001 /** 1002 * <CODE>[No Description Provided by Google]</CODE> 1003 * 1004 * @param scopeURL - 1005 * 1006 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 1007 * {@link Ret0}></CODE> 1008 * 1009 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1010 * browser receives the invocation-request. 1011 * 1012 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 1013 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 1014 * {@code >} to ensure the Browser Function has run to completion. 1015 */ 1016 public static Script<String, JsonObject, Ret0> startWorker(String scopeURL) 1017 { 1018 // Exception-Check(s) to ensure that if any parameters which are not declared as 1019 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1020 1021 if (scopeURL == null) THROWS.throwNPE("scopeURL"); 1022 1023 final int webSocketID = 39007000 + counter++; 1024 final boolean[] optionals = { false, }; 1025 1026 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1027 String requestJSON = WriteJSON.get( 1028 parameterTypes.get("startWorker"), 1029 parameterNames.get("startWorker"), 1030 optionals, webSocketID, 1031 "ServiceWorker.startWorker", 1032 scopeURL 1033 ); 1034 1035 // This Remote Command does not have a Return-Value. 1036 return new Script<> 1037 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 1038 } 1039 1040 /** 1041 * <CODE>[No Description Provided by Google]</CODE> 1042 * 1043 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 1044 * {@link Ret0}></CODE> 1045 * 1046 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1047 * browser receives the invocation-request. 1048 * 1049 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 1050 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 1051 * {@code >} to ensure the Browser Function has run to completion. 1052 */ 1053 public static Script<String, JsonObject, Ret0> stopAllWorkers() 1054 { 1055 final int webSocketID = 39008000 + counter++; 1056 final boolean[] optionals = new boolean[0]; 1057 1058 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1059 String requestJSON = WriteJSON.get( 1060 parameterTypes.get("stopAllWorkers"), 1061 parameterNames.get("stopAllWorkers"), 1062 optionals, webSocketID, 1063 "ServiceWorker.stopAllWorkers" 1064 ); 1065 1066 // This Remote Command does not have a Return-Value. 1067 return new Script<> 1068 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 1069 } 1070 1071 /** 1072 * <CODE>[No Description Provided by Google]</CODE> 1073 * 1074 * @param versionId - 1075 * 1076 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 1077 * {@link Ret0}></CODE> 1078 * 1079 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1080 * browser receives the invocation-request. 1081 * 1082 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 1083 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 1084 * {@code >} to ensure the Browser Function has run to completion. 1085 */ 1086 public static Script<String, JsonObject, Ret0> stopWorker(String versionId) 1087 { 1088 // Exception-Check(s) to ensure that if any parameters which are not declared as 1089 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1090 1091 if (versionId == null) THROWS.throwNPE("versionId"); 1092 1093 final int webSocketID = 39009000 + counter++; 1094 final boolean[] optionals = { false, }; 1095 1096 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1097 String requestJSON = WriteJSON.get( 1098 parameterTypes.get("stopWorker"), 1099 parameterNames.get("stopWorker"), 1100 optionals, webSocketID, 1101 "ServiceWorker.stopWorker", 1102 versionId 1103 ); 1104 1105 // This Remote Command does not have a Return-Value. 1106 return new Script<> 1107 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 1108 } 1109 1110 /** 1111 * <CODE>[No Description Provided by Google]</CODE> 1112 * 1113 * @param scopeURL - 1114 * 1115 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 1116 * {@link Ret0}></CODE> 1117 * 1118 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1119 * browser receives the invocation-request. 1120 * 1121 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 1122 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 1123 * {@code >} to ensure the Browser Function has run to completion. 1124 */ 1125 public static Script<String, JsonObject, Ret0> unregister(String scopeURL) 1126 { 1127 // Exception-Check(s) to ensure that if any parameters which are not declared as 1128 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1129 1130 if (scopeURL == null) THROWS.throwNPE("scopeURL"); 1131 1132 final int webSocketID = 39010000 + counter++; 1133 final boolean[] optionals = { false, }; 1134 1135 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1136 String requestJSON = WriteJSON.get( 1137 parameterTypes.get("unregister"), 1138 parameterNames.get("unregister"), 1139 optionals, webSocketID, 1140 "ServiceWorker.unregister", 1141 scopeURL 1142 ); 1143 1144 // This Remote Command does not have a Return-Value. 1145 return new Script<> 1146 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 1147 } 1148 1149 /** 1150 * <CODE>[No Description Provided by Google]</CODE> 1151 * 1152 * @param scopeURL - 1153 * 1154 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 1155 * {@link Ret0}></CODE> 1156 * 1157 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1158 * browser receives the invocation-request. 1159 * 1160 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 1161 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 1162 * {@code >} to ensure the Browser Function has run to completion. 1163 */ 1164 public static Script<String, JsonObject, Ret0> updateRegistration(String scopeURL) 1165 { 1166 // Exception-Check(s) to ensure that if any parameters which are not declared as 1167 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1168 1169 if (scopeURL == null) THROWS.throwNPE("scopeURL"); 1170 1171 final int webSocketID = 39011000 + counter++; 1172 final boolean[] optionals = { false, }; 1173 1174 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1175 String requestJSON = WriteJSON.get( 1176 parameterTypes.get("updateRegistration"), 1177 parameterNames.get("updateRegistration"), 1178 optionals, webSocketID, 1179 "ServiceWorker.updateRegistration", 1180 scopeURL 1181 ); 1182 1183 // This Remote Command does not have a Return-Value. 1184 return new Script<> 1185 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 1186 } 1187 1188}