01: // FilterInterface.java
02: // $Id: FilterInterface.java,v 1.4 2000/08/16 21:37:52 ylafon Exp $
03: // (c) COPYRIGHT MIT and INRIA, 1996.
04: // Please first read the full copyright statement in file COPYRIGHT.html
05:
06: package org.w3c.tools.resources;
07:
08: import java.io.OutputStream;
09:
10: public interface FilterInterface {
11:
12: /**
13: * The lookup stage filtering.
14: * This filter is invoked during lookup, it can cancel the lookup operation
15: * in progress, by either throwing an exception (in case of error), or
16: * by returning <strong>true</strong>, in which case, the filter has
17: * perform the whole lookup operation itself.
18: * @param ls The current lookup state, describing the state of the lookup
19: * operation in progress.
20: * @param lr The current lookup result, describing the already computed
21: * part of the lookup operation.
22: * @return A boolean, <strong>true</strong> if lookup has been completed
23: * by the filter, and nothing else need to be done to complete it.
24: * Otherwise lookup should continue normally, and the filter returns
25: * <strong>false</strong>.
26: * @exception ProtocolException If some error occurs, and the whole
27: * lookup operation cannot be continued normally.
28: */
29:
30: public boolean lookup(LookupState ls, LookupResult lr)
31: throws ProtocolException;
32:
33: /**
34: * The filter's ingoing method is called before any request processing is
35: * done by the target resource.
36: * <p>This method can (if able) compute the whole request's reply, and
37: * return it. If processing should continue normally, then the filter
38: * must return <strong>null</strong>.
39: * <p>If a filter's <code>ingoingFilter</code> method gets called,
40: * then it is guaranteed that either its <code>outgoingFilter</code>
41: * method or its <code>exceptionFilter</code> method gets called.
42: * @param request The request being processed.
43: * @param filters The whole array of filters to be applied before
44: * actually continuing the process.
45: * @param fidx The index in the above array of the filter being called.
46: * @return A Reply instance, if the filter knows how to compute it, or
47: * <strong>null</strong> if the request processing should continue
48: * normally.
49: * @exception ProtocolException If the filter fails.
50: */
51:
52: public ReplyInterface ingoingFilter(RequestInterface request,
53: FilterInterface filters[], int fidx)
54: throws ProtocolException;
55:
56: /**
57: * The filter's outgoing method is called once the target resource has
58: * computed a reply.
59: * <p>This method can return a Reply instance, in which case, the
60: * processing should be aborted, and the returned reply should be emited
61: * back to the client. Otherwise, if the filter returns <strong>null
62: * </strong> the processing continues normally.
63: * @param request The request being processed.
64: * @param reply The original reply, as emited by the target resource,
65: * and which has already been processed by the first filters.
66: * @param filters The whole array of filters to be applied before
67: * actually continuing the process.
68: * @param fidx The index in the above array of the filter being called.
69: * @exception ProtocolException If the filter fails.
70: */
71:
72: public ReplyInterface outgoingFilter(RequestInterface request,
73: ReplyInterface reply, FilterInterface filters[], int fidx)
74: throws ProtocolException;
75:
76: /**
77: * @param request The request being processed.
78: * @param ex The exception that occured during processing the request.
79: * and which has already been processed by the first filters.
80: * @param filters The whole array of filters to be applied before
81: * actually continuing the process.
82: * @param fidx The index in the above array of the filter being called.
83: */
84:
85: public ReplyInterface exceptionFilter(RequestInterface request,
86: ProtocolException ex, FilterInterface filters[], int fidx);
87:
88: public OutputStream outputFilter(RequestInterface request,
89: ReplyInterface reply, OutputStream output);
90:
91: }
|