/*
 * Copyright (C) 2013 salesforce.com, inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.auraframework.def;

public enum HtmlTag {
    a,
    abbr,
    acronym,
    address,
    applet(false),
    area,
    article,
    aside,
    audio,
    b,
    base(false),
    basefont(false),
    bdi,
    bdo,
    big,
    blockquote,
    body,
    br,
    button,
    caption,
    canvas,
    center,
    cite,
    code,
    col,
    colgroup,
    command,
    datalist,
    dd,
    del,
    details,
    dfn,
    dir,
    div,
    dl,
    dt,
    em,
    embed(false),
    fieldset,
    figure,
    figcaption,
    font(false),
    footer,
    form,
    frame(false),
    frameset(false),
    h1,
    h2,
    h3,
    h4,
    h5,
    h6,
    head,
    header,
    hgroup,
    hr,
    html,
    i,
    iframe,
    img,
    input,
    ins,
    isindex(false),
    keygen,
    kbd,
    label,
    legend,
    li,
    link,
    map,
    mark,
    menu,
    meta,
    meter,
    noframes(false),
    noscript(false),
    object(false),
    nav,
    ol,
    optgroup,
    option,
    output,
    p,
    param(false),
    pre,
    progress,
    q,
    rp,
    rt,
    ruby,
    s,
    samp,
    script,
    section,
    select,
    small,
    source,
    span,
    strike,
    strong,
    style,
    sub,
    summary,
    sup,
    table,
    tbody,
    td,
    textarea,
    tfoot,
    th,
    thead,
    time,
    title,
    tr,
    track,
    tt,
    u,
    ul,
    var,
    video,
    wbr;

    private final boolean allowed;
    public static final String HTML_TAG = "aura:html";

    private HtmlTag(boolean allowed) {
        this.allowed = allowed;
    }

    private HtmlTag() {
        this(true);
    }

    public static final boolean allowed(String tag) {
        try {
            if (tag.equals(HTML_TAG)) {
                return true;
            }
            HtmlTag ret = valueOf(tag.toLowerCase());
            return ret.isAllowed();
        } catch (Throwable e) {
            return false;
        }
    }

    public boolean isAllowed() {
        return allowed;
    }
}

@@ -637,16 +637,64 @@
 k.def;%0A%0A
+import java.util.concurrent.ConcurrentHashMap;%0A%0A
 public e
@@ -2144,16 +2144,111 @@
 a:html%22;
+%0A    private static final ConcurrentHashMap%3CString,HtmlTag%3E tagMap = new ConcurrentHashMap%3C%3E();
 %0A%0A    pr
@@ -2436,11 +2436,29 @@
     
-try
+synchronized (tagMap)
  %7B%0A 
@@ -2479,193 +2479,349 @@
 (tag
-.equals(HTML_TAG)) %7B%0A                return true;%0A            %7D%0A            HtmlTag ret = valueOf(tag.toLowerCase());%0A            return ret.isAllowed();%0A        %7D catch (Throwable e) %7B
+Map.size() == 0) %7B%0A                for (HtmlTag t : values()) %7B%0A                    tagMap.put(t.toString(), t);%0A                %7D%0A            %7D%0A        %7D%0A        if (tag == null) %7B%0A            return false;%0A        %7D%0A        if (tag.equals(HTML_TAG)) %7B%0A            return true;%0A        %7D%0A        HtmlTag ret = tagMap.get(tag.toLowerCase());
 %0A   
@@ -2829,35 +2829,46 @@
     
-    
 return 
-false;%0A        %7D
+ret != null && ret.isAllowed();
 %0A   

Improve compile time performance. (#1769)