1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.jelly.tags.log;
17
18 import org.apache.commons.jelly.JellyTagException;
19 import org.apache.commons.jelly.TagSupport;
20 import org.apache.commons.logging.Log;
21 import org.apache.commons.logging.LogFactory;
22
23 /***
24 * An abstract base class for any logging tag..
25 *
26 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
27 * @version $Revision: 155420 $
28 */
29 public abstract class LogTagSupport extends TagSupport {
30
31 private Log log;
32 private boolean encode;
33
34 public LogTagSupport() {
35 }
36
37
38
39
40 /***
41 * @return the Log being used by this tag. If none is returned then a new one will be created.
42 */
43 public Log getLog() {
44 if ( log == null ) {
45
46
47 log = LogFactory.getLog( getClass() );
48 }
49 return log;
50 }
51
52 /***
53 * Sets the name of the logger to use
54 */
55 public void setName(String name) {
56 setLog( LogFactory.getLog(name) );
57 }
58
59 /*** Sets the Log instance to use for logging. */
60 public void setLog(Log log) {
61 this.log = log;
62 }
63
64 /***
65 * Returns whether the body of this tag will be XML encoded or not.
66 */
67 public boolean isEncode() {
68 return encode;
69 }
70
71 /***
72 * Sets whether the body of the tag should be encoded as text (so that < and > are
73 * encoded as &lt; and &gt;) or leave the text as XML which is the default.
74 */
75 public void setEncode(boolean encode) {
76 this.encode = encode;
77 }
78
79 }