--- /dev/null
+// HTTPFilter.java\r
+// $Id: HTTPFilter.java,v 1.1 2010/06/15 12:21:58 smhuang Exp $\r
+// (c) COPYRIGHT MIT and INRIA, 1996.\r
+// Please first read the full copyright statement in file COPYRIGHT.html\r
+\r
+package org.w3c.jigsaw.http ;\r
+\r
+import java.io.IOException;\r
+import java.io.OutputStream;\r
+\r
+import org.w3c.tools.resources.LookupResult;\r
+import org.w3c.tools.resources.LookupState;\r
+import org.w3c.tools.resources.ProtocolException;\r
+\r
+import org.w3c.tools.resources.ProtocolException;\r
+\r
+public interface HTTPFilter {\r
+\r
+ /**\r
+ * The lookup stage filtering.\r
+ * This filter is invoked during lookup, it can cancel the lookup operation\r
+ * in progress, by either throwing an exception (in case of error), or\r
+ * by returning <strong>true</strong>, in which case, the filter has\r
+ * perform the whole lookup operation itself.\r
+ * @param ls The current lookup state, describing the state of the lookup\r
+ * operation in progress.\r
+ * @param lr The current lookup result, describing the already computed\r
+ * part of the lookup operation.\r
+ * @return A boolean, <strong>true</strong> if lookup has been completed\r
+ * by the filter, and nothing else need to be done to complete it. \r
+ * Otherwise lookup should continue normally, and the filter returns\r
+ * <strong>false</strong>.\r
+ * @exception ProtocolException If some error occurs, and the whole \r
+ * lookup operation cannot be continued normally.\r
+ */\r
+\r
+ public boolean lookup(LookupState ls, LookupResult lr)\r
+ throws ProtocolException;\r
+\r
+ /**\r
+ * The filter's ingoing method is called before any request processing is\r
+ * done by the target resource.\r
+ * <p>This method can (if able) compute the whole request's reply, and \r
+ * return it. If processing should continue normally, then the filter\r
+ * must return <strong>null</strong>.\r
+ * <p>If a filter's <code>ingoingFilter</code> method gets called, \r
+ * then it is guaranteed that either its <code>outgoingFilter</code>\r
+ * method or its <code>exceptionFilter</code> method gets called.\r
+ * @param request The request being processed.\r
+ * @param filters The whole array of filters to be applied before\r
+ * actually continuing the process.\r
+ * @param fidx The index in the above array of the filter being called.\r
+ * @return A Reply instance, if the filter knows how to compute it, or\r
+ * <strong>null</strong> if the request processing should continue\r
+ * normally.\r
+ * @exception ProtocolException If the filter fails.\r
+ */\r
+\r
+ public Reply ingoingFilter(Request request\r
+ , HTTPFilter filters[]\r
+ , int fidx)\r
+ throws ProtocolException;\r
+\r
+ /**\r
+ * The filter's outgoing method is called once the target resource has\r
+ * computed a reply.\r
+ * <p>This method can return a Reply instance, in which case, the\r
+ * processing should be aborted, and the returned reply should be emited\r
+ * back to the client. Otherwise, if the filter returns <strong>null\r
+ * </strong> the processing continues normally.\r
+ * @param request The request being processed.\r
+ * @param reply The original reply, as emited by the target resource, \r
+ * and which has already been processed by the first filters.\r
+ * @param filters The whole array of filters to be applied before\r
+ * actually continuing the process.\r
+ * @param fidx The index in the above array of the filter being called.\r
+ * @exception ProtocolException If the filter fails.\r
+ */\r
+\r
+ public Reply outgoingFilter(Request request, Reply reply\r
+ , HTTPFilter filters[]\r
+ , int fidx)\r
+ throws ProtocolException;\r
+\r
+ public OutputStream outputFilter(Request request\r
+ , Reply reply\r
+ , OutputStream output)\r
+ throws IOException;\r
+\r
+ /**\r
+ * @param request The request being processed.\r
+ * @param ex The exception that occured during processing the request. \r
+ * and which has already been processed by the first filters.\r
+ * @param filters The whole array of filters to be applied before\r
+ * actually continuing the process.\r
+ * @param fidx The index in the above array of the filter being called.\r
+ */\r
+\r
+ public Reply exceptionFilter(Request request\r
+ , ProtocolException ex\r
+ , HTTPFilter filters[]\r
+ , int fidx);\r
+\r
+}\r