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