public void startElement()

in tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigParser.java [192:323]


  public void startElement(final String uri, final String localName, final String qName, final Attributes attributes)
      throws SAXException {

    // No unused content should be collected, specially text mixed with tags.
    assert buffer.toString().trim().length() == 0;

    buffer.setLength(0);
    stack.add(qName);

    switch (qName.hashCode()) {

      case TOBAGO_CONFIG:
        tobagoConfig = new TobagoConfigFragment();
        break;

      case CONTENT_SECURITY_POLICY:
        final String mode = attributes.getValue(ATTR_MODE);
        tobagoConfig.setContentSecurityPolicy(new ContentSecurityPolicy(mode));
        break;

      case THEME_DEFINITION:
        currentTheme = new ThemeImpl();
        tobagoConfig.addThemeDefinition(currentTheme);
        break;

      case RESOURCES:
        production = Boolean.parseBoolean(attributes.getValue(ATTR_PRODUCTION));
        break;

      case EXCLUDES:
        exclude = true;
        break;

      case SCRIPT:
        final ThemeScript script = new ThemeScript();
        script.setName(attributes.getValue(ATTR_NAME));
        script.setType(attributes.getValue(ATTR_TYPE));
        final String scriptPriority = attributes.getValue(ATTR_PRIORITY);
        script.setPriority(scriptPriority != null ? Integer.parseUnsignedInt(scriptPriority) : MAX_PRIORITY);
        if (production) {
          if (exclude) {
            currentTheme.getProductionResources().addExcludeScript(script);
          } else {
            currentTheme.getProductionResources().addIncludeScript(script);
          }
        } else {
          if (exclude) {
            currentTheme.getDevelopmentResources().addExcludeScript(script);
          } else {
            currentTheme.getDevelopmentResources().addIncludeScript(script);
          }
        }
        break;

      case STYLE:
        final ThemeStyle style = new ThemeStyle();
        style.setName(attributes.getValue(ATTR_NAME));
        final String stylePriority = attributes.getValue(ATTR_PRIORITY);
        style.setPriority(stylePriority != null ? Integer.parseUnsignedInt(stylePriority) : MAX_PRIORITY);
        if (production) {
          if (exclude) {
            currentTheme.getProductionResources().addExcludeStyle(style);
          } else {
            currentTheme.getProductionResources().addIncludeStyle(style);
          }
        } else {
          if (exclude) {
            currentTheme.getDevelopmentResources().addExcludeStyle(style);
          } else {
            currentTheme.getDevelopmentResources().addIncludeStyle(style);
          }
        }
        break;

      case PROPERTIES:
        properties = new Properties();
        break;

      case ENTRY:
        entryKey = attributes.getValue(ATTR_KEY);
        break;

      case DIRECTIVE:
        directiveName = attributes.getValue(ATTR_NAME);
        break;

      case TAG:
        tagName = attributes.getValue(ATTR_NAME);
        break;

      case ATTRIBUTE:
        currentTheme.addTagDefault(tagName, attributes.getValue(ATTR_NAME), attributes.getValue(ATTR_DEFAULT));
        break;

      case NAME:
      case ORDERING:
      case BEFORE:
      case AFTER:
      case THEME_CONFIG:
      case DEFAULT_THEME:
      case SUPPORTED_THEME:
      case THEME_COOKIE:
      case THEME_SESSION:
      case SUPPORTED_MARKUP:
      case MARKUP:
      case CREATE_SESSION_SECRET:
      case CHECK_SESSION_SECRET:
      case SECURITY_ANNOTATION:
      case PREVENT_FRAME_ATTACKS:
      case SET_NOSNIFF_HEADER:
      case THEME_DEFINITIONS:
      case DISPLAY_NAME:
      case VERSION:
      case VERSIONED:
      case FALLBACK:
      case SANITIZER:
      case SANITIZER_CLASS:
      case MIME_TYPES:
      case MIME_TYPE:
      case EXTENSION:
      case TYPE:
      case RENDERERS:
      case RENDERER:
      case INCLUDES:
      case TAGS:
        // nothing to do
        break;

      default:
        LOG.warn("Ignoring unknown start tag <" + qName + "> with hashCode=" + qName.hashCode());
    }
  }