1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.scxml.model;
19
20 import java.util.Collection;
21
22 import org.apache.commons.scxml.Context;
23 import org.apache.commons.scxml.ErrorReporter;
24 import org.apache.commons.scxml.Evaluator;
25 import org.apache.commons.scxml.EventDispatcher;
26 import org.apache.commons.scxml.SCInstance;
27 import org.apache.commons.scxml.SCXMLExpressionException;
28
29 /***
30 * The class in this SCXML object model that corresponds to the
31 * <log> SCXML element.
32 *
33 */
34 public class Log extends Action {
35
36 /***
37 * An expression evaluating to a string to be logged.
38 */
39 private String expr;
40
41 /***
42 * An expression which returns string which may be used, for example,
43 * to indicate the purpose of the log.
44 */
45 private String label;
46
47 /***
48 * Constructor.
49 */
50 public Log() {
51 super();
52 }
53
54 /***
55 * Get the log expression.
56 *
57 * @return Returns the expression.
58 */
59 public final String getExpr() {
60 return expr;
61 }
62
63 /***
64 * Set the log expression.
65 *
66 * @param expr The expr to set.
67 */
68 public final void setExpr(final String expr) {
69 this.expr = expr;
70 }
71
72 /***
73 * Get the log label.
74 *
75 * @return Returns the label.
76 */
77 public final String getLabel() {
78 return label;
79 }
80
81 /***
82 * Set the log label.
83 *
84 * @param label The label to set.
85 */
86 public final void setLabel(final String label) {
87 this.label = label;
88 }
89
90 /***
91 * {@inheritDoc}
92 */
93 public void execute(final EventDispatcher evtDispatcher,
94 final ErrorReporter errRep, final SCInstance scInstance,
95 final org.apache.commons.logging.Log appLog,
96 final Collection derivedEvents)
97 throws ModelException, SCXMLExpressionException {
98 Context ctx = scInstance.getContext(getParentState());
99 Evaluator eval = scInstance.getEvaluator();
100 appLog.info(label + ": " + String.valueOf(eval.eval(ctx, expr)));
101 }
102 }
103