001package Torello.Browser.BrowserAPI; 002 003// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 004// Java-HTML Imports 005// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 006 007import Torello.Browser.*; 008import Torello.Browser.helper.*; 009import Torello.Browser.JavaScriptAPI.*; 010import Torello.JSON.*; 011 012import Torello.Java.ReadOnly.ReadOnlyList; 013import Torello.Java.ReadOnly.ReadOnlyArrayList; 014 015import Torello.JavaDoc.Annotations.StaticFunctional; 016import Torello.JavaDoc.Annotations.JDHeaderBackgroundImg; 017 018import Torello.Browser.BrowserAPI.NestedHelpers.Commands.DOMStorage$$Commands; 019 020 021// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 022// JDK Imports 023// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 024 025import javax.json.JsonObject; 026import javax.json.JsonValue; 027 028/** 029 * <SPAN CLASS=COPIEDJDK><B>Query and modify DOM storage.</B></SPAN> 030 * <EMBED CLASS='external-html' DATA-FILE-ID=CDP.CODE_GEN_NOTE> 031 */ 032@StaticFunctional@JDHeaderBackgroundImg(EmbedTagFileID="CDP.WOOD_PLANK_NOTE") 033public class DOMStorage 034{ 035 // No Pubic Constructors 036 private DOMStorage() { } 037 038 039 // ******************************************************************************************** 040 // ******************************************************************************************** 041 // Eliminated Types 042 // ******************************************************************************************** 043 // ******************************************************************************************** 044 045 046 /** 047 * DOM Storage item. 048 049 * <EMBED CLASS='external-html' DATA-CTAS='String' DATA-FILE-ID=CDP.EliminatedType 050 * DATA-NAME=Item> 051 */ 052 public static final String Item = 053 "Item has been eliminated.\n" + 054 "It was replaced with the standard Java-Type: String"; 055 056 /** 057 * <CODE>[No Description Provided by Google]</CODE> 058 059 * <EMBED CLASS='external-html' DATA-CTAS='String' DATA-FILE-ID=CDP.EliminatedType 060 * DATA-NAME=SerializedStorageKey> 061 */ 062 public static final String SerializedStorageKey = 063 "SerializedStorageKey has been eliminated.\n" + 064 "It was replaced with the standard Java-Type: String"; 065 066 067 068 // ******************************************************************************************** 069 // ******************************************************************************************** 070 // Basic Types 071 // ******************************************************************************************** 072 // ******************************************************************************************** 073 074 075 /** 076 * DOM Storage identifier. 077 * 078 * <EMBED CLASS=globalDefs DATA-DOMAIN=DOMStorage DATA-API=BrowserAPI> 079 */ 080 @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_TYPE_JDHBI") 081 public static class StorageId 082 extends BaseType<StorageId> 083 implements java.io.Serializable 084 { 085 /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */ 086 protected static final long serialVersionUID = 1; 087 088 private static final NestedHelper<DOMStorage.StorageId> singleton = 089 Torello.Browser.BrowserAPI.NestedHelpers.Types. 090 DOMStorage$$StorageId$$.singleton; 091 092 /** 093 * Security origin for the storage. 094 * <BR /><B CLASS=Opt-Top>OPTIONAL</B> 095 */ 096 public final String securityOrigin; 097 098 /** 099 * Represents a key by which DOM Storage keys its CachedStorageAreas 100 * <BR /><B CLASS=Opt-Top>OPTIONAL</B> 101 */ 102 public final String storageKey; 103 104 /** Whether the storage is local storage (not session storage). */ 105 public final boolean isLocalStorage; 106 107 /** Constructor. Please review this class' fields for documentation. */ 108 public StorageId( 109 ReadOnlyList<Boolean> isPresent, String securityOrigin, String storageKey, 110 boolean isLocalStorage 111 ) 112 { 113 super(singleton, Domains.DOMStorage, "StorageId", 3); 114 115 this.securityOrigin = securityOrigin; 116 this.storageKey = storageKey; 117 this.isLocalStorage = isLocalStorage; 118 119 this.isPresent = (isPresent == null) 120 ? singleton.generateIsPresentList(this) 121 : THROWS.check(isPresent, 3, "DOMStorage.StorageId"); 122 } 123 124 /** Creates an instance of this class from a {@link JsonObject}.*/ 125 public static StorageId fromJSON(JsonObject jo) 126 { return singleton.fromJSON(jo); } 127 128 /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/ 129 public static NestedDescriptor<StorageId> descriptor() 130 { return singleton.descriptor(); } 131 } 132 133 134 // ******************************************************************************************** 135 // ******************************************************************************************** 136 // Event Types 137 // ******************************************************************************************** 138 // ******************************************************************************************** 139 140 141 /** 142 * <CODE>[No Description Provided by Google]</CODE> 143 * 144 * <EMBED CLASS=globalDefs DATA-DOMAIN=DOMStorage DATA-API=BrowserAPI> 145 */ 146 @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_EVENT_JDHBI") 147 public static class domStorageItemAdded 148 extends BrowserEvent<domStorageItemAdded> 149 implements java.io.Serializable 150 { 151 /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */ 152 protected static final long serialVersionUID = 1; 153 154 private static final NestedHelper<DOMStorage.domStorageItemAdded> singleton = 155 Torello.Browser.BrowserAPI.NestedHelpers.Events. 156 DOMStorage$$domStorageItemAdded$$.singleton; 157 158 /** <CODE>[No Description Provided by Google]</CODE> */ 159 public final DOMStorage.StorageId storageId; 160 161 /** <CODE>[No Description Provided by Google]</CODE> */ 162 public final String key; 163 164 /** <CODE>[No Description Provided by Google]</CODE> */ 165 public final String newValue; 166 167 /** Constructor. Please review this class' fields for documentation. */ 168 public domStorageItemAdded 169 (ReadOnlyList<Boolean> isPresent, StorageId storageId, String key, String newValue) 170 { 171 super(singleton, Domains.DOMStorage, "domStorageItemAdded", 3); 172 173 this.storageId = storageId; 174 this.key = key; 175 this.newValue = newValue; 176 177 this.isPresent = (isPresent == null) 178 ? singleton.generateIsPresentList(this) 179 : THROWS.check(isPresent, 3, "DOMStorage.domStorageItemAdded"); 180 } 181 182 /** Creates an instance of this class from a {@link JsonObject}.*/ 183 public static domStorageItemAdded fromJSON(JsonObject jo) 184 { return singleton.fromJSON(jo); } 185 186 /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/ 187 public static NestedDescriptor<domStorageItemAdded> descriptor() 188 { return singleton.descriptor(); } 189 } 190 191 /** 192 * <CODE>[No Description Provided by Google]</CODE> 193 * 194 * <EMBED CLASS=globalDefs DATA-DOMAIN=DOMStorage DATA-API=BrowserAPI> 195 */ 196 @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_EVENT_JDHBI") 197 public static class domStorageItemRemoved 198 extends BrowserEvent<domStorageItemRemoved> 199 implements java.io.Serializable 200 { 201 /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */ 202 protected static final long serialVersionUID = 1; 203 204 private static final NestedHelper<DOMStorage.domStorageItemRemoved> singleton = 205 Torello.Browser.BrowserAPI.NestedHelpers.Events. 206 DOMStorage$$domStorageItemRemoved$$.singleton; 207 208 /** <CODE>[No Description Provided by Google]</CODE> */ 209 public final DOMStorage.StorageId storageId; 210 211 /** <CODE>[No Description Provided by Google]</CODE> */ 212 public final String key; 213 214 /** Constructor. Please review this class' fields for documentation. */ 215 public domStorageItemRemoved 216 (ReadOnlyList<Boolean> isPresent, StorageId storageId, String key) 217 { 218 super(singleton, Domains.DOMStorage, "domStorageItemRemoved", 2); 219 220 this.storageId = storageId; 221 this.key = key; 222 223 this.isPresent = (isPresent == null) 224 ? singleton.generateIsPresentList(this) 225 : THROWS.check(isPresent, 2, "DOMStorage.domStorageItemRemoved"); 226 } 227 228 /** Creates an instance of this class from a {@link JsonObject}.*/ 229 public static domStorageItemRemoved fromJSON(JsonObject jo) 230 { return singleton.fromJSON(jo); } 231 232 /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/ 233 public static NestedDescriptor<domStorageItemRemoved> descriptor() 234 { return singleton.descriptor(); } 235 } 236 237 /** 238 * <CODE>[No Description Provided by Google]</CODE> 239 * 240 * <EMBED CLASS=globalDefs DATA-DOMAIN=DOMStorage DATA-API=BrowserAPI> 241 */ 242 @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_EVENT_JDHBI") 243 public static class domStorageItemUpdated 244 extends BrowserEvent<domStorageItemUpdated> 245 implements java.io.Serializable 246 { 247 /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */ 248 protected static final long serialVersionUID = 1; 249 250 private static final NestedHelper<DOMStorage.domStorageItemUpdated> singleton = 251 Torello.Browser.BrowserAPI.NestedHelpers.Events. 252 DOMStorage$$domStorageItemUpdated$$.singleton; 253 254 /** <CODE>[No Description Provided by Google]</CODE> */ 255 public final DOMStorage.StorageId storageId; 256 257 /** <CODE>[No Description Provided by Google]</CODE> */ 258 public final String key; 259 260 /** <CODE>[No Description Provided by Google]</CODE> */ 261 public final String oldValue; 262 263 /** <CODE>[No Description Provided by Google]</CODE> */ 264 public final String newValue; 265 266 /** Constructor. Please review this class' fields for documentation. */ 267 public domStorageItemUpdated( 268 ReadOnlyList<Boolean> isPresent, StorageId storageId, String key, String oldValue, 269 String newValue 270 ) 271 { 272 super(singleton, Domains.DOMStorage, "domStorageItemUpdated", 4); 273 274 this.storageId = storageId; 275 this.key = key; 276 this.oldValue = oldValue; 277 this.newValue = newValue; 278 279 this.isPresent = (isPresent == null) 280 ? singleton.generateIsPresentList(this) 281 : THROWS.check(isPresent, 4, "DOMStorage.domStorageItemUpdated"); 282 } 283 284 /** Creates an instance of this class from a {@link JsonObject}.*/ 285 public static domStorageItemUpdated fromJSON(JsonObject jo) 286 { return singleton.fromJSON(jo); } 287 288 /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/ 289 public static NestedDescriptor<domStorageItemUpdated> descriptor() 290 { return singleton.descriptor(); } 291 } 292 293 /** 294 * <CODE>[No Description Provided by Google]</CODE> 295 * 296 * <EMBED CLASS=globalDefs DATA-DOMAIN=DOMStorage DATA-API=BrowserAPI> 297 */ 298 @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_EVENT_JDHBI") 299 public static class domStorageItemsCleared 300 extends BrowserEvent<domStorageItemsCleared> 301 implements java.io.Serializable 302 { 303 /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */ 304 protected static final long serialVersionUID = 1; 305 306 private static final NestedHelper<DOMStorage.domStorageItemsCleared> singleton = 307 Torello.Browser.BrowserAPI.NestedHelpers.Events. 308 DOMStorage$$domStorageItemsCleared$$.singleton; 309 310 /** <CODE>[No Description Provided by Google]</CODE> */ 311 public final DOMStorage.StorageId storageId; 312 313 /** Constructor. Please review this class' fields for documentation. */ 314 public domStorageItemsCleared(ReadOnlyList<Boolean> isPresent, StorageId storageId) 315 { 316 super(singleton, Domains.DOMStorage, "domStorageItemsCleared", 1); 317 318 this.storageId = storageId; 319 320 this.isPresent = (isPresent == null) 321 ? singleton.generateIsPresentList(this) 322 : THROWS.check(isPresent, 1, "DOMStorage.domStorageItemsCleared"); 323 } 324 325 /** Creates an instance of this class from a {@link JsonObject}.*/ 326 public static domStorageItemsCleared fromJSON(JsonObject jo) 327 { return singleton.fromJSON(jo); } 328 329 /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/ 330 public static NestedDescriptor<domStorageItemsCleared> descriptor() 331 { return singleton.descriptor(); } 332 } 333 334 335 336 337 // ******************************************************************************************** 338 // ******************************************************************************************** 339 // Commands 340 // ******************************************************************************************** 341 // ******************************************************************************************** 342 343 344 /** 345 * <CODE>[No Description Provided by Google]</CODE> 346 * 347 * @param storageId - 348 * 349 * @return An instance of <CODE>{@link Script}<Void></CODE> 350 * 351 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 352 * browser receives the invocation-request. 353 * 354 * <BR /><BR /><DIV CLASS=JDHint> 355 * This Browser-Function <I>does not have</I> a return-value. You may choose to 356 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that 357 * the Browser Function has run to completion. 358 * </DIV> 359 */ 360 public static Script<Void> clear(StorageId storageId) 361 { 362 // Build the JSON Request-Object (as a String); only 1 Parameter is passed 363 final String requestJSON = WriteJSON.get 364 (CDPTypes.CDP_TYPE, "storageId", false, "DOMStorage.clear", storageId); 365 366 return Script.NO_RET(Domains.DOMStorage, "clear", requestJSON); 367 } 368 369 /** 370 * Disables storage tracking, prevents storage events from being sent to the client. 371 * 372 * @return An instance of <CODE>{@link Script}<Void></CODE> 373 * 374 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 375 * browser receives the invocation-request. 376 * 377 * <BR /><BR /><DIV CLASS=JDHint> 378 * This Browser-Function <I>does not have</I> a return-value. You may choose to 379 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that 380 * the Browser Function has run to completion. 381 * </DIV> 382 */ 383 public static Script<Void> disable() 384 { 385 // Ultra-Simple Request JSON - Because this method has no parameters 386 final String requestJSON = "{\"method\":\"DOMStorage.disable\"}"; 387 388 return Script.NO_RET(Domains.DOMStorage, "disable", requestJSON); 389 } 390 391 /** 392 * Enables storage tracking, storage events will now be delivered to the client. 393 * 394 * @return An instance of <CODE>{@link Script}<Void></CODE> 395 * 396 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 397 * browser receives the invocation-request. 398 * 399 * <BR /><BR /><DIV CLASS=JDHint> 400 * This Browser-Function <I>does not have</I> a return-value. You may choose to 401 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that 402 * the Browser Function has run to completion. 403 * </DIV> 404 */ 405 public static Script<Void> enable() 406 { 407 // Ultra-Simple Request JSON - Because this method has no parameters 408 final String requestJSON = "{\"method\":\"DOMStorage.enable\"}"; 409 410 return Script.NO_RET(Domains.DOMStorage, "enable", requestJSON); 411 } 412 413 /** 414 * <CODE>[No Description Provided by Google]</CODE> 415 * 416 * @param storageId - 417 * 418 * @return An instance of <CODE>{@link Script}<String[]></CODE> 419 * 420 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 421 * {@link Script#exec(WebSocketSender) Script.exec}, and afterwards, a {@link Promise} 422 * <CODE><String[]></CODE> will be returned 423 * 424 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 425 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 426 * be retrieved.</I> 427 * 428 * <BR /><BR /><DIV CLASS=JDHint> 429 * This Browser Function's {@code Promise} returns: 430 * <CODE>String[] (<B>entries</B>)</CODE> 431 * </DIV> 432 */ 433 public static Script<String[]> getDOMStorageItems(StorageId storageId) 434 { 435 // Build the JSON Request-Object (as a String); only 1 Parameter is passed 436 final String requestJSON = WriteJSON.get 437 (CDPTypes.CDP_TYPE, "storageId", false, "DOMStorage.getDOMStorageItems", storageId); 438 439 return new Script<>( 440 Domains.DOMStorage, "getDOMStorageItems", requestJSON, 441 DOMStorage$$Commands::getDOMStorageItems, 442 String[].class 443 ); 444 } 445 446 /** 447 * <CODE>[No Description Provided by Google]</CODE> 448 * 449 * @param storageId - 450 * 451 * @param key - 452 * 453 * @return An instance of <CODE>{@link Script}<Void></CODE> 454 * 455 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 456 * browser receives the invocation-request. 457 * 458 * <BR /><BR /><DIV CLASS=JDHint> 459 * This Browser-Function <I>does not have</I> a return-value. You may choose to 460 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that 461 * the Browser Function has run to completion. 462 * </DIV> 463 */ 464 public static Script<Void> removeDOMStorageItem(StorageId storageId, String key) 465 { 466 // Convert all Method Parameters into a JSON Request-Object (as a String) 467 final String requestJSON = WriteJSON.get( 468 DOMStorage$$Commands.removeDOMStorageItem$$, "DOMStorage.removeDOMStorageItem", 469 storageId, key 470 ); 471 472 return Script.NO_RET(Domains.DOMStorage, "removeDOMStorageItem", requestJSON); 473 } 474 475 /** 476 * <CODE>[No Description Provided by Google]</CODE> 477 * 478 * @param storageId - 479 * 480 * @param key - 481 * 482 * @param value - 483 * 484 * @return An instance of <CODE>{@link Script}<Void></CODE> 485 * 486 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 487 * browser receives the invocation-request. 488 * 489 * <BR /><BR /><DIV CLASS=JDHint> 490 * This Browser-Function <I>does not have</I> a return-value. You may choose to 491 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that 492 * the Browser Function has run to completion. 493 * </DIV> 494 */ 495 public static Script<Void> setDOMStorageItem(StorageId storageId, String key, String value) 496 { 497 // Convert all Method Parameters into a JSON Request-Object (as a String) 498 final String requestJSON = WriteJSON.get( 499 DOMStorage$$Commands.setDOMStorageItem$$, "DOMStorage.setDOMStorageItem", 500 storageId, key, value 501 ); 502 503 return Script.NO_RET(Domains.DOMStorage, "setDOMStorageItem", requestJSON); 504 } 505 506 507}