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