《有些模式》- 责任链(简单模拟1)
package com.macrotea.responzchain.test;import com.macrotea.responzchain.chain.FilterChain;import com.macrotea.responzchain.handler.MessageHandler;import com.macrotea.responzchain.impl.HTMLFilter;import com.macrotea.responzchain.impl.HarmonyFilter;public class Mainer {public static void main(String[] args) { String netText="<h1>哈哈</h1>我来到一个神奇的地方,这里有犀利哥,有大乡里,有奔跑哥,什么都有!";/*构造过滤器链*/FilterChain chain=new FilterChain();chain.appendFilter(new HTMLFilter()).appendFilter(new HarmonyFilter());/*传递给信息处理者*/MessageHandler msgHandler =new MessageHandler(chain);String clearText=msgHandler.doHandle(netText);System.out.println(clearText);}}??
?
简单责任链设计模式!!
?
?
?