Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   /*
    * Copyright (c) 2008-2014 Mozilla Foundation
    *
    * Permission is hereby granted, free of charge, to any person obtaining a 
    * copy of this software and associated documentation files (the "Software"), 
    * to deal in the Software without restriction, including without limitation 
    * the rights to use, copy, modify, merge, publish, distribute, sublicense, 
    * and/or sell copies of the Software, and to permit persons to whom the 
    * Software is furnished to do so, subject to the following conditions:
   *
   * The above copyright notice and this permission notice shall be included in 
   * all copies or substantial portions of the Software.
   *
   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
   * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
   * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
   * DEALINGS IN THE SOFTWARE.
   */
  
  package org.whattf.checker.schematronequiv;
  
  import java.util.HashMap;
  import java.util.HashSet;
  import java.util.Map;
  import java.util.Set;
  import java.util.Arrays;
  
  
  public class Assertions extends Checker {
  
      private static boolean w3cBranding = "1".equals(System.getProperty("nu.validator.servlet.w3cbranding")) ? true
              : false;
  
      private static boolean lowerCaseLiteralEqualsIgnoreAsciiCaseString(
              String lowerCaseLiteralString string) {
          if (string == null) {
              return false;
          }
          if (lowerCaseLiteral.length() != string.length()) {
              return false;
          }
          for (int i = 0; i < lowerCaseLiteral.length(); i++) {
              char c0 = lowerCaseLiteral.charAt(i);
              char c1 = string.charAt(i);
              if (c1 >= 'A' && c1 <= 'Z') {
                  c1 += 0x20;
              }
              if (c0 != c1) {
                  return false;
              }
          }
          return true;
      }
  
      private static boolean equalsIgnoreAsciiCase(String oneString other) {
          if (other == null) {
              if (one == null) {
                  return true;
              } else {
                  return false;
              }
          }
          if (one.length() != other.length()) {
              return false;
          }
          for (int i = 0; i < one.length(); i++) {
              char c0 = one.charAt(i);
              char c1 = other.charAt(i);
              if (c0 >= 'A' && c0 <= 'Z') {
                  c0 += 0x20;
              }
              if (c1 >= 'A' && c1 <= 'Z') {
                  c1 += 0x20;
              }
              if (c0 != c1) {
                  return false;
              }
          }
          return true;
      }
  
      private static final String trimSpaces(String str) {
          return trimLeadingSpaces(trimTrailingSpaces(str));
      }
  
      private static final String trimLeadingSpaces(String str) {
          if (str == null) {
             return null;
         }
         for (int i = str.length(); i > 0; --i) {
             char c = str.charAt(str.length() - i);
             if (!(' ' == c || '\t' == c || '\n' == c || '\f' == c || '\r' == c)) {
                 return str.substring(str.length() - istr.length());
             }
         }
         return "";
     }
 
     private static final String trimTrailingSpaces(String str) {
         if (str == null) {
             return null;
         }
         for (int i = str.length() - 1; i >= 0; --i) {
             char c = str.charAt(i);
             if (!(' ' == c || '\t' == c || '\n' == c || '\f' == c || '\r' == c)) {
                 return str.substring(0, i + 1);
             }
         }
         return "";
     }
 
     private static final Map<StringStringOBSOLETE_ELEMENTS = new HashMap<StringString>();
 
     static {
         .put("center""Use CSS instead.");
         .put("font""Use CSS instead.");
         .put("big""Use CSS instead.");
         .put("strike""Use CSS instead.");
         .put("tt""Use CSS instead.");
         .put("acronym",
                 "Use the \u201Cabbr\u201D element instead.");
         .put("dir""Use the \u201Cul\u201D element instead.");
         .put("applet",
                 "Use the \u201Cobject\u201D element instead.");
         .put("basefont""Use CSS instead.");
         .put(
                 "frameset",
                 "Use the \u201Ciframe\u201D element and CSS instead, or use server-side includes.");
         .put(
                 "noframes",
                 "Use the \u201Ciframe\u201D element and CSS instead, or use server-side includes.");
         if () {
             .put(
                     "hgroup",
                     "To mark up subheadings, consider either just putting the "
                             + "subheading into a \u201Cp\u201D element after the "
                             + "\u201Ch1\u201D-\u201Ch6\u201D element containing the "
                             + "main heading, or else putting the subheading directly "
                             + "within the \u201Ch1\u201D-\u201Ch6\u201D element "
                             + "containing the main heading, but separated from the main "
                             + "heading by punctuation and/or within, for example, a "
                             + "\u201Cspan class=\"subheading\"\u201D element with "
                             + "differentiated styling. "
                             + "To group headings and subheadings, alternative titles, "
                             + "or taglines, consider using the \u201Cheader\u201D or "
                             + "\u201Cdiv\u201D elements.");
         }
     }
 
     private static final Map<StringString[]> OBSOLETE_ATTRIBUTES = new HashMap<StringString[]>();
 
     static {
         .put("abbr"new String[] { "td""th" });
         .put("archive"new String[] { "object" });
         .put("axis"new String[] { "td""th" });
         .put("charset"new String[] { "link""a" });
         .put("classid"new String[] { "object" });
         .put("code"new String[] { "object" });
         .put("codebase"new String[] { "object" });
         .put("codetype"new String[] { "object" });
         .put("coords"new String[] { "a" });
         .put("datafld"new String[] { "span""div",
                 "object""input""select""textarea""button""table" });
         .put("dataformatas"new String[] { "span""div",
                 "object""input""select""textarea""button""table" });
         .put("datasrc"new String[] { "span""div",
                 "object""input""select""textarea""button""table" });
         .put("datapagesize"new String[] { "table" });
         .put("declare"new String[] { "object" });
         .put("event"new String[] { "script" });
         .put("for"new String[] { "script" });
         .put("language"new String[] { "script" });
         if (!) {
             .put("longdesc",
                     new String[] { "img""iframe" });
         }
         .put("methods"new String[] { "link""a" });
         .put("name"new String[] { "img""embed""option" });
         .put("nohref"new String[] { "area" });
         .put("profile"new String[] { "head" });
         .put("scheme"new String[] { "meta" });
         .put("scope"new String[] { "td" });
         .put("shape"new String[] { "a" });
         .put("standby"new String[] { "object" });
         .put("target"new String[] { "link" });
         .put("type"new String[] { "param" });
         .put("urn"new String[] { "a""link" });
         .put("usemap"new String[] { "input" });
         .put("valuetype"new String[] { "param" });
         .put("version"new String[] { "html" });
     }
 
     private static final Map<StringStringOBSOLETE_ATTRIBUTES_MSG = new HashMap<StringString>();
 
     static {
         .put(
                 "abbr",
                 "Consider instead beginning the cell contents with concise text, followed by further elaboration if needed.");
         .put(
                 "archive",
                 "Use the \u201Cdata\u201D and \u201Ctype\u201D attributes to invoke plugins. To set a parameter with the name \u201Carchive\u201D, use the \u201Cparam\u201D element.");
         .put("axis",
                 "Use the \u201Cscope\u201D attribute.");
         .put("charset",
                 "Use an HTTP Content-Type header on the linked resource instead.");
         .put(
                 "classid",
                 "Use the \u201Cdata\u201D and \u201Ctype\u201D attributes to invoke plugins. To set a parameter with the name \u201Cclassid\u201D, use the \u201Cparam\u201D element.");
         .put(
                 "code",
                 "Use the \u201Cdata\u201D and \u201Ctype\u201D attributes to invoke plugins. To set a parameter with the name \u201Ccode\u201D, use the \u201Cparam\u201D element.");
         .put(
                 "codebase",
                 "Use the \u201Cdata\u201D and \u201Ctype\u201D attributes to invoke plugins. To set a parameter with the name \u201Ccodebase\u201D, use the \u201Cparam\u201D element.");
         .put(
                 "codetype",
                 "Use the \u201Cdata\u201D and \u201Ctype\u201D attributes to invoke plugins. To set a parameter with the name \u201Ccodetype\u201D, use the \u201Cparam\u201D element.");
         .put("coords",
                 "Use \u201Carea\u201D instead of \u201Ca\u201D for image maps.");
         .put("datapagesize""You can safely omit it.");
         .put("datafld""Use script and a mechanism such as XMLHttpRequest to populate the page dynamically");
         .put("dataformatas""Use script and a mechanism such as XMLHttpRequest to populate the page dynamically");
         .put("datasrc""Use script and a mechanism such as XMLHttpRequest to populate the page dynamically");
         .put("for",
                 "Use DOM Events mechanisms to register event listeners.");
         .put("event",
                 "Use DOM Events mechanisms to register event listeners.");
         .put(
                 "declare",
                 "Repeat the \u201Cobject\u201D element completely each time the resource is to be reused.");
         .put("language",
                 "Use the \u201Ctype\u201D attribute instead.");
         if (!) {
             .put("longdesc",
                     "Use a regular \u201Ca\u201D element to link to the description.");
         }
         .put("methods",
                 "Use the HTTP OPTIONS feature instead.");
         .put("name",
                 "Use the \u201Cid\u201D attribute instead.");
         .put("nohref",
                 "Omitting the \u201Chref\u201D attribute is sufficient.");
         .put(
                 "profile",
                 "To declare which \u201Cmeta\u201D terms are used in the document, instead register the names as meta extensions. To trigger specific UA behaviors, use a \u201Clink\u201D element instead.");
         .put(
                 "scheme",
                 "Use only one scheme per field, or make the scheme declaration part of the value.");
         .put("scope",
                 "Use the \u201Cscope\u201D attribute on a \u201Cth\u201D element instead.");
         .put("shape",
                 "Use \u201Carea\u201D instead of \u201Ca\u201D for image maps.");
         .put(
                 "standby",
                 "Optimise the linked resource so that it loads quickly or, at least, incrementally.");
         .put("target""You can safely omit it.");
         .put(
                 "type",
                 "Use the \u201Cname\u201D and \u201Cvalue\u201D attributes without declaring value types.");
         .put(
                 "urn",
                 "Specify the preferred persistent identifier using the \u201Chref\u201D attribute instead.");
         .put(
                 "usemap",
                 "Use the \u201Cimg\u201D element instead of the \u201Cinput\u201D element for image maps.");
         .put(
                 "valuetype",
                 "Use the \u201Cname\u201D and \u201Cvalue\u201D attributes without declaring value types.");
         .put("version""You can safely omit it.");
     }
 
     private static final Map<StringString[]> OBSOLETE_STYLE_ATTRS = new HashMap<StringString[]>();
 
     static {
         .put("align"new String[] { "caption""iframe",
                 "img""input""object""embed""legend""table""hr",
                 "div""h1""h2""h3""h4""h5""h6""p""col",
                 "colgroup""tbody""td""tfoot""th""thead""tr" });
         .put("alink"new String[] { "body" });
         .put("allowtransparency"new String[] { "iframe" });
         .put("background"new String[] { "body" });
         .put("bgcolor"new String[] { "table""tr""td",
                 "th""body" });
         .put("border"new String[] { "object""table" });
         .put("cellpadding"new String[] { "table" });
         .put("cellspacing"new String[] { "table" });
         .put("char"new String[] { "col""colgroup",
                 "tbody""td""tfoot""th""thead""tr" });
         .put("charoff"new String[] { "col""colgroup",
                 "tbody""td""tfoot""th""thead""tr" });
         .put("clear"new String[] { "br" });
         .put("color"new String[] { "hr" });
         .put("compact"new String[] { "dl""menu""ol",
                 "ul" });
         .put("frameborder"new String[] { "iframe" });
         .put("frame"new String[] { "table" });
         .put("height"new String[] { "td""th" });
         .put("hspace"new String[] { "img""object""embed" });
         .put("link"new String[] { "body" });
         .put("marginbottom"new String[] { "body" });
         .put("marginheight"new String[] { "iframe""body" });
         .put("marginleft"new String[] { "body" });
         .put("marginright"new String[] { "body" });
         .put("margintop"new String[] { "body" });
         .put("marginwidth"new String[] { "iframe""body" });
         .put("noshade"new String[] { "hr" });
         .put("nowrap"new String[] { "td""th" });
         .put("rules"new String[] { "table" });
         .put("scrolling"new String[] { "iframe" });
         .put("size"new String[] { "hr" });
         .put("text"new String[] { "body" });
         .put("type"new String[] { "li""ul" });
         .put("valign"new String[] { "col""colgroup",
                 "tbody""td""tfoot""th""thead""tr" });
         .put("vlink"new String[] { "body" });
         .put("vspace"new String[] { "img""object""embed" });
         .put("width"new String[] { "hr""table""td",
                 "th""col""colgroup""pre" });
     }
 
     private static final String[] SPECIAL_ANCESTORS = { "a""address",
             "button""caption""dfn""dt""figcaption""figure""footer",
             "form""header""label""map""noscript""th""time",
             "progress""meter""article""aside""nav" };
 
     private static int specialAncestorNumber(String name) {
         for (int i = 0; i < .i++) {
             if (name == [i]) {
                 return i;
             }
         }
         return -1;
     }
 
     private static Map<StringIntegerANCESTOR_MASK_BY_DESCENDANT = new HashMap<StringInteger>();
 
     private static void registerProhibitedAncestor(String ancestor,
             String descendant) {
         int number = specialAncestorNumber(ancestor);
         if (number == -1) {
             throw new IllegalStateException("Ancestor not found in array: "
                     + ancestor);
         }
         Integer maskAsObject = .get(descendant);
         int mask = 0;
         if (maskAsObject != null) {
             mask = maskAsObject.intValue();
         }
         mask |= (1 << number);
         .put(descendantnew Integer(mask));
     }
 
     static {
         registerProhibitedAncestor("form""form");
         registerProhibitedAncestor("time""time");
         registerProhibitedAncestor("progress""progress");
         registerProhibitedAncestor("meter""meter");
         registerProhibitedAncestor("dfn""dfn");
         registerProhibitedAncestor("noscript""noscript");
         registerProhibitedAncestor("label""label");
         registerProhibitedAncestor("address""address");
         registerProhibitedAncestor("address""section");
         registerProhibitedAncestor("address""nav");
         registerProhibitedAncestor("address""article");
         registerProhibitedAncestor("address""aside");
         registerProhibitedAncestor("header""header");
         registerProhibitedAncestor("footer""header");
         registerProhibitedAncestor("address""header");
         registerProhibitedAncestor("header""footer");
         registerProhibitedAncestor("footer""footer");
         registerProhibitedAncestor("dt""header");
         registerProhibitedAncestor("dt""footer");
         registerProhibitedAncestor("dt""article");
         registerProhibitedAncestor("dt""aside");
         registerProhibitedAncestor("dt""nav");
         registerProhibitedAncestor("dt""section");
         registerProhibitedAncestor("dt""h1");
         registerProhibitedAncestor("dt""h2");
         registerProhibitedAncestor("dt""h2");
         registerProhibitedAncestor("dt""h3");
         registerProhibitedAncestor("dt""h4");
         registerProhibitedAncestor("dt""h5");
         registerProhibitedAncestor("dt""h6");
         registerProhibitedAncestor("dt""hgroup");
         registerProhibitedAncestor("th""header");
         registerProhibitedAncestor("th""footer");
         registerProhibitedAncestor("th""article");
         registerProhibitedAncestor("th""aside");
         registerProhibitedAncestor("th""nav");
         registerProhibitedAncestor("th""section");
         registerProhibitedAncestor("th""h1");
         registerProhibitedAncestor("th""h2");
         registerProhibitedAncestor("th""h2");
         registerProhibitedAncestor("th""h3");
         registerProhibitedAncestor("th""h4");
         registerProhibitedAncestor("th""h5");
         registerProhibitedAncestor("th""h6");
         registerProhibitedAncestor("th""hgroup");
         registerProhibitedAncestor("address""footer");
         registerProhibitedAncestor("address""h1");
         registerProhibitedAncestor("address""h2");
         registerProhibitedAncestor("address""h3");
         registerProhibitedAncestor("address""h4");
         registerProhibitedAncestor("address""h5");
         registerProhibitedAncestor("address""h6");
         registerProhibitedAncestor("a""a");
         registerProhibitedAncestor("button""a");
         registerProhibitedAncestor("a""details");
         registerProhibitedAncestor("button""details");
         registerProhibitedAncestor("a""button");
         registerProhibitedAncestor("button""button");
         registerProhibitedAncestor("a""textarea");
         registerProhibitedAncestor("button""textarea");
         registerProhibitedAncestor("a""select");
         registerProhibitedAncestor("button""select");
         registerProhibitedAncestor("a""keygen");
         registerProhibitedAncestor("button""keygen");
         registerProhibitedAncestor("a""embed");
         registerProhibitedAncestor("button""embed");
         registerProhibitedAncestor("a""iframe");
         registerProhibitedAncestor("button""iframe");
         registerProhibitedAncestor("a""label");
         registerProhibitedAncestor("button""label");
         registerProhibitedAncestor("caption""table");
         registerProhibitedAncestor("article""main");
         registerProhibitedAncestor("aside""main");
         registerProhibitedAncestor("header""main");
         registerProhibitedAncestor("footer""main");
         registerProhibitedAncestor("nav""main");
     }
 
     private static final int A_BUTTON_MASK = (1 << specialAncestorNumber("a"))
             | (1 << specialAncestorNumber("button"));
 
     private static final int FIGCAPTION_MASK = (1 << specialAncestorNumber("figcaption"));
 
     private static final int FIGURE_MASK = (1 << specialAncestorNumber("figure"));
 
     private static final int MAP_MASK = (1 << specialAncestorNumber("map"));
 
     private static final int HREF_MASK = (1 << 30);
 
     private static final int LABEL_FOR_MASK = (1 << 28);
 
     private static final Map<StringSet<String>> REQUIRED_ROLE_ANCESTOR_BY_DESCENDANT = new HashMap<StringSet<String>>();
 
     private static final Map<StringSet<String>> ariaOwnsIdsByRole = new HashMap<StringSet<String>>();
 
     private static void registerRequiredAncestorRole(String parentString child) {
         Set<Stringparents = .get(child);
         if (parents == null) {
             parents = new HashSet<String>();
         }
         parents.add(parent);
         .put(childparents);
     }
 
     static {
         registerRequiredAncestorRole("combobox""option");
         registerRequiredAncestorRole("listbox""option");
         registerRequiredAncestorRole("radiogroup""option");
         registerRequiredAncestorRole("menu""option");
         registerRequiredAncestorRole("menu""menuitem");
         registerRequiredAncestorRole("menu""menuitemcheckbox");
         registerRequiredAncestorRole("menu""menuitemradio");
         registerRequiredAncestorRole("menubar""menuitem");
         registerRequiredAncestorRole("menubar""menuitemcheckbox");
         registerRequiredAncestorRole("menubar""menuitemradio");
         registerRequiredAncestorRole("tablist""tab");
         registerRequiredAncestorRole("tree""treeitem");
         registerRequiredAncestorRole("tree""option");
         registerRequiredAncestorRole("group""treeitem");
         registerRequiredAncestorRole("group""listitem");
         registerRequiredAncestorRole("group""menuitemradio");
         registerRequiredAncestorRole("list""listitem");
         registerRequiredAncestorRole("row""gridcell");
         registerRequiredAncestorRole("row""columnheader");
         registerRequiredAncestorRole("row""rowheader");
         registerRequiredAncestorRole("grid""row");
         registerRequiredAncestorRole("grid""rowgroup");
         registerRequiredAncestorRole("rowgroup""row");
         registerRequiredAncestorRole("treegrid""row");
     }
 
     private static final Set<StringMUST_NOT_DANGLE_IDREFS = new HashSet<String>();
 
     static {
         .add("aria-controls");
         .add("aria-describedby");
         .add("aria-flowto");
         .add("aria-labelledby");
         .add("aria-owns");
     }
 
     private class IdrefLocator {
         private final Locator locator;
 
         private final String idref;
 
         private final String additional;

        

Parameters:
locator
idref
 
         public IdrefLocator(Locator locatorString idref) {
             this. = new LocatorImpl(locator);
             this. = idref;
             this. = null;
         }
 
         public IdrefLocator(Locator locatorString idrefString additional) {
             this. = new LocatorImpl(locator);
             this. = idref;
             this. = additional;
         }

        
Returns the locator.

Returns:
the locator
 
         public Locator getLocator() {
             return ;
         }

        
Returns the idref.

Returns:
the idref
 
         public String getIdref() {
             return ;
         }

        
Returns the additional.

Returns:
the additional
 
         public String getAdditional() {
             return ;
         }
     }
 
     private class StackNode {
         private final int ancestorMask;
 
         private final String name// null if not HTML
 
         private final String role;
 
         private final String activeDescendant;
 
         private final String forAttr;
 
         private Set<LocatorimagesLackingAlt = new HashSet<Locator>();
 
         private Locator nonEmptyOption = null;
 
         private boolean children = false;
 
         private boolean selectedOptions = false;
 
         private boolean labeledDescendants = false;
 
         private boolean trackDescendants = false;
 
         private boolean textNodeFound = false;
 
         private boolean imgFound = false;
 
         private boolean embeddedContentFound = false;
 
         private boolean figcaptionNeeded = false;
 
         private boolean figcaptionContentFound = false;
 
         private boolean optionNeeded = false;
 
         private boolean optionFound = false;
 
         private boolean noValueOptionFound = false;
 
         private boolean emptyValueOptionFound = false;

        

Parameters:
ancestorMask
 
         public StackNode(int ancestorMaskString nameString role,
                 String activeDescendantString forAttr) {
             this. = ancestorMask;
             this. = name;
             this. = role;
             this. = activeDescendant;
             this. = forAttr;
         }

        
Returns the ancestorMask.

Returns:
the ancestorMask
 
         public int getAncestorMask() {
             return ;
         }

        
Returns the name.

Returns:
the name
 
         public String getName() {
             return ;
         }

        
Returns the children.

Returns:
the children
 
         public boolean isChildren() {
             return ;
         }

        
Sets the children.

Parameters:
children the children to set
 
         public void setChildren() {
             this. = true;
         }

        
Returns the selectedOptions.

Returns:
the selectedOptions
 
         public boolean isSelectedOptions() {
             return ;
         }

        
Sets the selectedOptions.

Parameters:
selectedOptions the selectedOptions to set
 
         public void setSelectedOptions() {
             this. = true;
         }

        
Returns the labeledDescendants.

Returns:
the labeledDescendants
 
         public boolean isLabeledDescendants() {
             return ;
         }

        
Sets the labeledDescendants.

Parameters:
labeledDescendants the labeledDescendants to set
 
         public void setLabeledDescendants() {
             this. = true;
         }

        
Returns the trackDescendants.

Returns:
the trackDescendants
 
         public boolean isTrackDescendant() {
             return ;
         }

        
Sets the trackDescendants.

Parameters:
trackDescendants the trackDescendants to set
 
         public void setTrackDescendants() {
             this. = true;
         }

        
Returns the role.

Returns:
the role
 
         public String getRole() {
             return ;
         }

        
Returns the activeDescendant.

Returns:
the activeDescendant
 
         public String getActiveDescendant() {
             return ;
         }

        
Returns the forAttr.

Returns:
the forAttr
 
         public String getForAttr() {
             return ;
         }

        
Returns the textNodeFound.

Returns:
the textNodeFound
 
         public boolean hasTextNode() {
             return ;
         }

        
Sets the textNodeFound.
 
         public void setTextNodeFound() {
             this. = true;
         }

        
Returns the imgFound.

Returns:
the imgFound
 
         public boolean hasImg() {
             return ;
         }

        
Sets the imgFound.
 
         public void setImgFound() {
             this. = true;
         }

        
Returns the embeddedContentFound.

Returns:
the embeddedContentFound
 
         public boolean hasEmbeddedContent() {
             return ;
         }

        
Sets the embeddedContentFound.
 
         public void setEmbeddedContentFound() {
             this. = true;
         }

        
Returns the figcaptionNeeded.

Returns:
the figcaptionNeeded
 
         public boolean needsFigcaption() {
             return ;
         }

        
Sets the figcaptionNeeded.
 
         public void setFigcaptionNeeded() {
             this. = true;
         }

        
Returns the figcaptionContentFound.

Returns:
the figcaptionContentFound
 
         public boolean hasFigcaptionContent() {
             return ;
         }

        
Sets the figcaptionContentFound.
 
         public void setFigcaptionContentFound() {
             this. = true;
         }

        
Returns the imagesLackingAlt

Returns:
the imagesLackingAlt
 
         public Set<LocatorgetImagesLackingAlt() {
             return ;
         }

        
Adds to the imagesLackingAlt
 
         public void addImageLackingAlt(Locator locator) {
             this..add(locator);
         }

        
Returns the optionNeeded.

Returns:
the optionNeeded
 
         public boolean isOptionNeeded() {
             return ;
         }

        
Sets the optionNeeded.
 
         public void setOptionNeeded() {
             this. = true;
         }

        
Returns the optionFound.

Returns:
the optionFound
 
         public boolean hasOption() {
             return ;
         }

        
Sets the optionFound.
 
         public void setOptionFound() {
             this. = true;
         }

        
Returns the noValueOptionFound.

Returns:
the noValueOptionFound
 
         public boolean hasNoValueOption() {
             return ;
         }

        
Sets the noValueOptionFound.
 
         public void setNoValueOptionFound() {
             this. = true;
         }

        
Returns the emptyValueOptionFound.

Returns:
the emptyValueOptionFound
 
         public boolean hasEmptyValueOption() {
             return ;
         }

        
Sets the emptyValueOptionFound.
 
         public void setEmptyValueOptionFound() {
             this. = true;
         }

        
Returns the nonEmptyOption.

Returns:
the nonEmptyOption
 
         public Locator nonEmptyOptionLocator() {
             return ;
         }

        
Sets the nonEmptyOption.
 
         public void setNonEmptyOption(Locator locator) {
             this. = locator;
         }
 
     }
 
     private StackNode[] stack;
 
     private int currentPtr;
 
     public Assertions() {
         super();
     }
 
     private void push(StackNode node) {
         ++;
         if ( == .) {
             StackNode[] newStack = new StackNode[. + 64];
             System.arraycopy(, 0, newStack, 0, .);
              = newStack;
         }
         [] = node;
     }
 
     private StackNode pop() {
         return [--];
     }
 
     private StackNode peek() {
         return [];
     }
 
     private Map<StackNodeLocatoropenSingleSelects = new HashMap<StackNodeLocator>();
 
     private Map<StackNodeLocatoropenLabels = new HashMap<StackNodeLocator>();
 
 
     private Map<StackNodeLocatoropenActiveDescendants = new HashMap<StackNodeLocator>();
 
 
     private Set<StringmenuIds = new HashSet<String>();
 
 
 
     private Set<StringformControlIds = new HashSet<String>();
 
 
     private Set<StringlistIds = new HashSet<String>();
 
 
     private Set<StringallIds = new HashSet<String>();
 
     private int currentFigurePtr;
 
     private boolean hasMain;
 
     private final void errContainedInOrOwnedBy(String roleLocator locator)
             throws SAXException {
         err("An element with \u201Crole=" + role + "\u201D"
                 + " must be contained in, or owned by, an element with "
                 + renderRoleSet(.get(role)) + ".",
                 locator);
     }
 
     private boolean currentElementHasRequiredAncestorRole(
             Set<StringrequiredAncestorRoles) {
         for (String role : requiredAncestorRoles) {
             for (int i = 0; i < i++) {
                 if (role.equals([ - i].getRole())) {
                     return true;
                 }
             }
         }
         return false;
     }

    
 
     @Override public void endDocument() throws SAXException {
         // contextmenu
         for (IdrefLocator idrefLocator : ) {
             if (!.contains(idrefLocator.getIdref())) {
                 err(
                         "The \u201Ccontextmenu\u201D attribute must refer to a \u201Cmenu\u201D element.",
                         idrefLocator.getLocator());
             }
         }
 
         // label for
        for (IdrefLocator idrefLocator : ) {
            if (!.contains(idrefLocator.getIdref())) {
                err(
                        "The \u201Cfor\u201D attribute of the \u201Clabel\u201D element must refer to a form control.",
                        idrefLocator.getLocator());
            }
        }
        // input list
        for (IdrefLocator idrefLocator : ) {
            if (!.contains(idrefLocator.getIdref())) {
                err(
                        "The \u201Clist\u201D attribute of the \u201Cinput\u201D element must refer to a \u201Cdatalist\u201D element.",
                        idrefLocator.getLocator());
            }
        }
        // ARIA idrefs
        for (IdrefLocator idrefLocator : ) {
            if (!.contains(idrefLocator.getIdref())) {
                err(
                        "The \u201C"
                                + idrefLocator.getAdditional()
                                + "\u201D attribute must point to an element in the same document.",
                        idrefLocator.getLocator());
            }
        }
        // ARIA required owners
        for (IdrefLocator idrefLocator : ) {
            boolean foundOwner = false;
            String role = idrefLocator.getAdditional();
            for (String ownerRole : .get(role)) {
                if (.size() != 0
                        && .get(ownerRole) != null
                        && .get(ownerRole).contains(
                                idrefLocator.getIdref())) {
                    foundOwner = true;
                    break;
                }
            }
            if (!foundOwner) {
                errContainedInOrOwnedBy(roleidrefLocator.getLocator());
            }
        }
        reset();
         = null;
    }
    private static double getDoubleAttribute(Attributes attsString name) {
        String str = atts.getValue(""name);
        if (str == null) {
            return .;
        } else {
            try {
                return Double.parseDouble(str);
            } catch (NumberFormatException e) {
                return .;
            }
        }
    }

    
    @Override public void endElement(String uriString localNameString name)
            throws SAXException {
        StackNode node = pop();
        Locator locator = null;
        .remove(node);
        .remove(node);
        .remove(node);
        if ("http://www.w3.org/1999/xhtml" == uri) {
            if ("figure" == localName) {
                if ((node.needsFigcaption() && !node.hasFigcaptionContent())
                        || node.hasTextNode() || node.hasEmbeddedContent()) {
                    for (Locator imgLocator : node.getImagesLackingAlt()) {
                        err("An \u201Cimg\u201D element must have an"
                                + " \u201Calt\u201D attribute, except under"
                                + " certain conditions. For details, consult"
                                + " guidance on providing text alternatives"
                                + " for images."imgLocator);
                    }
                }
            } else if ("select" == localName && node.isOptionNeeded()) {
                if (!node.hasOption()) {
                    err("A \u201Cselect\u201D element with a"
                            + " \u201Crequired\u201D attribute and without a"
                            + " \u201Cmultiple\u201D attribute, and whose size"
                            + " is \u201C1\u201D, must have a child"
                            + " \u201Coption\u201D element.");
                }
                if (node.nonEmptyOptionLocator() != null) {
                    err("The first child \u201Coption\u201D element of a"
                            + " \u201Cselect\u201D element with a"
                            + " \u201Crequired\u201D attribute and without a"
                            + " \u201Cmultiple\u201D attribute, and whose size"
                            + " is \u201C1\u201D, must have either an empty"
                            + " \u201Cvalue\u201D attribute, or must have no"
                            + " text content."node.nonEmptyOptionLocator());
                }
            } else if ("option" == localName && ![].hasOption()) {
                [].setOptionFound();
            }
        }
        if ((locator = .remove(node)) != null) {
            warn(
                    "Attribute \u201Caria-activedescendant\u201D value should "
                    + "either refer to a descendant element, or should "
                    + "be accompanied by attribute \u201Caria-owns\u201D.",
                    locator);
        }
    }

    
    @Override public void startDocument() throws SAXException {
        reset();
         = new StackNode[32];
         = 0;
         = -1;
        [0] = null;
         = false;
    }
    public void reset() {
        .clear();
        .clear();
        .clear();
        .clear();
        .clear();
        .clear();
        .clear();
        .clear();
        .clear();
        .clear();
        .clear();
        .clear();
        .clear();
        .clear();
    }

    
    @Override public void startElement(String uriString localName,
            String nameAttributes attsthrows SAXException {
        Set<Stringids = new HashSet<String>();
        String role = null;
        String activeDescendant = null;
        String owns = null;
        String forAttr = null;
        boolean href = false;
        boolean activeDescendantWithAriaOwns = false;
        StackNode parent = peek();
        int ancestorMask = 0;
        String parentRole = null;
        String parentName = null;
        if (parent != null) {
            ancestorMask = parent.getAncestorMask();
            parentName = parent.getName();
            parentRole = parent.getRole();
        }
        if ("http://www.w3.org/1999/xhtml" == uri) {
            boolean controls = false;
            boolean hidden = false;
            boolean add = false;
            boolean toolbar = false;
            boolean usemap = false;
            boolean ismap = false;
            boolean selected = false;
            boolean itemid = false;
            boolean itemref = false;
            boolean itemscope = false;
            boolean itemtype = false;
            boolean languageJavaScript = false;
            boolean typeNotTextJavaScript = false;
            String xmlLang = null;
            String lang = null;
            String id = null;
            String contextmenu = null;
            String list = null;
            int len = atts.getLength();
            for (int i = 0;&n