• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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;
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     {
getValues()32         public String [] getValues ()
33         {
34             return VALUES;
35         }
36 
37         private static final String [] VALUES = new String []
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 
setVerbosity(final VerbosityAttribute verbosity)55     public void setVerbosity (final VerbosityAttribute verbosity)
56     {
57         m_verbosity = verbosity.getValue ();
58     }
59 
60     // verbosity class filter attribute:
61 
setVerbosityfilter(final String filter)62     public void setVerbosityfilter (final String filter)
63     {
64         m_verbosityFilter = filter;
65     }
66 
67     // ACCESSORS:
68 
getSettings()69     public IProperties getSettings ()
70     {
71         IProperties settings = m_settings;
72         if (settings == null)
73         {
74             settings = EMMAProperties.wrap (new Properties ());
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 m_verbosity;
97     private String m_verbosityFilter;
98 
99     private transient IProperties m_settings; // can be null
100 
101 } // end of class
102 // ----------------------------------------------------------------------------