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 Accessibility
030{
031    // ********************************************************************************************
032    // ********************************************************************************************
033    // Class Header Stuff
034    // ********************************************************************************************
035    // ********************************************************************************************
036
037
038    // No Pubic Constructors
039    private Accessibility () { }
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 : Accessibility.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        parameterNames.put("disable", EMPTY_VEC_STR);
078
079        parameterNames.put("enable", EMPTY_VEC_STR);
080
081        v = new Vector<String>(4);
082        parameterNames.put("getPartialAXTree", v);
083        Collections.addAll(v, new String[]
084        { "nodeId", "backendNodeId", "objectId", "fetchRelatives", });
085
086        v = new Vector<String>(3);
087        parameterNames.put("getFullAXTree", v);
088        Collections.addAll(v, new String[]
089        { "depth", "max_depth", "frameId", });
090
091        v = new Vector<String>(2);
092        parameterNames.put("getChildAXNodes", v);
093        Collections.addAll(v, new String[]
094        { "id", "frameId", });
095
096        v = new Vector<String>(5);
097        parameterNames.put("queryAXTree", v);
098        Collections.addAll(v, new String[]
099        { "nodeId", "backendNodeId", "objectId", "accessibleName", "role", });
100    }
101
102
103    // ********************************************************************************************
104    // ********************************************************************************************
105    // Types - Static Inner Classes
106    // ********************************************************************************************
107    // ********************************************************************************************
108
109    // public static class AXNodeId => String
110    
111    /** Enum of possible property types. */
112    public static final String[] AXValueType =
113    { 
114        "boolean", "tristate", "booleanOrUndefined", "idref", "idrefList", "integer", "node", 
115        "nodeList", "number", "string", "computedString", "token", "tokenList", "domRelation", 
116        "role", "internalRole", "valueUndefined", 
117    };
118    
119    /** Enum of possible property sources. */
120    public static final String[] AXValueSourceType =
121    { "attribute", "implicit", "style", "contents", "placeholder", "relatedElement", };
122    
123    /** Enum of possible native property sources (as a subtype of a particular AXValueSourceType). */
124    public static final String[] AXValueNativeSourceType =
125    { 
126        "description", "figcaption", "label", "labelfor", "labelwrapped", "legend", 
127        "rubyannotation", "tablecaption", "title", "other", 
128    };
129    
130    /**
131     * Values of AXProperty name:
132     * - from 'busy' to 'roledescription': states which apply to every AX node
133     * - from 'live' to 'root': attributes which apply to nodes in live regions
134     * - from 'autocomplete' to 'valuetext': attributes which apply to widgets
135     * - from 'checked' to 'selected': states which apply to widgets
136     * - from 'activedescendant' to 'owns' - relationships between elements other than parent/child/sibling.
137     */
138    public static final String[] AXPropertyName =
139    { 
140        "busy", "disabled", "editable", "focusable", "focused", "hidden", "hiddenRoot", "invalid", 
141        "keyshortcuts", "settable", "roledescription", "live", "atomic", "relevant", "root", 
142        "autocomplete", "hasPopup", "level", "multiselectable", "orientation", "multiline", 
143        "readonly", "required", "valuemin", "valuemax", "valuetext", "checked", "expanded", 
144        "modal", "pressed", "selected", "activedescendant", "controls", "describedby", "details", 
145        "errormessage", "flowto", "labelledby", "owns", 
146    };
147    
148    /** A single source for a computed AX property. */
149    public static class AXValueSource
150        extends BaseType
151        implements java.io.Serializable
152    {
153        /** For Object Serialization.  java.io.Serializable */
154        protected static final long serialVersionUID = 1;
155        
156        public boolean[] optionals()
157        { return new boolean[] { false, true, true, true, true, true, true, true, true, }; }
158        
159        /** What type of source this is. */
160        public final String type;
161        
162        /**
163         * The value of this property source.
164         * <BR />
165         * <BR /><B>OPTIONAL</B>
166         */
167        public final Accessibility.AXValue value;
168        
169        /**
170         * The name of the relevant attribute, if any.
171         * <BR />
172         * <BR /><B>OPTIONAL</B>
173         */
174        public final String attribute;
175        
176        /**
177         * The value of the relevant attribute, if any.
178         * <BR />
179         * <BR /><B>OPTIONAL</B>
180         */
181        public final Accessibility.AXValue attributeValue;
182        
183        /**
184         * Whether this source is superseded by a higher priority source.
185         * <BR />
186         * <BR /><B>OPTIONAL</B>
187         */
188        public final Boolean superseded;
189        
190        /**
191         * The native markup source for this value, e.g. a &lt;label&gt; element.
192         * <BR />
193         * <BR /><B>OPTIONAL</B>
194         */
195        public final String nativeSource;
196        
197        /**
198         * The value, such as a node or node list, of the native source.
199         * <BR />
200         * <BR /><B>OPTIONAL</B>
201         */
202        public final Accessibility.AXValue nativeSourceValue;
203        
204        /**
205         * Whether the value for this property is invalid.
206         * <BR />
207         * <BR /><B>OPTIONAL</B>
208         */
209        public final Boolean invalid;
210        
211        /**
212         * Reason for the value being invalid, if it is.
213         * <BR />
214         * <BR /><B>OPTIONAL</B>
215         */
216        public final String invalidReason;
217        
218        /**
219         * Constructor
220         *
221         * @param type What type of source this is.
222         * 
223         * @param value The value of this property source.
224         * <BR /><B>OPTIONAL</B>
225         * 
226         * @param attribute The name of the relevant attribute, if any.
227         * <BR /><B>OPTIONAL</B>
228         * 
229         * @param attributeValue The value of the relevant attribute, if any.
230         * <BR /><B>OPTIONAL</B>
231         * 
232         * @param superseded Whether this source is superseded by a higher priority source.
233         * <BR /><B>OPTIONAL</B>
234         * 
235         * @param nativeSource The native markup source for this value, e.g. a &lt;label&gt; element.
236         * <BR /><B>OPTIONAL</B>
237         * 
238         * @param nativeSourceValue The value, such as a node or node list, of the native source.
239         * <BR /><B>OPTIONAL</B>
240         * 
241         * @param invalid Whether the value for this property is invalid.
242         * <BR /><B>OPTIONAL</B>
243         * 
244         * @param invalidReason Reason for the value being invalid, if it is.
245         * <BR /><B>OPTIONAL</B>
246         */
247        public AXValueSource(
248                String type, Accessibility.AXValue value, String attribute, 
249                Accessibility.AXValue attributeValue, Boolean superseded, String nativeSource, 
250                Accessibility.AXValue nativeSourceValue, Boolean invalid, String invalidReason
251            )
252        {
253            // Exception-Check(s) to ensure that if any parameters which are not declared as
254            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
255            
256            if (type == null) BRDPC.throwNPE("type");
257            
258            // Exception-Check(s) to ensure that if any parameters which must adhere to a
259            // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw.
260            
261            BRDPC.checkIAE("type", type, "Accessibility.AXValueSourceType", Accessibility.AXValueSourceType);
262            BRDPC.checkIAE("nativeSource", nativeSource, "Accessibility.AXValueNativeSourceType", Accessibility.AXValueNativeSourceType);
263            
264            this.type               = type;
265            this.value              = value;
266            this.attribute          = attribute;
267            this.attributeValue     = attributeValue;
268            this.superseded         = superseded;
269            this.nativeSource       = nativeSource;
270            this.nativeSourceValue  = nativeSourceValue;
271            this.invalid            = invalid;
272            this.invalidReason      = invalidReason;
273        }
274        
275        /**
276         * JSON Object Constructor
277         * @param jo A Json-Object having data about an instance of {@code 'AXValueSource'}.
278         */
279        public AXValueSource (JsonObject jo)
280        {
281            this.type               = ReadJSON.getString(jo, "type", false, true);
282            this.value              = ReadJSON.getObject(jo, "value", Accessibility.AXValue.class, true, false);
283            this.attribute          = ReadJSON.getString(jo, "attribute", true, false);
284            this.attributeValue     = ReadJSON.getObject(jo, "attributeValue", Accessibility.AXValue.class, true, false);
285            this.superseded         = ReadBoxedJSON.getBoolean(jo, "superseded", true);
286            this.nativeSource       = ReadJSON.getString(jo, "nativeSource", true, false);
287            this.nativeSourceValue  = ReadJSON.getObject(jo, "nativeSourceValue", Accessibility.AXValue.class, true, false);
288            this.invalid            = ReadBoxedJSON.getBoolean(jo, "invalid", true);
289            this.invalidReason      = ReadJSON.getString(jo, "invalidReason", true, false);
290        }
291        
292        
293        /** Checks whether {@code 'this'} equals an input Java-{@code Object} */
294        public boolean equals(Object other)
295        {
296            if (other == null)                       return false;
297            if (other.getClass() != this.getClass()) return false;
298        
299            AXValueSource o = (AXValueSource) other;
300        
301            return
302                    Objects.equals(this.type, o.type)
303                &&  Objects.equals(this.value, o.value)
304                &&  Objects.equals(this.attribute, o.attribute)
305                &&  Objects.equals(this.attributeValue, o.attributeValue)
306                &&  Objects.equals(this.superseded, o.superseded)
307                &&  Objects.equals(this.nativeSource, o.nativeSource)
308                &&  Objects.equals(this.nativeSourceValue, o.nativeSourceValue)
309                &&  Objects.equals(this.invalid, o.invalid)
310                &&  Objects.equals(this.invalidReason, o.invalidReason);
311        }
312        
313        /** Generates a Hash-Code for {@code 'this'} instance */
314        public int hashCode()
315        {
316            return
317                    Objects.hashCode(this.type)
318                +   this.value.hashCode()
319                +   Objects.hashCode(this.attribute)
320                +   this.attributeValue.hashCode()
321                +   Objects.hashCode(this.superseded)
322                +   Objects.hashCode(this.nativeSource)
323                +   this.nativeSourceValue.hashCode()
324                +   Objects.hashCode(this.invalid)
325                +   Objects.hashCode(this.invalidReason);
326        }
327    }
328    
329    /** <CODE>[No Description Provided by Google]</CODE> */
330    public static class AXRelatedNode
331        extends BaseType
332        implements java.io.Serializable
333    {
334        /** For Object Serialization.  java.io.Serializable */
335        protected static final long serialVersionUID = 1;
336        
337        public boolean[] optionals()
338        { return new boolean[] { false, true, true, }; }
339        
340        /** The BackendNodeId of the related DOM node. */
341        public final int backendDOMNodeId;
342        
343        /**
344         * The IDRef value provided, if any.
345         * <BR />
346         * <BR /><B>OPTIONAL</B>
347         */
348        public final String idref;
349        
350        /**
351         * The text alternative of this node in the current context.
352         * <BR />
353         * <BR /><B>OPTIONAL</B>
354         */
355        public final String text;
356        
357        /**
358         * Constructor
359         *
360         * @param backendDOMNodeId The BackendNodeId of the related DOM node.
361         * 
362         * @param idref The IDRef value provided, if any.
363         * <BR /><B>OPTIONAL</B>
364         * 
365         * @param text The text alternative of this node in the current context.
366         * <BR /><B>OPTIONAL</B>
367         */
368        public AXRelatedNode(int backendDOMNodeId, String idref, String text)
369        {
370            this.backendDOMNodeId  = backendDOMNodeId;
371            this.idref             = idref;
372            this.text              = text;
373        }
374        
375        /**
376         * JSON Object Constructor
377         * @param jo A Json-Object having data about an instance of {@code 'AXRelatedNode'}.
378         */
379        public AXRelatedNode (JsonObject jo)
380        {
381            this.backendDOMNodeId  = ReadPrimJSON.getInt(jo, "backendDOMNodeId");
382            this.idref             = ReadJSON.getString(jo, "idref", true, false);
383            this.text              = ReadJSON.getString(jo, "text", true, false);
384        }
385        
386        
387        /** Checks whether {@code 'this'} equals an input Java-{@code Object} */
388        public boolean equals(Object other)
389        {
390            if (other == null)                       return false;
391            if (other.getClass() != this.getClass()) return false;
392        
393            AXRelatedNode o = (AXRelatedNode) other;
394        
395            return
396                    Objects.equals(this.backendDOMNodeId, o.backendDOMNodeId)
397                &&  Objects.equals(this.idref, o.idref)
398                &&  Objects.equals(this.text, o.text);
399        }
400        
401        /** Generates a Hash-Code for {@code 'this'} instance */
402        public int hashCode()
403        {
404            return
405                    this.backendDOMNodeId
406                +   Objects.hashCode(this.idref)
407                +   Objects.hashCode(this.text);
408        }
409    }
410    
411    /** <CODE>[No Description Provided by Google]</CODE> */
412    public static class AXProperty
413        extends BaseType
414        implements java.io.Serializable
415    {
416        /** For Object Serialization.  java.io.Serializable */
417        protected static final long serialVersionUID = 1;
418        
419        public boolean[] optionals()
420        { return new boolean[] { false, false, }; }
421        
422        /** The name of this property. */
423        public final String name;
424        
425        /** The value of this property. */
426        public final Accessibility.AXValue value;
427        
428        /**
429         * Constructor
430         *
431         * @param name The name of this property.
432         * 
433         * @param value The value of this property.
434         */
435        public AXProperty(String name, Accessibility.AXValue value)
436        {
437            // Exception-Check(s) to ensure that if any parameters which are not declared as
438            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
439            
440            if (name == null)  BRDPC.throwNPE("name");
441            if (value == null) BRDPC.throwNPE("value");
442            
443            // Exception-Check(s) to ensure that if any parameters which must adhere to a
444            // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw.
445            
446            BRDPC.checkIAE("name", name, "Accessibility.AXPropertyName", Accessibility.AXPropertyName);
447            
448            this.name   = name;
449            this.value  = value;
450        }
451        
452        /**
453         * JSON Object Constructor
454         * @param jo A Json-Object having data about an instance of {@code 'AXProperty'}.
455         */
456        public AXProperty (JsonObject jo)
457        {
458            this.name   = ReadJSON.getString(jo, "name", false, true);
459            this.value  = ReadJSON.getObject(jo, "value", Accessibility.AXValue.class, false, true);
460        }
461        
462        
463        /** Checks whether {@code 'this'} equals an input Java-{@code Object} */
464        public boolean equals(Object other)
465        {
466            if (other == null)                       return false;
467            if (other.getClass() != this.getClass()) return false;
468        
469            AXProperty o = (AXProperty) other;
470        
471            return
472                    Objects.equals(this.name, o.name)
473                &&  Objects.equals(this.value, o.value);
474        }
475        
476        /** Generates a Hash-Code for {@code 'this'} instance */
477        public int hashCode()
478        {
479            return
480                    Objects.hashCode(this.name)
481                +   this.value.hashCode();
482        }
483    }
484    
485    /** A single computed AX property. */
486    public static class AXValue
487        extends BaseType
488        implements java.io.Serializable
489    {
490        /** For Object Serialization.  java.io.Serializable */
491        protected static final long serialVersionUID = 1;
492        
493        public boolean[] optionals()
494        { return new boolean[] { false, true, true, true, }; }
495        
496        /** The type of this value. */
497        public final String type;
498        
499        /**
500         * The computed value of this property.
501         * <BR />
502         * <BR /><B>OPTIONAL</B>
503         */
504        public final JsonValue value;
505        
506        /**
507         * One or more related nodes, if applicable.
508         * <BR />
509         * <BR /><B>OPTIONAL</B>
510         */
511        public final Accessibility.AXRelatedNode[] relatedNodes;
512        
513        /**
514         * The sources which contributed to the computation of this property.
515         * <BR />
516         * <BR /><B>OPTIONAL</B>
517         */
518        public final Accessibility.AXValueSource[] sources;
519        
520        /**
521         * Constructor
522         *
523         * @param type The type of this value.
524         * 
525         * @param value The computed value of this property.
526         * <BR /><B>OPTIONAL</B>
527         * 
528         * @param relatedNodes One or more related nodes, if applicable.
529         * <BR /><B>OPTIONAL</B>
530         * 
531         * @param sources The sources which contributed to the computation of this property.
532         * <BR /><B>OPTIONAL</B>
533         */
534        public AXValue(
535                String type, JsonValue value, Accessibility.AXRelatedNode[] relatedNodes, 
536                Accessibility.AXValueSource[] sources
537            )
538        {
539            // Exception-Check(s) to ensure that if any parameters which are not declared as
540            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
541            
542            if (type == null) BRDPC.throwNPE("type");
543            
544            // Exception-Check(s) to ensure that if any parameters which must adhere to a
545            // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw.
546            
547            BRDPC.checkIAE("type", type, "Accessibility.AXValueType", Accessibility.AXValueType);
548            
549            this.type          = type;
550            this.value         = value;
551            this.relatedNodes  = relatedNodes;
552            this.sources       = sources;
553        }
554        
555        /**
556         * JSON Object Constructor
557         * @param jo A Json-Object having data about an instance of {@code 'AXValue'}.
558         */
559        public AXValue (JsonObject jo)
560        {
561            this.type          = ReadJSON.getString(jo, "type", false, true);
562            this.value         = jo.get("value");
563            this.relatedNodes = (jo.getJsonArray("relatedNodes") == null)
564                ? null
565                : ReadArrJSON.DimN.objArr(jo.getJsonArray("relatedNodes"), null, 0, Accessibility.AXRelatedNode[].class);
566        
567            this.sources = (jo.getJsonArray("sources") == null)
568                ? null
569                : ReadArrJSON.DimN.objArr(jo.getJsonArray("sources"), null, 0, Accessibility.AXValueSource[].class);
570        
571        }
572        
573        
574        /** Checks whether {@code 'this'} equals an input Java-{@code Object} */
575        public boolean equals(Object other)
576        {
577            if (other == null)                       return false;
578            if (other.getClass() != this.getClass()) return false;
579        
580            AXValue o = (AXValue) other;
581        
582            return
583                    Objects.equals(this.type, o.type)
584                &&  Objects.equals(this.value, o.value)
585                &&  Arrays.deepEquals(this.relatedNodes, o.relatedNodes)
586                &&  Arrays.deepEquals(this.sources, o.sources);
587        }
588        
589        /** Generates a Hash-Code for {@code 'this'} instance */
590        public int hashCode()
591        {
592            return
593                    Objects.hashCode(this.type)
594                +   Objects.hashCode(this.value)
595                +   Arrays.deepHashCode(this.relatedNodes)
596                +   Arrays.deepHashCode(this.sources);
597        }
598    }
599    
600    /** A node in the accessibility tree. */
601    public static class AXNode
602        extends BaseType
603        implements java.io.Serializable
604    {
605        /** For Object Serialization.  java.io.Serializable */
606        protected static final long serialVersionUID = 1;
607        
608        public boolean[] optionals()
609        { return new boolean[] { false, false, true, true, true, true, true, true, true, true, }; }
610        
611        /** Unique identifier for this node. */
612        public final String nodeId;
613        
614        /** Whether this node is ignored for accessibility */
615        public final boolean ignored;
616        
617        /**
618         * Collection of reasons why this node is hidden.
619         * <BR />
620         * <BR /><B>OPTIONAL</B>
621         */
622        public final Accessibility.AXProperty[] ignoredReasons;
623        
624        /**
625         * This <CODE>Node</CODE>'s role, whether explicit or implicit.
626         * <BR />
627         * <BR /><B>OPTIONAL</B>
628         */
629        public final Accessibility.AXValue role;
630        
631        /**
632         * The accessible name for this <CODE>Node</CODE>.
633         * <BR />
634         * <BR /><B>OPTIONAL</B>
635         */
636        public final Accessibility.AXValue name;
637        
638        /**
639         * The accessible description for this <CODE>Node</CODE>.
640         * <BR />
641         * <BR /><B>OPTIONAL</B>
642         */
643        public final Accessibility.AXValue description;
644        
645        /**
646         * The value for this <CODE>Node</CODE>.
647         * <BR />
648         * <BR /><B>OPTIONAL</B>
649         */
650        public final Accessibility.AXValue value;
651        
652        /**
653         * All other properties
654         * <BR />
655         * <BR /><B>OPTIONAL</B>
656         */
657        public final Accessibility.AXProperty[] properties;
658        
659        /**
660         * IDs for each of this node's child nodes.
661         * <BR />
662         * <BR /><B>OPTIONAL</B>
663         */
664        public final String[] childIds;
665        
666        /**
667         * The backend ID for the associated DOM node, if any.
668         * <BR />
669         * <BR /><B>OPTIONAL</B>
670         */
671        public final Integer backendDOMNodeId;
672        
673        /**
674         * Constructor
675         *
676         * @param nodeId Unique identifier for this node.
677         * 
678         * @param ignored Whether this node is ignored for accessibility
679         * 
680         * @param ignoredReasons Collection of reasons why this node is hidden.
681         * <BR /><B>OPTIONAL</B>
682         * 
683         * @param role This <CODE>Node</CODE>'s role, whether explicit or implicit.
684         * <BR /><B>OPTIONAL</B>
685         * 
686         * @param name The accessible name for this <CODE>Node</CODE>.
687         * <BR /><B>OPTIONAL</B>
688         * 
689         * @param description The accessible description for this <CODE>Node</CODE>.
690         * <BR /><B>OPTIONAL</B>
691         * 
692         * @param value The value for this <CODE>Node</CODE>.
693         * <BR /><B>OPTIONAL</B>
694         * 
695         * @param properties All other properties
696         * <BR /><B>OPTIONAL</B>
697         * 
698         * @param childIds IDs for each of this node's child nodes.
699         * <BR /><B>OPTIONAL</B>
700         * 
701         * @param backendDOMNodeId The backend ID for the associated DOM node, if any.
702         * <BR /><B>OPTIONAL</B>
703         */
704        public AXNode(
705                String nodeId, boolean ignored, Accessibility.AXProperty[] ignoredReasons, 
706                Accessibility.AXValue role, Accessibility.AXValue name, 
707                Accessibility.AXValue description, Accessibility.AXValue value, 
708                Accessibility.AXProperty[] properties, String[] childIds, Integer backendDOMNodeId
709            )
710        {
711            // Exception-Check(s) to ensure that if any parameters which are not declared as
712            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
713            
714            if (nodeId == null) BRDPC.throwNPE("nodeId");
715            
716            this.nodeId            = nodeId;
717            this.ignored           = ignored;
718            this.ignoredReasons    = ignoredReasons;
719            this.role              = role;
720            this.name              = name;
721            this.description       = description;
722            this.value             = value;
723            this.properties        = properties;
724            this.childIds          = childIds;
725            this.backendDOMNodeId  = backendDOMNodeId;
726        }
727        
728        /**
729         * JSON Object Constructor
730         * @param jo A Json-Object having data about an instance of {@code 'AXNode'}.
731         */
732        public AXNode (JsonObject jo)
733        {
734            this.nodeId            = ReadJSON.getString(jo, "nodeId", false, true);
735            this.ignored           = ReadPrimJSON.getBoolean(jo, "ignored");
736            this.ignoredReasons = (jo.getJsonArray("ignoredReasons") == null)
737                ? null
738                : ReadArrJSON.DimN.objArr(jo.getJsonArray("ignoredReasons"), null, 0, Accessibility.AXProperty[].class);
739        
740            this.role              = ReadJSON.getObject(jo, "role", Accessibility.AXValue.class, true, false);
741            this.name              = ReadJSON.getObject(jo, "name", Accessibility.AXValue.class, true, false);
742            this.description       = ReadJSON.getObject(jo, "description", Accessibility.AXValue.class, true, false);
743            this.value             = ReadJSON.getObject(jo, "value", Accessibility.AXValue.class, true, false);
744            this.properties = (jo.getJsonArray("properties") == null)
745                ? null
746                : ReadArrJSON.DimN.objArr(jo.getJsonArray("properties"), null, 0, Accessibility.AXProperty[].class);
747        
748            this.childIds = (jo.getJsonArray("childIds") == null)
749                ? null
750                : ReadArrJSON.DimN.strArr(jo.getJsonArray("childIds"), null, 0, String[].class);
751        
752            this.backendDOMNodeId  = ReadBoxedJSON.getInteger(jo, "backendDOMNodeId", true);
753        }
754        
755        
756        /** Checks whether {@code 'this'} equals an input Java-{@code Object} */
757        public boolean equals(Object other)
758        {
759            if (other == null)                       return false;
760            if (other.getClass() != this.getClass()) return false;
761        
762            AXNode o = (AXNode) other;
763        
764            return
765                    Objects.equals(this.nodeId, o.nodeId)
766                &&  (this.ignored == o.ignored)
767                &&  Arrays.deepEquals(this.ignoredReasons, o.ignoredReasons)
768                &&  Objects.equals(this.role, o.role)
769                &&  Objects.equals(this.name, o.name)
770                &&  Objects.equals(this.description, o.description)
771                &&  Objects.equals(this.value, o.value)
772                &&  Arrays.deepEquals(this.properties, o.properties)
773                &&  Arrays.deepEquals(this.childIds, o.childIds)
774                &&  Objects.equals(this.backendDOMNodeId, o.backendDOMNodeId);
775        }
776        
777        /** Generates a Hash-Code for {@code 'this'} instance */
778        public int hashCode()
779        {
780            return
781                    Objects.hashCode(this.nodeId)
782                +   (this.ignored ? 1 : 0)
783                +   Arrays.deepHashCode(this.ignoredReasons)
784                +   this.role.hashCode()
785                +   this.name.hashCode()
786                +   this.description.hashCode()
787                +   this.value.hashCode()
788                +   Arrays.deepHashCode(this.properties)
789                +   Arrays.deepHashCode(this.childIds)
790                +   Objects.hashCode(this.backendDOMNodeId);
791        }
792    }
793    
794    
795    // Counter for keeping the WebSocket Request ID's distinct.
796    private static int counter = 1;
797    
798    /**
799     * Disables the accessibility domain.
800     * 
801     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
802     * {@link Ret0}&gt;</CODE>
803     *
804     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
805     * browser receives the invocation-request.
806     *
807     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
808     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
809     * {@code >} to ensure the Browser Function has run to completion.
810     */
811    public static Script<String, JsonObject, Ret0> disable()
812    {
813        final int          webSocketID = 7000000 + counter++;
814        final boolean[]    optionals   = new boolean[0];
815        
816        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
817        String requestJSON = WriteJSON.get(
818            parameterTypes.get("disable"),
819            parameterNames.get("disable"),
820            optionals, webSocketID,
821            "Accessibility.disable"
822        );
823        
824        // This Remote Command does not have a Return-Value.
825        return new Script<>
826            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
827    }
828    
829    /**
830     * Enables the accessibility domain which causes <CODE>AXNodeId</CODE>s to remain consistent between method calls.
831     * This turns on accessibility for the page, which can impact performance until accessibility is disabled.
832     * 
833     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
834     * {@link Ret0}&gt;</CODE>
835     *
836     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
837     * browser receives the invocation-request.
838     *
839     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
840     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
841     * {@code >} to ensure the Browser Function has run to completion.
842     */
843    public static Script<String, JsonObject, Ret0> enable()
844    {
845        final int          webSocketID = 7001000 + counter++;
846        final boolean[]    optionals   = new boolean[0];
847        
848        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
849        String requestJSON = WriteJSON.get(
850            parameterTypes.get("enable"),
851            parameterNames.get("enable"),
852            optionals, webSocketID,
853            "Accessibility.enable"
854        );
855        
856        // This Remote Command does not have a Return-Value.
857        return new Script<>
858            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
859    }
860    
861    /**
862     * Fetches the accessibility node and partial accessibility tree for this DOM node, if it exists.
863     * <BR /><B>EXPERIMENTAL</B>
864     * 
865     * @param nodeId Identifier of the node to get the partial accessibility tree for.
866     * <BR /><B>OPTIONAL</B>
867     * 
868     * @param backendNodeId Identifier of the backend node to get the partial accessibility tree for.
869     * <BR /><B>OPTIONAL</B>
870     * 
871     * @param objectId JavaScript object id of the node wrapper to get the partial accessibility tree for.
872     * <BR /><B>OPTIONAL</B>
873     * 
874     * @param fetchRelatives Whether to fetch this nodes ancestors, siblings and children. Defaults to true.
875     * <BR /><B>OPTIONAL</B>
876     * 
877     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
878     * {@link Accessibility.AXNode}[]&gt;</CODE>
879     * 
880     * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using
881     * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE>&lt;JsonObject,
882     * {@link Accessibility.AXNode}[]&gt;</CODE> will be returned.
883     *
884     * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>,
885     * using {@link Promise#await()}, <I>and the returned result of this Browser Function may
886      * may be retrieved.</I>
887     *
888     * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B>
889     * <BR /><BR /><UL CLASS=JDUL>
890     * <LI><CODE>{@link Accessibility.AXNode}[] (<B>nodes</B></CODE>)
891     *     <BR />The <CODE>Accessibility.AXNode</CODE> for this DOM node, if it exists, plus its ancestors, siblings and
892     *     children, if requested.
893     * </LI>
894     * </UL> */
895    public static Script<String, JsonObject, Accessibility.AXNode[]> getPartialAXTree
896        (Integer nodeId, Integer backendNodeId, String objectId, Boolean fetchRelatives)
897    {
898        final int       webSocketID = 7002000 + counter++;
899        final boolean[] optionals   = { true, true, true, true, };
900        
901        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
902        String requestJSON = WriteJSON.get(
903            parameterTypes.get("getPartialAXTree"),
904            parameterNames.get("getPartialAXTree"),
905            optionals, webSocketID,
906            "Accessibility.getPartialAXTree",
907            nodeId, backendNodeId, objectId, fetchRelatives
908        );
909        
910        // 'JSON Binding' ... Converts Browser Response-JSON to 'Accessibility.AXNode[]'
911        Function<JsonObject, Accessibility.AXNode[]> responseProcessor = (JsonObject jo) ->
912            (jo.getJsonArray("nodes") == null)
913                ? null
914                : ReadArrJSON.DimN.objArr(jo.getJsonArray("nodes"), null, 0, Accessibility.AXNode[].class);
915        
916        // Pass the 'defaultSender' to Script-Constructor
917        // The sender that is used can be changed before executing script.
918        return new Script<>(BRDPC.defaultSender, webSocketID, requestJSON, responseProcessor);
919    }
920    
921    /**
922     * Fetches the entire accessibility tree for the root Document
923     * <BR /><B>EXPERIMENTAL</B>
924     * 
925     * @param depth 
926     * The maximum depth at which descendants of the root node should be retrieved.
927     * If omitted, the full tree is returned.
928     * <BR /><B>OPTIONAL</B>
929     * 
930     * @param max_depth Deprecated. This parameter has been renamed to <CODE>depth</CODE>. If depth is not provided, max_depth will be used.
931     * <BR /><B>OPTIONAL</B>
932     * <BR /><B>DEPRECATED</B>
933     * 
934     * @param frameId 
935     * The frame for whose document the AX tree should be retrieved.
936     * If omited, the root frame is used.
937     * <BR /><B>OPTIONAL</B>
938     * 
939     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
940     * {@link Accessibility.AXNode}[]&gt;</CODE>
941     * 
942     * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using
943     * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE>&lt;JsonObject,
944     * {@link Accessibility.AXNode}[]&gt;</CODE> will be returned.
945     *
946     * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>,
947     * using {@link Promise#await()}, <I>and the returned result of this Browser Function may
948      * may be retrieved.</I>
949     *
950     * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B>
951     * <BR /><BR /><UL CLASS=JDUL>
952     * <LI><CODE>{@link Accessibility.AXNode}[] (<B>nodes</B></CODE>)
953     *     <BR />-
954     * </LI>
955     * </UL> */
956    public static Script<String, JsonObject, Accessibility.AXNode[]> getFullAXTree
957        (Integer depth, Integer max_depth, String frameId)
958    {
959        final int       webSocketID = 7003000 + counter++;
960        final boolean[] optionals   = { true, true, true, };
961        
962        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
963        String requestJSON = WriteJSON.get(
964            parameterTypes.get("getFullAXTree"),
965            parameterNames.get("getFullAXTree"),
966            optionals, webSocketID,
967            "Accessibility.getFullAXTree",
968            depth, max_depth, frameId
969        );
970        
971        // 'JSON Binding' ... Converts Browser Response-JSON to 'Accessibility.AXNode[]'
972        Function<JsonObject, Accessibility.AXNode[]> responseProcessor = (JsonObject jo) ->
973            (jo.getJsonArray("nodes") == null)
974                ? null
975                : ReadArrJSON.DimN.objArr(jo.getJsonArray("nodes"), null, 0, Accessibility.AXNode[].class);
976        
977        // Pass the 'defaultSender' to Script-Constructor
978        // The sender that is used can be changed before executing script.
979        return new Script<>(BRDPC.defaultSender, webSocketID, requestJSON, responseProcessor);
980    }
981    
982    /**
983     * Fetches a particular accessibility node by AXNodeId.
984     * Requires <CODE>enable()</CODE> to have been called previously.
985     * <BR /><B>EXPERIMENTAL</B>
986     * 
987     * @param id -
988     * 
989     * @param frameId 
990     * The frame in whose document the node resides.
991     * If omitted, the root frame is used.
992     * <BR /><B>OPTIONAL</B>
993     * 
994     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
995     * {@link Accessibility.AXNode}[]&gt;</CODE>
996     * 
997     * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using
998     * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE>&lt;JsonObject,
999     * {@link Accessibility.AXNode}[]&gt;</CODE> will be returned.
1000     *
1001     * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>,
1002     * using {@link Promise#await()}, <I>and the returned result of this Browser Function may
1003      * may be retrieved.</I>
1004     *
1005     * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B>
1006     * <BR /><BR /><UL CLASS=JDUL>
1007     * <LI><CODE>{@link Accessibility.AXNode}[] (<B>nodes</B></CODE>)
1008     *     <BR />-
1009     * </LI>
1010     * </UL> */
1011    public static Script<String, JsonObject, Accessibility.AXNode[]> getChildAXNodes
1012        (String id, String frameId)
1013    {
1014        // Exception-Check(s) to ensure that if any parameters which are not declared as
1015        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
1016        
1017        if (id == null) BRDPC.throwNPE("id");
1018        
1019        final int       webSocketID = 7004000 + counter++;
1020        final boolean[] optionals   = { false, true, };
1021        
1022        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
1023        String requestJSON = WriteJSON.get(
1024            parameterTypes.get("getChildAXNodes"),
1025            parameterNames.get("getChildAXNodes"),
1026            optionals, webSocketID,
1027            "Accessibility.getChildAXNodes",
1028            id, frameId
1029        );
1030        
1031        // 'JSON Binding' ... Converts Browser Response-JSON to 'Accessibility.AXNode[]'
1032        Function<JsonObject, Accessibility.AXNode[]> responseProcessor = (JsonObject jo) ->
1033            (jo.getJsonArray("nodes") == null)
1034                ? null
1035                : ReadArrJSON.DimN.objArr(jo.getJsonArray("nodes"), null, 0, Accessibility.AXNode[].class);
1036        
1037        // Pass the 'defaultSender' to Script-Constructor
1038        // The sender that is used can be changed before executing script.
1039        return new Script<>(BRDPC.defaultSender, webSocketID, requestJSON, responseProcessor);
1040    }
1041    
1042    /**
1043     * Query a DOM node's accessibility subtree for accessible name and role.
1044     * This command computes the name and role for all nodes in the subtree, including those that are
1045     * ignored for accessibility, and returns those that mactch the specified name and role. If no DOM
1046     * node is specified, or the DOM node does not exist, the command returns an error. If neither
1047     * <CODE>accessibleName</CODE> or <CODE>role</CODE> is specified, it returns all the accessibility nodes in the subtree.
1048     * <BR /><B>EXPERIMENTAL</B>
1049     * 
1050     * @param nodeId Identifier of the node for the root to query.
1051     * <BR /><B>OPTIONAL</B>
1052     * 
1053     * @param backendNodeId Identifier of the backend node for the root to query.
1054     * <BR /><B>OPTIONAL</B>
1055     * 
1056     * @param objectId JavaScript object id of the node wrapper for the root to query.
1057     * <BR /><B>OPTIONAL</B>
1058     * 
1059     * @param accessibleName Find nodes with this computed name.
1060     * <BR /><B>OPTIONAL</B>
1061     * 
1062     * @param role Find nodes with this computed role.
1063     * <BR /><B>OPTIONAL</B>
1064     * 
1065     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
1066     * {@link Accessibility.AXNode}[]&gt;</CODE>
1067     * 
1068     * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using
1069     * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE>&lt;JsonObject,
1070     * {@link Accessibility.AXNode}[]&gt;</CODE> will be returned.
1071     *
1072     * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>,
1073     * using {@link Promise#await()}, <I>and the returned result of this Browser Function may
1074      * may be retrieved.</I>
1075     *
1076     * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B>
1077     * <BR /><BR /><UL CLASS=JDUL>
1078     * <LI><CODE>{@link Accessibility.AXNode}[] (<B>nodes</B></CODE>)
1079     *     <BR />A list of <CODE>Accessibility.AXNode</CODE> matching the specified attributes,
1080     *     including nodes that are ignored for accessibility.
1081     * </LI>
1082     * </UL> */
1083    public static Script<String, JsonObject, Accessibility.AXNode[]> queryAXTree
1084        (Integer nodeId, Integer backendNodeId, String objectId, String accessibleName, String role)
1085    {
1086        final int       webSocketID = 7005000 + counter++;
1087        final boolean[] optionals   = { true, true, true, true, true, };
1088        
1089        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
1090        String requestJSON = WriteJSON.get(
1091            parameterTypes.get("queryAXTree"),
1092            parameterNames.get("queryAXTree"),
1093            optionals, webSocketID,
1094            "Accessibility.queryAXTree",
1095            nodeId, backendNodeId, objectId, accessibleName, role
1096        );
1097        
1098        // 'JSON Binding' ... Converts Browser Response-JSON to 'Accessibility.AXNode[]'
1099        Function<JsonObject, Accessibility.AXNode[]> responseProcessor = (JsonObject jo) ->
1100            (jo.getJsonArray("nodes") == null)
1101                ? null
1102                : ReadArrJSON.DimN.objArr(jo.getJsonArray("nodes"), null, 0, Accessibility.AXNode[].class);
1103        
1104        // Pass the 'defaultSender' to Script-Constructor
1105        // The sender that is used can be changed before executing script.
1106        return new Script<>(BRDPC.defaultSender, webSocketID, requestJSON, responseProcessor);
1107    }
1108    
1109}