Merge branch 'subtree'
[fanfix.git] / src / be / nikiroo / utils / StringUtils.java
index f7548aecca717c19aff3b0c60db338f5ad0fe1df..be1c654502f58bd91554873a0b241876837a33c0 100644 (file)
@@ -156,6 +156,30 @@ public class StringUtils {
                return text;
        }
 
+       /**
+        * Justify a text into width-sized (at the maximum) lines and return all the
+        * lines concatenated into a single '\\n'-separated line of text.
+        * 
+        * @param text
+        *            the {@link String} to justify
+        * @param width
+        *            the maximum size of the resulting lines
+        * 
+        * @return a list of justified text lines concatenated into a single
+        *         '\\n'-separated line of text
+        */
+       static public String justifyTexts(String text, int width) {
+               StringBuilder builder = new StringBuilder();
+               for (String line : justifyText(text, width, null)) {
+                       if (builder.length() > 0) {
+                               builder.append('\n');
+                       }
+                       builder.append(line);
+               }
+
+               return builder.toString();
+       }
+
        /**
         * Justify a text into width-sized (at the maximum) lines.
         * 
@@ -430,7 +454,10 @@ public class StringUtils {
         *            the input data
         * 
         * @return the hash
+        * 
+        * @deprecated please use {@link HashUtils}
         */
+       @Deprecated
        static public String getMd5Hash(String input) {
                try {
                        MessageDigest md = MessageDigest.getInstance("MD5");
@@ -689,10 +716,10 @@ public class StringUtils {
         * <p>
         * Examples:
         * <ul>
-        * <li><tt>8 765</tt> becomes "8k"</li>
-        * <li><tt>998 765</tt> becomes "998k"</li>
-        * <li><tt>12 987 364</tt> becomes "12M"</li>
-        * <li><tt>5 534 333 221</tt> becomes "5G"</li>
+        * <li><tt>8 765</tt> becomes "8 k"</li>
+        * <li><tt>998 765</tt> becomes "998 k"</li>
+        * <li><tt>12 987 364</tt> becomes "12 M"</li>
+        * <li><tt>5 534 333 221</tt> becomes "5 G"</li>
         * </ul>
         * 
         * @param value
@@ -710,10 +737,10 @@ public class StringUtils {
         * <p>
         * Examples (assuming decimalPositions = 1):
         * <ul>
-        * <li><tt>8 765</tt> becomes "8.7k"</li>
-        * <li><tt>998 765</tt> becomes "998.7k"</li>
-        * <li><tt>12 987 364</tt> becomes "12.9M"</li>
-        * <li><tt>5 534 333 221</tt> becomes "5.5G"</li>
+        * <li><tt>8 765</tt> becomes "8.7 k"</li>
+        * <li><tt>998 765</tt> becomes "998.7 k"</li>
+        * <li><tt>12 987 364</tt> becomes "12.9 M"</li>
+        * <li><tt>5 534 333 221</tt> becomes "5.5 G"</li>
         * </ul>
         * 
         * @param value
@@ -725,7 +752,7 @@ public class StringUtils {
         */
        public static String formatNumber(long value, int decimalPositions) {
                long userValue = value;
-               String suffix = "";
+               String suffix = " ";
                long mult = 1;
 
                if (value >= 1000000000l) {