Example #1
0
  // Tests whether we have a match for a particular accessibility
  // property.
  private boolean _matchAccessibilityProperty(
      String propertyName, AccessibilityProfile accProfile) {
    if (XMLConstants.ACC_HIGH_CONTRAST.equals(propertyName)) return accProfile.isHighContrast();
    if (XMLConstants.ACC_LARGE_FONTS.equals(propertyName)) return accProfile.isLargeFonts();

    // Should never reach here (did we add a new property?)
    assert (false);

    return false;
  }
    // Parses the text into an AccessibilityProfile.
    private static AccessibilityProfile _getAccessibilityProfile(String text) {
      AccessibilityProfile.ColorContrast colorContrast = null;
      AccessibilityProfile.FontSize fontSize = null;

      // Note: we do the parsing here in the ConfigParser instead of in
      // RequestContextImpl so that we can easily detect/log any problems
      // once at startup.  Also nice to do this here so that we have some
      // chance of actually logging line numbers, though at the moment it
      // looks like our Handler doesn't implement Locator.

      StringTokenizer tokens = new StringTokenizer(text);
      while (tokens.hasMoreTokens()) {
        String token = tokens.nextToken();

        if ("high-contrast".equals(token)) {
          colorContrast = AccessibilityProfile.ColorContrast.HIGH;
        } else if ("large-fonts".equals(token)) {
          fontSize = AccessibilityProfile.FontSize.LARGE;
        } else {
          _LOG.warning("INVALID_ACC_PROFILE", new Object[] {token});
        }
      }

      return AccessibilityProfile.getInstance(colorContrast, fontSize);
    }