01: // CountCommand.java
02: // $Id: CountCommand.java,v 1.4 2000/08/16 21:37:47 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.jigsaw.ssi.commands;
07:
08: import java.util.Dictionary;
09:
10: import org.w3c.www.http.HTTP;
11:
12: import org.w3c.util.ArrayDictionary;
13:
14: import org.w3c.jigsaw.http.Reply;
15: import org.w3c.jigsaw.http.Request;
16:
17: import org.w3c.jigsaw.ssi.SSIFrame;
18:
19: /**
20: * This command inserts the number of recorded accesses to this resource,
21: * as reported by org.w3c.jigsaw.filter.CounterFilter.
22: * @see org.w3c.jigsaw.filters.CounterFilter
23: * @author Antonio Ramirez <anto@mit.edu>
24: */
25: public class CountCommand extends BasicCommand {
26: private static final String NAME = "hitcount";
27:
28: public Reply execute(SSIFrame ssiframe, Request request,
29: ArrayDictionary parameters, Dictionary variables) {
30: Reply reply = ssiframe.createCommandReply(request, HTTP.OK);
31:
32: Integer count = (Integer) request
33: .getState(org.w3c.jigsaw.filters.CounterFilter.STATE_COUNT);
34: if (count == null)
35: reply.setContent("[unknown]");
36: else
37: reply.setContent(count.toString());
38:
39: // FIXME, NOTE:
40: // the handling of weak validation should be configurable
41: handleSimpleIMS(request, reply);
42: return reply;
43: }
44:
45: public String getName() {
46: return NAME;
47: }
48:
49: public String getValue(Dictionary variables, String variable,
50: Request request) {
51: return "null";
52: }
53:
54: }
|