debugfilter.java

来自「很棒的web服务器源代码」· Java 代码 · 共 84 行

JAVA
84
字号
// DebugFilter.java// $Id: DebugFilter.java,v 1.11 2000/08/16 21:37:36 ylafon Exp $// (c) COPYRIGHT MIT and INRIA, 1996.// Please first read the full copyright statement in file COPYRIGHT.htmlpackage org.w3c.jigsaw.filters;import org.w3c.tools.resources.Attribute;import org.w3c.tools.resources.AttributeHolder;import org.w3c.tools.resources.AttributeRegistry;import org.w3c.tools.resources.BooleanAttribute;import org.w3c.tools.resources.ReplyInterface;import org.w3c.tools.resources.RequestInterface;import org.w3c.tools.resources.ResourceFilter;import org.w3c.jigsaw.http.Reply;import org.w3c.jigsaw.http.Request;/** * Print incoming request and outgoing replies. */public class DebugFilter extends ResourceFilter {    /**     * Attribute index - The on/off toggle.     */    protected static int ATTR_ONOFF = -1 ;    static {	Attribute a   = null ;	Class     cls = null ;	try {	    cls = Class.forName("org.w3c.jigsaw.filters.DebugFilter");	} catch (Exception ex) {	    ex.printStackTrace() ;	    System.exit(1) ;	}	// The onoff toggle	a = new BooleanAttribute("onoff"				 , Boolean.TRUE				 , Attribute.EDITABLE) ;	ATTR_ONOFF = AttributeRegistry.registerAttribute(cls, a) ;    }    /**     * Get the onoff toggle value.     */    public boolean getOnOffFlag() {	return getBoolean(ATTR_ONOFF, true) ;    }    /**     * The ingoing filter - fearly easy !     * @param request The incomming request.     * @return Always <strong>null</strong>.     */    public ReplyInterface ingoingFilter(RequestInterface req) {	Request request = (Request) req;	if ( getOnOffFlag() ) 	    request.dump(System.out);	return null;    }    /**     * The outgoing filter - As easy as the ingoing filter.     * @param request The original request.     * @param reply The target's reply.     */    public ReplyInterface outgoingFilter(RequestInterface req,					 ReplyInterface rep)     {	Reply reply = (Reply) rep;	if ( getOnOffFlag() ) 	    reply.dump(System.out);	return null ;    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?