logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sde...@apache.org
Subject svn commit: r930644 - in /logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/xml: UtilLoggingXMLDecoder.java XMLDecoder.java
Date Sun, 04 Apr 2010 08:41:33 GMT
Author: sdeboy
Date: Sun Apr  4 08:41:32 2010
New Revision: 930644

URL: http://svn.apache.org/viewvc?rev=930644&view=rev
Log:
Chainsaw updates
 - It's now possible to directly load events stored in a zip file created when saving events
to a file with a zip extension
 - Now hiding the receivers panel by default
 - Reduced the default size of the details pane
 - Updated logpanel details, welcome tab and release notes panes to use system fonts and size

Modified:
    logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/xml/UtilLoggingXMLDecoder.java
    logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/xml/XMLDecoder.java

Modified: logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/xml/UtilLoggingXMLDecoder.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/xml/UtilLoggingXMLDecoder.java?rev=930644&r1=930643&r2=930644&view=diff
==============================================================================
--- logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/xml/UtilLoggingXMLDecoder.java
(original)
+++ logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/xml/UtilLoggingXMLDecoder.java
Sun Apr  4 08:41:32 2010
@@ -19,6 +19,7 @@ package org.apache.log4j.xml;
 
 import java.awt.Component;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.LineNumberReader;
 import java.io.StringReader;
@@ -29,6 +30,7 @@ import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Vector;
+import java.util.zip.ZipInputStream;
 
 import javax.swing.ProgressMonitorInputStream;
 import javax.xml.parsers.DocumentBuilder;
@@ -89,6 +91,8 @@ public class UtilLoggingXMLDecoder imple
      */
   private Component owner = null;
 
+  private static final String ENCODING = "UTF-8";
+
     /**
      * Create new instance.
      * @param o owner
@@ -177,14 +181,23 @@ public class UtilLoggingXMLDecoder imple
    * @throws IOException if IO error during processing.
    */
   public Vector decode(final URL url) throws IOException {
-    LineNumberReader reader = null;
+    LineNumberReader reader;
+    boolean isZipFile = url.getPath().toLowerCase().endsWith(".zip");
+    InputStream inputStream;
+    if (isZipFile) {
+        inputStream = new ZipInputStream(url.openStream());
+        //move stream to next entry so we can read it
+        ((ZipInputStream)inputStream).getNextEntry();
+    } else {
+        inputStream = url.openStream();
+    }
     if (owner != null) {
         reader = new LineNumberReader(
                 new InputStreamReader(
                         new ProgressMonitorInputStream(owner,
-                                "Loading " + url , url.openStream())));
+                                "Loading " + url , inputStream), ENCODING));
     } else {
-        reader = new LineNumberReader(new InputStreamReader(url.openStream()));
+        reader = new LineNumberReader(new InputStreamReader(inputStream, ENCODING));
     }
     Vector v = new Vector();
 

Modified: logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/xml/XMLDecoder.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/xml/XMLDecoder.java?rev=930644&r1=930643&r2=930644&view=diff
==============================================================================
--- logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/xml/XMLDecoder.java
(original)
+++ logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/xml/XMLDecoder.java
Sun Apr  4 08:41:32 2010
@@ -19,6 +19,7 @@ package org.apache.log4j.xml;
 
 import java.awt.Component;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.LineNumberReader;
 import java.io.StringReader;
@@ -28,6 +29,7 @@ import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Vector;
+import java.util.zip.ZipInputStream;
 
 import javax.swing.ProgressMonitorInputStream;
 import javax.xml.parsers.DocumentBuilder;
@@ -184,12 +186,22 @@ public class XMLDecoder implements Decod
    */
   public Vector decode(final URL url) throws IOException {
     LineNumberReader reader;
+    boolean isZipFile = url.getPath().toLowerCase().endsWith(".zip");
+    InputStream inputStream;
+    if (isZipFile) {
+        inputStream = new ZipInputStream(url.openStream());
+        //move stream to next entry so we can read it
+        ((ZipInputStream)inputStream).getNextEntry();
+    } else {
+        inputStream = url.openStream();
+    }
     if (owner != null) {
-      reader = new LineNumberReader(new InputStreamReader(
-              new ProgressMonitorInputStream(owner,
-                      "Loading " + url , url.openStream()), ENCODING));
+        reader = new LineNumberReader(
+                new InputStreamReader(
+                        new ProgressMonitorInputStream(owner,
+                                "Loading " + url , inputStream), ENCODING));
     } else {
-      reader = new LineNumberReader(new InputStreamReader(url.openStream(), ENCODING));
+        reader = new LineNumberReader(new InputStreamReader(inputStream, ENCODING));
     }
 
     Vector v = new Vector();



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message