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