You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-commits@incubator.apache.org by xa...@apache.org on 2007/09/26 05:33:53 UTC

svn commit: r579478 - /incubator/ivy/core/trunk/src/java/org/apache/ivy/util/Message.java

Author: xavier
Date: Tue Sep 25 22:33:51 2007
New Revision: 579478

URL: http://svn.apache.org/viewvc?rev=579478&view=rev
Log:
code cleanup

Modified:
    incubator/ivy/core/trunk/src/java/org/apache/ivy/util/Message.java

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/Message.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/Message.java?rev=579478&r1=579477&r2=579478&view=diff
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/Message.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/Message.java Tue Sep 25 22:33:51 2007
@@ -28,9 +28,14 @@
 import org.apache.ivy.core.IvyContext;
 
 /**
- * 
+ * Logging utility class.
+ * <p>
+ * To initialize Message you can call {@link #init(MessageImpl)} with
+ * the {@link MessageImpl} of your choice.
+ * <p> 
+ * This only takes effect in the current thread.
  */
-public class Message {
+public final class Message {
     // messages level copied from ant project, to avoid dependency on ant
     /** Message priority of "error". */
     public static final int MSG_ERR = 0;
@@ -47,15 +52,15 @@
     /** Message priority of "debug". */
     public static final int MSG_DEBUG = 4;
 
-    private static List _problems = new ArrayList();
+    private static List problems = new ArrayList();
 
-    private static List _warns = new ArrayList();
+    private static List warns = new ArrayList();
 
-    private static List _errors = new ArrayList();
+    private static List errors = new ArrayList();
 
-    private static boolean _showProgress = true;
+    private static boolean showProgress = true;
 
-    private static boolean _showedInfo = false;
+    private static boolean showedInfo = false;
 
     public static void init(MessageImpl impl) {
         IvyContext.getContext().setMessageImpl(impl);
@@ -80,7 +85,7 @@
     }
 
     private static void showInfo() {
-        if (!_showedInfo) {
+        if (!showedInfo) {
             Properties props = new Properties();
             URL moduleURL = Message.class.getResource("/module.properties");
             if (moduleURL != null) {
@@ -89,7 +94,7 @@
                     props.load(module);
                     debug("version information loaded from " + moduleURL);
                     info(":: Ivy " + props.getProperty("version") + " - "
-                            + props.getProperty("date") + " :: http://incubator.apache.org/ivy/ ::");
+                           + props.getProperty("date") + " :: http://incubator.apache.org/ivy/ ::");
                     module.close();
                 } catch (IOException e) {
                     info(":: Ivy non official version :: http://incubator.apache.org/ivy/ ::");
@@ -97,7 +102,7 @@
             } else {
                 info(":: Ivy non official version :: http://incubator.apache.org/ivy/ ::");
             }
-            _showedInfo = true;
+            showedInfo = true;
         }
     }
 
@@ -153,8 +158,8 @@
         } else {
             System.err.println(msg);
         }
-        _problems.add("WARN:  " + msg);
-        _warns.add(msg);
+        problems.add("WARN:  " + msg);
+        warns.add(msg);
     }
 
     public static void error(String msg) {
@@ -166,21 +171,21 @@
         } else {
             System.err.println(msg);
         }
-        _problems.add("\tERROR: " + msg);
-        _errors.add(msg);
+        problems.add("\tERROR: " + msg);
+        errors.add(msg);
     }
 
     public static List getProblems() {
-        return _problems;
+        return problems;
     }
 
     public static void sumupProblems() {
-        if (_problems.size() > 0) {
+        if (problems.size() > 0) {
             info("\n:: problems summary ::");
             MessageImpl messageImpl = IvyContext.getContext().getMessageImpl();
-            if (_warns.size() > 0) {
+            if (warns.size() > 0) {
                 info(":::: WARNINGS");
-                for (Iterator iter = _warns.iterator(); iter.hasNext();) {
+                for (Iterator iter = warns.iterator(); iter.hasNext();) {
                     String msg = (String) iter.next();
                     if (messageImpl != null) {
                         messageImpl.log("\t" + msg + "\n", MSG_WARN);
@@ -189,9 +194,9 @@
                     }
                 }
             }
-            if (_errors.size() > 0) {
+            if (errors.size() > 0) {
                 info(":::: ERRORS");
-                for (Iterator iter = _errors.iterator(); iter.hasNext();) {
+                for (Iterator iter = errors.iterator(); iter.hasNext();) {
                     String msg = (String) iter.next();
                     if (messageImpl != null) {
                         messageImpl.log("\t" + msg + "\n", MSG_ERR);
@@ -201,14 +206,14 @@
                 }
             }
             info("\n:: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS");
-            _problems.clear();
-            _warns.clear();
-            _errors.clear();
+            problems.clear();
+            warns.clear();
+            errors.clear();
         }
     }
 
     public static void progress() {
-        if (_showProgress) {
+        if (showProgress) {
             MessageImpl messageImpl = IvyContext.getContext().getMessageImpl();
             if (messageImpl != null) {
                 messageImpl.progress();
@@ -223,7 +228,7 @@
     }
 
     public static void endProgress(String msg) {
-        if (_showProgress) {
+        if (showProgress) {
             MessageImpl messageImpl = IvyContext.getContext().getMessageImpl();
             if (messageImpl != null) {
                 messageImpl.endProgress(msg);
@@ -232,14 +237,17 @@
     }
 
     public static boolean isShowProgress() {
-        return _showProgress;
+        return showProgress;
     }
 
     public static void setShowProgress(boolean progress) {
-        _showProgress = progress;
+        showProgress = progress;
     }
 
     public static void uninit() {
         IvyContext.getContext().setMessageImpl(null);
+    }
+    
+    private Message() {
     }
 }