1 16 package dlog4j.util.tags; 17 18 import java.io.IOException ; 19 import java.io.Reader ; 20 21 import javax.servlet.jsp.JspException ; 22 import javax.servlet.jsp.tagext.BodyTagSupport ; 23 24 import org.apache.commons.lang.StringUtils; 25 29 public class HtmlFormatTag extends BodyTagSupport { 30 31 boolean ubb = false; 32 boolean html= false; 33 boolean face= false; 34 35 38 public int doStartTag() throws JspException { 39 return EVAL_BODY_BUFFERED; 40 } 41 42 45 public int doEndTag() throws JspException { 46 Reader reader = getBodyContent().getReader(); 47 char[] buf = new char[1024]; 48 try{ 49 StringBuffer content = new StringBuffer (1024); 50 do{ 51 int rc = reader.read(buf); 52 if(rc>0) 53 content.append(buf,0,rc); 54 if(rc<1024) 55 break; 56 }while(true); 57 pageContext.getOut().write(format(content.toString(),ubb,html,face)); 58 }catch(IOException e0){ 59 } 60 return EVAL_PAGE; 61 } 62 70 protected String format(String content, boolean useUbb, boolean transHtml, boolean useFace){ 71 String html = content; 72 if(transHtml){ 73 html = StringUtils.replace(html,"\t"," "); html = StringUtils.replace(html," "," "); html = StringUtils.replace(html,"\n","<br>"); } 77 if(useUbb){ 78 79 } 80 return html; 81 } 82 85 public void release() { 86 super.release(); 87 } 88 89 92 public boolean isFace() { 93 return face; 94 } 95 96 99 public boolean isHtml() { 100 return html; 101 } 102 103 106 public boolean isUbb() { 107 return ubb; 108 } 109 110 113 public void setFace(boolean b) { 114 face = b; 115 } 116 117 120 public void setHtml(boolean b) { 121 html = b; 122 } 123 124 127 public void setUbb(boolean b) { 128 ubb = b; 129 } 130 131 } 132 | Popular Tags |