KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > types > LogLevel


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */

18
19 package org.apache.tools.ant.types;
20
21 import org.apache.tools.ant.Project;
22
23 /**
24  * The enumerated values for Ant's log level.
25  */

26 public class LogLevel extends EnumeratedAttribute {
27
28     /** ERR loglevel constant. */
29     public static final LogLevel ERR = new LogLevel("error");
30
31     /** WARN loglevel constant. */
32     public static final LogLevel WARN = new LogLevel("warn");
33
34     /** INFO loglevel constant. */
35     public static final LogLevel INFO = new LogLevel("info");
36
37     /** VERBOSE loglevel constant. */
38     public static final LogLevel VERBOSE = new LogLevel("verbose");
39
40     /** DEBUG loglevel constant. */
41     public static final LogLevel DEBUG = new LogLevel("debug");
42
43     /**
44      * Public constructor.
45      */

46     public LogLevel() {
47     }
48
49     private LogLevel(String JavaDoc value) {
50         this();
51         setValue(value);
52     }
53
54     /**
55      * @see EnumeratedAttribute#getValues
56      * @return the strings allowed for the level attribute
57      */

58     public String JavaDoc[] getValues() {
59         return new String JavaDoc[] {
60             "error",
61             "warn",
62             "warning",
63             "info",
64             "verbose",
65             "debug"};
66     }
67
68     /**
69      * mapping of enumerated values to log levels
70      */

71     private static int[] levels = {
72         Project.MSG_ERR,
73         Project.MSG_WARN,
74         Project.MSG_WARN,
75         Project.MSG_INFO,
76         Project.MSG_VERBOSE,
77         Project.MSG_DEBUG
78     };
79
80     /**
81      * get the level of the echo of the current value
82      * @return the level
83      */

84     public int getLevel() {
85         return levels[getIndex()];
86     }
87 }
88
Popular Tags