| FilterInputStream myStream=new LineNumberInputStream ( new BufferInputStream( new StringBufferInputStream( myStringBuffer))); |
![]() |
| public interface BodyContentFilterIntf { public String filtContent(String aContent) throws ContentFilterException; } |
| public class LengthContentFilter implements BodyContentFilterIntf { private BodyContentFilterIntf bodyContentFilterIntf = null; public HtmlContentFilter(BodyContentFilterIntf aFilter) { bodyContentFilterIntf = aFilter; } public String filtContent(String aContent) throws ContentFilterException { String l_Content = aContent; If (bodyContentFilterIntf!=null) _Content = bodyContentFilterIntf .filtContent(l_Content); if (aContent.length()<=50) throw new ContentFilterException (“输入的字数不能少于50!”); return aContext; } } |
| implements BodyContentFilterIntf { private BodyContentFilterIntf bodyContentFilterIntf = null; public SendEmailContentFilter(BodyContentFilterIntf aFilter) { bodyContentFilterIntf = aFilter; } public String filtContent(String aContent) throws ContentFilterException { String l_Content = aContent; if (bodyContentFilterIntf!=null) l_Content = bodyContentFilterIntf .filtContent(l_Content); SendEmail(“webmaster@SnailWeb.com”,l_Content) return aContext; } } |
| try { l_Content = new HtmlContentFilter(new SensitiveWordContextFilter(null)). filtContent(bodyContext); } catch (ContentFilterException ex) { BBSCommon.showMsgInResponse(response, ex.getMessage()); return; } |
| try { BodyContentFilterIntf bodyContentFilterIntf = null; bodyContentFilterIntf = new HtmlContentFilter(null); if(IsMember==true) bodyContentFilterIntf = new sendEmailContentFilter(bodyContentFilterIntf); else bodyContentFilterIntf = new SensitiveWordContextFilter(bodyContentFilterIntf); l_Content = bodyContentFilterIntf.filtContent(bodyContext); } catch (ContentFilterException ex) { BBSCommon.showMsgInResponse(response, ex.getMessage()); return; } |