Author: mbenson
Date: Fri Sep 22 11:42:21 2006
New Revision: 449046
URL: http://svn.apache.org/viewvc?view=rev&rev=449046
Log:
incorporate new LogLevel EA into <echo> and <record>. Are there others?
Added:
ant/core/trunk/src/main/org/apache/tools/ant/types/LogLevel.java (with
props)
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Echo.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Recorder.java
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Echo.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Echo.java?view=diff&rev=449046&r1=449045&r2=449046
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Echo.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Echo.java Fri Sep 22
11:42:21 2006
@@ -30,7 +30,8 @@
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.util.FileUtils;
-import org.apache.tools.ant.types.EnumeratedAttribute;
+import org.apache.tools.ant.types.LogLevel;
+
/**
* Writes a message to the Ant logging facilities.
*
@@ -141,37 +142,6 @@
/**
* The enumerated values for the level attribute.
*/
- public static class EchoLevel extends EnumeratedAttribute {
- /**
- * @see EnumeratedAttribute#getValues
- * @return the strings allowed for the level attribute
- */
- public String[] getValues() {
- return new String[] {
- "error",
- "warning",
- "info",
- "verbose",
- "debug"};
- }
-
- /**
- * mapping of enumerated values to log levels
- */
- private static int[] levels = {
- Project.MSG_ERR,
- Project.MSG_WARN,
- Project.MSG_INFO,
- Project.MSG_VERBOSE,
- Project.MSG_DEBUG
- };
-
- /**
- * get the level of the echo of the current value
- * @return the level
- */
- public int getLevel() {
- return levels[getIndex()];
- }
+ public static class EchoLevel extends LogLevel {
}
}
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Recorder.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Recorder.java?view=diff&rev=449046&r1=449045&r2=449046
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Recorder.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Recorder.java Fri Sep
22 11:42:21 2006
@@ -24,6 +24,7 @@
import org.apache.tools.ant.SubBuildListener;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.EnumeratedAttribute;
+import org.apache.tools.ant.types.LogLevel;
/**
* Adds a listener to the current build process that records the
@@ -130,20 +131,7 @@
* @see VerbosityLevelChoices
*/
public void setLoglevel(VerbosityLevelChoices level) {
- //I hate cascading if/elseif clauses !!!
- String lev = level.getValue();
-
- if (lev.equalsIgnoreCase("error")) {
- loglevel = Project.MSG_ERR;
- } else if (lev.equalsIgnoreCase("warn")) {
- loglevel = Project.MSG_WARN;
- } else if (lev.equalsIgnoreCase("info")) {
- loglevel = Project.MSG_INFO;
- } else if (lev.equalsIgnoreCase("verbose")) {
- loglevel = Project.MSG_VERBOSE;
- } else if (lev.equalsIgnoreCase("debug")) {
- loglevel = Project.MSG_DEBUG;
- }
+ loglevel = level.getLevel();
}
//////////////////////////////////////////////////////////////////////
@@ -200,16 +188,7 @@
* A list of possible values for the <code>setLoglevel()</code> method.
* Possible values include: error, warn, info, verbose, debug.
*/
- public static class VerbosityLevelChoices extends EnumeratedAttribute {
- private static final String[] VALUES = {"error", "warn", "info",
- "verbose", "debug"};
-
- /**
- * @see EnumeratedAttribute#getValues()
- */
- public String[] getValues() {
- return VALUES;
- }
+ public static class VerbosityLevelChoices extends LogLevel {
}
Added: ant/core/trunk/src/main/org/apache/tools/ant/types/LogLevel.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/LogLevel.java?view=auto&rev=449046
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/LogLevel.java (added)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/LogLevel.java Fri Sep 22
11:42:21 2006
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.tools.ant.types;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+import java.io.BufferedWriter;
+import java.io.OutputStreamWriter;
+import java.io.FileOutputStream;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.util.FileUtils;
+import org.apache.tools.ant.types.EnumeratedAttribute;
+
+/**
+ * The enumerated values for Ant's log level.
+ */
+public class LogLevel extends EnumeratedAttribute {
+
+ /** ERR loglevel constant. */
+ public static final LogLevel ERR = new LogLevel("error");
+
+ /** WARN loglevel constant. */
+ public static final LogLevel WARN = new LogLevel("warn");
+
+ /** INFO loglevel constant. */
+ public static final LogLevel INFO = new LogLevel("info");
+
+ /** VERBOSE loglevel constant. */
+ public static final LogLevel VERBOSE = new LogLevel("verbose");
+
+ /** DEBUG loglevel constant. */
+ public static final LogLevel DEBUG = new LogLevel("debug");
+
+ /**
+ * Public constructor.
+ */
+ public LogLevel() {
+ }
+
+ private LogLevel(String value) {
+ this();
+ setValue(value);
+ }
+
+ /**
+ * @see EnumeratedAttribute#getValues
+ * @return the strings allowed for the level attribute
+ */
+ public String[] getValues() {
+ return new String[] {
+ "error",
+ "warn",
+ "warning",
+ "info",
+ "verbose",
+ "debug"};
+ }
+
+ /**
+ * mapping of enumerated values to log levels
+ */
+ private static int[] levels = {
+ Project.MSG_ERR,
+ Project.MSG_WARN,
+ Project.MSG_WARN,
+ Project.MSG_INFO,
+ Project.MSG_VERBOSE,
+ Project.MSG_DEBUG
+ };
+
+ /**
+ * get the level of the echo of the current value
+ * @return the level
+ */
+ public int getLevel() {
+ return levels[getIndex()];
+ }
+}
Propchange: ant/core/trunk/src/main/org/apache/tools/ant/types/LogLevel.java
------------------------------------------------------------------------------
svn:eol-style = native
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]