From d666630badf8f341f2efc80c4abd5c9a3f2523c3 Mon Sep 17 00:00:00 2001 From: theli Date: Wed, 7 Sep 2005 22:23:53 +0000 Subject: [PATCH] *) Bugfix for Status class not found git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@683 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/IndexCreateIndexingQueue_p.java | 29 +++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/htroot/IndexCreateIndexingQueue_p.java b/htroot/IndexCreateIndexingQueue_p.java index d797d00e4..df0d11f49 100644 --- a/htroot/IndexCreateIndexingQueue_p.java +++ b/htroot/IndexCreateIndexingQueue_p.java @@ -43,6 +43,7 @@ // javac -classpath .:../classes IndexCreate_p.java // if the shell's current path is HTROOT +import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; @@ -153,7 +154,7 @@ public class IndexCreateIndexingQueue_p { prop.put("indexing-queue_list_"+entryCount+"_modified", (pcentry.responseHeader() == null) ? "" : daydate(pcentry.responseHeader().lastModified())); prop.put("indexing-queue_list_"+entryCount+"_anchor", (pcentry.anchorName()==null)?"":pcentry.anchorName()); prop.put("indexing-queue_list_"+entryCount+"_url", pcentry.normalizedURLString()); - prop.put("indexing-queue_list_"+entryCount+"_size", Status.bytesToString(entrySize)); + prop.put("indexing-queue_list_"+entryCount+"_size", bytesToString(entrySize)); prop.put("indexing-queue_list_"+entryCount+"_inProcess", (inProcess)?1:0); prop.put("indexing-queue_list_"+entryCount+"_inProcess_hash", pcentry.urlHash()); dark = !dark; @@ -206,6 +207,32 @@ public class IndexCreateIndexingQueue_p { return prop; } + public static String bytesToString(long byteCount) { + try { + StringBuffer byteString = new StringBuffer(); + + DecimalFormat df = new DecimalFormat( "0.00" ); + if (byteCount > 1073741824) { + byteString.append(df.format((double)byteCount / (double)1073741824 )) + .append(" GB"); + } else if (byteCount > 1048576) { + byteString.append(df.format((double)byteCount / (double)1048576)) + .append(" MB"); + } else if (byteCount > 1024) { + byteString.append(df.format((double)byteCount /(double)1024)) + .append(" KB"); + } else { + byteString.append(Long.toString(byteCount)) + .append(" Bytes"); + } + + return byteString.toString(); + } catch (Exception e) { + return "unknown"; + } + + } + }