logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1172394 - in /logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src: main/java/org/apache/logging/log4j/message/ThreadDumpMessage.java test/java/org/apache/logging/log4j/message/ThreadDumpMessageTest.java
Date Sun, 18 Sep 2011 23:37:36 GMT
Author: rgoers
Date: Sun Sep 18 23:37:36 2011
New Revision: 1172394

URL: http://svn.apache.org/viewvc?rev=1172394&view=rev
Log:
Add equals, hashcode and javadoc

Modified:
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/ThreadDumpMessage.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/message/ThreadDumpMessageTest.java

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/ThreadDumpMessage.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/ThreadDumpMessage.java?rev=1172394&r1=1172393&r2=1172394&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/ThreadDumpMessage.java
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/ThreadDumpMessage.java
Sun Sep 18 23:37:36 2011
@@ -39,6 +39,10 @@ public class ThreadDumpMessage implement
 
     }
 
+    /**
+     * Generate a ThreadDumpMessage with a title.
+     * @param title The title.
+     */
     public ThreadDumpMessage(String title) {
         this.title = title == null ? "" : title;
         Map<Thread, StackTraceElement[]> map = Thread.getAllStackTraces();
@@ -48,6 +52,10 @@ public class ThreadDumpMessage implement
         }
     }
 
+    /**
+     * Return the ThreadDump in printable format.
+     * @return the ThreadDump suitable for logging.
+     */
     public String getFormattedMessage() {
         if (formattedMessage != null) {
             return formattedMessage;
@@ -83,10 +91,19 @@ public class ThreadDumpMessage implement
         }
     }
 
+    /**
+     * Returns the title.
+     * @return the title.
+     */
     public String getMessageFormat() {
         return title == null ? "" : title;
     }
 
+    /**
+     * Returns an array with a single element, a Map containing the ThreadInformation as
the key
+     * and the StackTraceElement array as the value;
+     * @return the "parameters" to this Message.
+     */
     public Object[] getParameters() {
         return new Object[] {threads};
     }
@@ -118,5 +135,32 @@ public class ThreadDumpMessage implement
             threadGroupName = group == null ? null : group.getName();
         }
 
+        @Override
+        public boolean equals(Object o) {
+            if (this == o) {
+                return true;
+            }
+            if (o == null || getClass() != o.getClass()) {
+                return false;
+            }
+
+            ThreadInfo that = (ThreadInfo) o;
+
+            if (id != that.id) {
+                return false;
+            }
+            if (name != null ? !name.equals(that.name) : that.name != null) {
+                return false;
+            }
+
+            return true;
+        }
+
+        @Override
+        public int hashCode() {
+            int result = (int) (id ^ (id >>> 32));
+            result = 31 * result + (name != null ? name.hashCode() : 0);
+            return result;
+        }
     }
 }

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/message/ThreadDumpMessageTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/message/ThreadDumpMessageTest.java?rev=1172394&r1=1172393&r2=1172394&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/message/ThreadDumpMessageTest.java
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/message/ThreadDumpMessageTest.java
Sun Sep 18 23:37:36 2011
@@ -30,6 +30,7 @@ public class ThreadDumpMessageTest {
         ThreadDumpMessage msg = new ThreadDumpMessage("Testing");
 
         String message = msg.getFormattedMessage();
+        //System.out.print(message);
         assertTrue("No header", message.contains("Testing"));
         assertTrue("No RUNNABLE", message.contains("RUNNABLE"));
         assertTrue("No ThreadDumpMessage", message.contains("ThreadDumpMessage"));



Mime
View raw message