KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > vladium > emma > ant > VerbosityCfg


1 /* Copyright (C) 2003 Vladimir Roubtsov. All rights reserved.
2  *
3  * This program and the accompanying materials are made available under
4  * the terms of the Common Public License v1.0 which accompanies this distribution,
5  * and is available at http://www.eclipse.org/legal/cpl-v10.html
6  *
7  * $Id: VerbosityCfg.java,v 1.1.2.1 2004/07/16 23:32:04 vlad_r Exp $
8  */

9 package com.vladium.emma.ant;
10
11 import java.util.Properties JavaDoc;
12
13 import org.apache.tools.ant.types.EnumeratedAttribute;
14
15 import com.vladium.emma.AppLoggers;
16 import com.vladium.emma.EMMAProperties;
17 import com.vladium.logging.ILogLevels;
18 import com.vladium.util.IProperties;
19
20 // ----------------------------------------------------------------------------
21
/**
22  * @author Vlad Roubtsov, (C) 2004
23  */

24 public
25 final class VerbosityCfg
26 {
27     // public: ................................................................
28

29
30     public static final class VerbosityAttribute extends EnumeratedAttribute
31     {
32         public String JavaDoc [] getValues ()
33         {
34             return VALUES;
35         }
36         
37         private static final String JavaDoc [] VALUES = new String JavaDoc []
38             {
39                 ILogLevels.SEVERE_STRING,
40                 ILogLevels.SILENT_STRING,
41                 ILogLevels.WARNING_STRING,
42                 ILogLevels.QUIET_STRING,
43                 ILogLevels.INFO_STRING,
44                 ILogLevels.VERBOSE_STRING,
45                 ILogLevels.TRACE1_STRING,
46                 ILogLevels.TRACE2_STRING,
47                 ILogLevels.TRACE3_STRING,
48             };
49
50     } // end of nested class
51

52
53     // verbosity attribute:
54

55     public void setVerbosity (final VerbosityAttribute verbosity)
56     {
57         m_verbosity = verbosity.getValue ();
58     }
59     
60     // verbosity class filter attribute:
61

62     public void setVerbosityfilter (final String JavaDoc filter)
63     {
64         m_verbosityFilter = filter;
65     }
66     
67     // ACCESSORS:
68

69     public IProperties getSettings ()
70     {
71         IProperties settings = m_settings;
72         if (settings == null)
73         {
74             settings = EMMAProperties.wrap (new Properties JavaDoc ());
75             
76             if ((m_verbosity != null) && (m_verbosity.trim ().length () > 0))
77                 settings.setProperty (AppLoggers.PROPERTY_VERBOSITY_LEVEL, m_verbosity.trim ());
78             
79             if ((m_verbosityFilter != null) && (m_verbosityFilter.trim ().length () > 0))
80                 settings.setProperty (AppLoggers.PROPERTY_VERBOSITY_FILTER, m_verbosityFilter.trim ());
81             
82             m_settings = settings;
83             return settings;
84         }
85         
86         return settings;
87     }
88     
89     // protected: .............................................................
90

91     // package: ...............................................................
92

93     // private: ...............................................................
94

95     
96     private String JavaDoc m_verbosity;
97     private String JavaDoc m_verbosityFilter;
98     
99     private transient IProperties m_settings; // can be null
100

101 } // end of class
102
// ----------------------------------------------------------------------------
Popular Tags