01: /*
02: * This file is part of PFIXCORE.
03: *
04: * PFIXCORE is free software; you can redistribute it and/or modify
05: * it under the terms of the GNU Lesser General Public License as published by
06: * the Free Software Foundation; either version 2 of the License, or
07: * (at your option) any later version.
08: *
09: * PFIXCORE is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public License
15: * along with PFIXCORE; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: *
18: */
19:
20: package de.schlund.pfixcore.example;
21:
22: import org.apache.log4j.Logger;
23: import org.w3c.dom.Element;
24:
25: import de.schlund.pfixcore.workflow.Context;
26: import de.schlund.pfixcore.workflow.ContextResource;
27: import de.schlund.pfixxml.ResultDocument;
28:
29: /**
30: * ContextCounter.java
31: *
32: *
33: * Created: Thu Oct 22 19:24:37 2001
34: *
35: * @author <a href="mailto:jtl@schlund.de">Jens Lautenbacher</a>
36: *
37: *
38: */
39:
40: public class ContextCounterImpl implements ContextResource,
41: ContextCounter {
42:
43: private Boolean showcounter = Boolean.FALSE;
44: private int counter = 0;
45: private final static Logger LOG = Logger
46: .getLogger(ContextCounterImpl.class);
47:
48: // private Context context;
49:
50: public void init(Context context) {
51: // this.context = context;
52: }
53:
54: public void reset() {
55: showcounter = Boolean.FALSE;
56: counter = 0;
57: }
58:
59: public Boolean getShowCounter() {
60: return showcounter;
61: }
62:
63: public int getCounter() {
64: return counter;
65: }
66:
67: public void setShowCounter(Boolean showcounter) {
68: this .showcounter = showcounter;
69: }
70:
71: public void setCounter(int count) {
72: counter = count;
73: }
74:
75: public void addToCounter(int count) {
76: counter += count;
77: }
78:
79: public boolean needsData() {
80: return false;
81: }
82:
83: public String toString() {
84: LOG.debug("Doing ContextCounter...");
85: return "[showcounter?: " + showcounter + "][counter?: "
86: + counter + "]";
87: }
88:
89: public void insertStatus(ResultDocument resdoc, Element overview) {
90: overview.setAttribute("showcounter", "" + showcounter);
91: overview.setAttribute("counter", "" + counter);
92: }
93:
94: }// ContextCounter
|