Author: nextgens
Date: 2007-03-17 13:48:51 +0000 (Sat, 17 Mar 2007)
New Revision: 12178

Added:
   trunk/freenet/src/freenet/support/StringArray.java
Modified:
   trunk/freenet/src/freenet/node/FNPPacketMangler.java
   trunk/freenet/src/freenet/oldplugins/plugin/PluginManager.java
   trunk/freenet/src/freenet/store/BerkeleyDBFreenetStore.java
Log:
Implement a StringArray.toString() method ... and apply it where usefull.

Maybe we shouldn't display the data in BerkleyDBFreenetStore though... it might 
be too big.

Modified: trunk/freenet/src/freenet/node/FNPPacketMangler.java
===================================================================
--- trunk/freenet/src/freenet/node/FNPPacketMangler.java        2007-03-17 
13:15:06 UTC (rev 12177)
+++ trunk/freenet/src/freenet/node/FNPPacketMangler.java        2007-03-17 
13:48:51 UTC (rev 12178)
@@ -20,6 +20,7 @@
 import freenet.support.Fields;
 import freenet.support.HexUtil;
 import freenet.support.Logger;
+import freenet.support.StringArray;
 import freenet.support.TimeUtil;
 import freenet.support.WouldBlockException;

@@ -990,7 +991,7 @@
                 alreadyReported[x] = mi.alreadyReportedBytes;
                 x++;
                 if(mi.cb != null) callbacksCount += mi.cb.length;
-                if(logMINOR) Logger.minor(this, "Sending: "+mi+" length 
"+data.length+" cb "+mi.cb);
+                if(logMINOR) Logger.minor(this, "Sending: "+mi+" length 
"+data.length+" cb "+ StringArray.toString(mi.cb));
                 length += (data.length + 2);
             }
         }

Modified: trunk/freenet/src/freenet/oldplugins/plugin/PluginManager.java
===================================================================
--- trunk/freenet/src/freenet/oldplugins/plugin/PluginManager.java      
2007-03-17 13:15:06 UTC (rev 12177)
+++ trunk/freenet/src/freenet/oldplugins/plugin/PluginManager.java      
2007-03-17 13:48:51 UTC (rev 12178)
@@ -14,6 +14,7 @@
 import freenet.node.Node;
 import freenet.node.NodeClientCore;
 import freenet.support.Logger;
+import freenet.support.StringArray;
 import freenet.support.api.StringArrCallback;

 /**
@@ -65,7 +66,7 @@
                                        }
                                }
                                if(Logger.shouldLog(Logger.MINOR, this))
-                                       Logger.minor(this, "Plugin list: 
"+retval);
+                                       Logger.minor(this, "Plugin list: " + 
StringArray.toString(retval));
                                return retval;
                        };


Modified: trunk/freenet/src/freenet/store/BerkeleyDBFreenetStore.java
===================================================================
--- trunk/freenet/src/freenet/store/BerkeleyDBFreenetStore.java 2007-03-17 
13:15:06 UTC (rev 12177)
+++ trunk/freenet/src/freenet/store/BerkeleyDBFreenetStore.java 2007-03-17 
13:48:51 UTC (rev 12178)
@@ -1305,9 +1305,9 @@
                        }

                        if(logMINOR) {
-                               Logger.minor(this, "Get key: "+chk);
-                               Logger.minor(this, "Headers: "+header.length+" 
bytes, hash "+header);
-                               Logger.minor(this, "Data: "+data.length+" 
bytes, hash "+data+" fetching "+chk);
+                               Logger.minor(this, "Get key: " + chk);
+                               Logger.minor(this, "Headers: " + 
header.length+" bytes, hash " + HexUtil.bytesToHex(header));
+                               Logger.minor(this, "Data: " + data.length + " 
bytes, hash " + HexUtil.bytesToHex(data) + " fetching " + chk);
                        }

                }catch(CHKVerifyException ex){
@@ -1411,8 +1411,8 @@
                        }

                        if(logMINOR) {
-                               Logger.minor(this, "Headers: "+header.length+" 
bytes, hash "+header);
-                               Logger.minor(this, "Data: "+data.length+" 
bytes, hash "+data+" fetching "+chk);
+                               Logger.minor(this, "Headers: " + 
header.length+" bytes, hash " + HexUtil.bytesToHex(header));
+                               Logger.minor(this, "Data: " + data.length + " 
bytes, hash " + HexUtil.bytesToHex(data) + " fetching " + chk);
                        }

                }catch(SSKVerifyException ex){
@@ -1535,7 +1535,7 @@
                t = null;

                if(logMINOR) {
-                       Logger.minor(this, "Data: "+data.length+" bytes, hash 
"+data+" fetching "+HexUtil.bytesToHex(hash));
+                       Logger.minor(this, "Data: " + data.length + " bytes, 
hash " + HexUtil.bytesToHex(data) + " fetching "+HexUtil.bytesToHex(hash));
                }

                synchronized(this) {
@@ -1869,7 +1869,7 @@
         byte[] data = key.asPaddedBytes();

         if(!(Arrays.equals(hash, key.asBytesHash()))) {
-               Logger.error(this, "Invalid hash!: "+HexUtil.bytesToHex(hash)+" 
: "+key.asBytesHash());
+               Logger.error(this, "Invalid hash!: " + HexUtil.bytesToHex(hash) 
+ " : " + HexUtil.bytesToHex(key.asBytesHash()));
         }

         if(data.length!=dataBlockSize) {

Added: trunk/freenet/src/freenet/support/StringArray.java
===================================================================
--- trunk/freenet/src/freenet/support/StringArray.java                          
(rev 0)
+++ trunk/freenet/src/freenet/support/StringArray.java  2007-03-17 13:48:51 UTC 
(rev 12178)
@@ -0,0 +1,28 @@
+/* This code is part of Freenet. It is distributed under the GNU General
+ * Public License, version 2 (or at your option any later version). See
+ * http://www.gnu.org/ for further details of the GPL. */
+
+package freenet.support;
+
+/**
+ * This class implements various toString methods available in java 1.5 but 
not 1.4
+ * 
+ * @author Florent Daignière <nextgens at freenetproject.org>
+ */
+public class StringArray {
+       
+       /**
+        * This method implements the equivalent of Arrays.valueOf() (java 1.5)
+        * @param array
+        * @return string
+        */
+       public static String toString(Object[] array){
+               if((array != null) && (array.length > 0)){
+                       StringBuffer sb = new StringBuffer();
+                       for(int i=0; i<array.length; i++)
+                               sb.append(array.toString()+'|');
+                       return '[' + sb.substring(0, sb.length() - 
1).toString() + ']';
+               }else
+                       return "";
+       }
+}


Reply via email to