KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > idaremedia > antx > feedback > tests > OtherEmitConfiguration


1 /**
2  * $Id: OtherEmitConfiguration.java 180 2007-03-15 12:56:38Z ssmc $
3  * Copyright 2002-2003 iDare Media, Inc. All rights reserved.
4  *
5  * Originally written by iDare Media, Inc. for release into the public domain. This
6  * library, source form and binary form, is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public License as published by the
8  * Free Software Foundation; either version 2 of the License, or (at your option) any later
9  * version.<p>
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13  * See the GNU LGPL (GNU Lesser General Public License) for more details.<p>
14  *
15  * You should have received a copy of the GNU Lesser General Public License along with this
16  * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite
17  * 330, Boston, MA 02111-1307 USA. The LGPL can be found online at
18  * http://www.fsf.org/copyleft/lesser.html<p>
19  *
20  * This product has been influenced by several projects within the open-source community.
21  * The JWare developers wish to acknowledge the open-source community's support. For more
22  * information regarding the open-source products used within JWare, please visit the
23  * JWare website.
24  *----------------------------------------------------------------------------------------*
25  * WEBSITE- http://www.jware.info EMAIL- inquiries@jware.info
26  *----------------------------------------------------------------------------------------*
27  **/

28
29 package com.idaremedia.antx.feedback.tests;
30
31 import com.idaremedia.apis.DiagnosticsEmitter;
32
33 import com.idaremedia.antx.NoiseLevel;
34 import com.idaremedia.antx.feedback.DefaultEmitConfiguration;
35 import com.idaremedia.antx.feedback.EmitConfiguration;
36 import com.idaremedia.antx.feedback.LJDiagnosticsEmitter;
37
38 /**
39  * Fake configuration that differs from DefaultEmitConfiguration. Used to verify that
40  * EmitContexts work.
41  *
42  * @since JWare/AntX 0.1
43  * @author ssmc, &copy;2002-2003 <a HREF="http://www.jware.info">iDare&nbsp;Media,&nbsp;Inc.</a>
44  * @version 0.5
45  * @.safety multiple
46  * @.group impl,test,helper
47  **/

48
49 public final class OtherEmitConfiguration implements EmitConfiguration
50 {
51     /**
52      * Initialize new default configuration. (Anyone can create a default
53      * instance although the singleton is all that's needed for most uses.)
54      **/

55     public OtherEmitConfiguration()
56     {
57         m_rootEmitter = LJDiagnosticsEmitter.FACTORY.newEmitter("Mock.JWare.AntX.EmitConfiguration");
58     }
59
60
61     /**
62      * Returns a wrapper for a fixed Log4j logger.
63      **/

64     public DiagnosticsEmitter getEmitter()
65     {
66         return m_rootEmitter;
67     }
68
69
70     /**
71      * Returns a wrapper for the Log4j logger of specified
72      * grouping. Delegates to the default configuration.
73      **/

74     public DiagnosticsEmitter getCustomEmitter(String JavaDoc grpId)
75     {
76         return DefaultEmitConfiguration.INSTANCE.getCustomEmitter(grpId);
77     }
78
79
80     /**
81      * Returns the default runtime noiselevel.
82      **/

83     public NoiseLevel getNoiseLevel()
84     {
85         return NoiseLevel.ERROR;
86     }
87
88
89     /**
90      * Returns the default grouping (empty string).
91      **/

92     public String JavaDoc getFrom()
93     {
94         return "";
95     }
96
97
98     /**
99      * Updates incoming buffer with list of special properties values
100      * to be recorded. No-op.
101      **/

102     public boolean getPropertiesNameList(StringBuffer JavaDoc list)
103     {
104         list.append("ant.version");
105         return true;
106     }
107
108
109     /**
110      * Returns <i>true</i> to automatically include timestamps always.
111      **/

112     public boolean wantTimestamp()
113     {
114         return true;
115     }
116
117
118     /**
119      * Returns a simple MEDIUM formatted date-time string.
120      * Delegates to the default configuration.
121      * @param ms the timestamp (milliseconds)
122      **/

123     public String JavaDoc stampify(long ms)
124     {
125         return DefaultEmitConfiguration.INSTANCE.stampify(ms);
126     }
127
128
129     /**
130      * Returns <i>false</i> so emitted messages are not passed
131      * to Ant's standard logging system.
132      **/

133     public boolean shouldEcho()
134     {
135         m_shouldEchoCalls++;
136         return false;
137     }
138     public int getShouldEchoCalls()
139     {
140         return m_shouldEchoCalls;
141     }
142
143
144     /**
145      * Returns a single dot.
146      **/

147     public String JavaDoc getGroupingPathSeparator()
148     {
149         return ".";
150     }
151
152
153     private final DiagnosticsEmitter m_rootEmitter;
154     private int m_shouldEchoCalls=0;
155 }
156
157 /* end-of-OtherEmitConfiguration.java */
158
Popular Tags