@@ -0,0 +1,2316 @@
+/*%0A * To change this license header, choose License Headers in Project Properties.%0A * To change this template file, choose Tools %7C Templates%0A * and open the template in the editor.%0A */%0A%0Apackage com.ecbeta.view.html;%0A%0Aimport java.io.Serializable;%0Aimport java.util.ArrayList;%0Aimport java.util.HashMap;%0Aimport java.util.List;%0Aimport java.util.Map;%0Aimport org.apache.commons.lang.StringUtils;%0A%0A/**%0A *%0A * @author ronghai%0A */%0Apublic class HTMLElement implements Serializable%7B%0A    private String innerHTML;%0A    %0A    %0A    private final Map%3CString, String%3E attribtues;%0A    private final String tag;%0A    private List%3CHTMLElement%3E children; %0A    %0A    public HTMLElement addChild(String tag)%7B%0A        if(this.children == null)%7B%0A            this.children = new ArrayList%3C%3E();%0A        %7D%0A        HTMLElement ch = new HTMLElement(tag);%0A        this.children.add(ch);%0A        return ch;%0A    %7D%0A%0A    public String getInnerHTML() %7B%0A        return innerHTML;%0A    %7D%0A%0A    public void setInnerHTML(String innerHTML) %7B%0A        this.innerHTML = innerHTML;%0A    %7D%0A    %0A    public HTMLElement(String tag) %7B%0A        this.tag = tag;%0A        this.attribtues = new HashMap%3C%3E();%0A    %7D%0A    %0A    public HTMLElement set(String att, String value)%7B%0A        this.attribtues.put(att, value);%0A        return this;%0A    %7D%0A    public HTMLElement remove(String att)%7B%0A        this.attribtues.remove(att);%0A        return this;%0A    %7D%0A    %0A    public HTMLElement add(String att, String value)%7B%0A        String old = this.attribtues.get(att);%0A        if(old == null)%7B%0A            old = %22%22;%0A        %7D%0A        old += %22 %22+ value;%0A        return this.set(att, old);%0A    %7D%0A    %0A    public String toHTML()%7B%0A        StringBuilder sb = new StringBuilder();%0A        sb.append(%22%3C%22).append(tag);%0A        %0A        for(Map.Entry%3CString, String%3E ent : this.attribtues.entrySet())%7B%0A            sb.append(ent.getKey()).append(%22=%5C%22%22);%0A            sb.append(ent.getValue());%0A            sb.append(%22%5C%22 %22);%0A        %7D%0A        %0A        sb.append(%22%3E%22);%0A        if(StringUtils.isNotEmpty(innerHTML))%7B%0A            sb.append(innerHTML);%0A        %7D%0A        if(children != null)%7B%0A            for(HTMLElement h : children)%7B%0A                sb.append(h.toHTML());%0A            %7D%0A        %7D%0A        %0A        sb.append(%22%3C/%22).append(tag).append(%22%3E%22);%0A              %0A        return sb.toString();%0A    %7D%0A%7D%0A

add HTML Element