--- /dev/null
+// CountCommand.java\r
+// $Id: CountCommand.java,v 1.1 2010/06/15 12:21:54 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.ssi.commands ;\r
+\r
+import java.util.Dictionary;\r
+\r
+import org.w3c.www.http.HTTP ;\r
+\r
+import org.w3c.util.ArrayDictionary;\r
+\r
+import org.w3c.jigsaw.http.Reply;\r
+import org.w3c.jigsaw.http.Request;\r
+\r
+import org.w3c.jigsaw.ssi.SSIFrame;\r
+\r
+/**\r
+ * This command inserts the number of recorded accesses to this resource,\r
+ * as reported by org.w3c.jigsaw.filter.CounterFilter.\r
+ * @see org.w3c.jigsaw.filters.CounterFilter\r
+ * @author Antonio Ramirez <anto@mit.edu>\r
+ */\r
+public class CountCommand extends BasicCommand {\r
+ private static final String NAME = "hitcount" ;\r
+\r
+ public Reply execute(SSIFrame ssiframe,\r
+ Request request,\r
+ ArrayDictionary parameters,\r
+ Dictionary variables)\r
+ {\r
+ Reply reply =\r
+ ssiframe.createCommandReply(request,HTTP.OK) ;\r
+ \r
+ Integer count = (Integer)\r
+ request.getState(org.w3c.jigsaw.filters.CounterFilter.STATE_COUNT) ;\r
+ if(count == null)\r
+ reply.setContent("[unknown]") ;\r
+ else reply.setContent(count.toString()) ;\r
+\r
+ // FIXME, NOTE:\r
+ // the handling of weak validation should be configurable\r
+ handleSimpleIMS(request,reply) ;\r
+ return reply ;\r
+ } \r
+\r
+ public String getName()\r
+ {\r
+ return NAME ;\r
+ }\r
+\r
+ public String getValue(Dictionary variables, String variable, \r
+ Request request) {\r
+ return "null";\r
+ }\r
+\r
+}\r