KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jcorporate > expresso > core > misc > StringUtil


1 /* ====================================================================
2  * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
3  *
4  * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  *
18  * 3. The end-user documentation included with the redistribution,
19  * if any, must include the following acknowledgment:
20  * "This product includes software developed by Jcorporate Ltd.
21  * (http://www.jcorporate.com/)."
22  * Alternately, this acknowledgment may appear in the software itself,
23  * if and wherever such third-party acknowledgments normally appear.
24  *
25  * 4. "Jcorporate" and product names such as "Expresso" must
26  * not be used to endorse or promote products derived from this
27  * software without prior written permission. For written permission,
28  * please contact info@jcorporate.com.
29  *
30  * 5. Products derived from this software may not be called "Expresso",
31  * or other Jcorporate product names; nor may "Expresso" or other
32  * Jcorporate product names appear in their name, without prior
33  * written permission of Jcorporate Ltd.
34  *
35  * 6. No product derived from this software may compete in the same
36  * market space, i.e. framework, without prior written permission
37  * of Jcorporate Ltd. For written permission, please contact
38  * partners@jcorporate.com.
39  *
40  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
41  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
42  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
43  * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
44  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
45  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
46  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
47  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
48  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
49  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
50  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51  * SUCH DAMAGE.
52  * ====================================================================
53  *
54  * This software consists of voluntary contributions made by many
55  * individuals on behalf of the Jcorporate Ltd. Contributions back
56  * to the project(s) are encouraged when you make modifications.
57  * Please send them to support@jcorporate.com. For more information
58  * on Jcorporate Ltd. and its products, please see
59  * <http://www.jcorporate.com/>.
60  *
61  * Portions of this software are based upon other open source
62  * products and are subject to their respective licenses.
63  */

64
65 package com.jcorporate.expresso.core.misc;
66
67 import com.jcorporate.expresso.kernel.util.FastStringBuffer;
68
69 import java.io.PrintWriter JavaDoc;
70 import java.io.StringWriter JavaDoc;
71 import java.math.BigDecimal JavaDoc;
72 import java.math.BigInteger JavaDoc;
73 import java.util.Hashtable JavaDoc;
74 import java.util.List JavaDoc;
75 import java.util.Random JavaDoc;
76 import java.util.StringTokenizer JavaDoc;
77 import java.util.Vector JavaDoc;
78
79
80 /**
81  * This is class that consists of static methods, utilities for
82  * manipulations of <code>java.lang.String</code>s.
83  *
84  * @author Michael Nash, Peter Pilgrim, Henri Yves AMAIZO
85  */

86 public final class StringUtil {
87     public static final String JavaDoc EMPTY_STRING = "";
88
89
90     /**
91      * Make sure a string is not null. This is a convenience method, but it
92      * is not necessarily recommended if you do a lot of processing for theMessage
93      * parameter. It is recommended that you assertNotBlank, catch IllegalArgumentException
94      * and then throw an appropriate exception with your message.
95      *
96      * @param theString Any string, possibly null
97      * @param theMessage The error message to use if the argument is not null.
98      */

99     public static final void assertNotBlank(String JavaDoc theString, String JavaDoc theMessage) {
100         if (theString == null) {
101             throw new IllegalArgumentException JavaDoc("Null argument not allowed: " +
102                     theMessage);
103         }
104         if (theString.trim().equals(EMPTY_STRING)) {
105             throw new IllegalArgumentException JavaDoc("Blank argument not allowed: " +
106                     theMessage);
107         }
108     } /* assertNotBlank(String, String) */
109
110     /**
111      * Make sure a string is not null.
112      *
113      * @param theString Any string, possibly null
114      * @return An empty string if the original was null, else the original
115      */

116     public static final String JavaDoc notNull(String JavaDoc theString) {
117         if (theString == null) {
118             return EMPTY_STRING;
119         }
120
121         return theString;
122     } /* notNull(String) */
123
124
125     /**
126      * Throws an exception if theString can't be mapped to a boolean value.
127      *
128      * @param theString the string to check
129      * @param theMessage the message to have in the IllegalArgumentException
130      * if the conditions aren't met.
131      */

132     public static final void assertBoolean(String JavaDoc theString, String JavaDoc theMessage) {
133         assertNotBlank(theString, theMessage);
134
135         if (!(theString.equalsIgnoreCase("yes") ||
136                 theString.equalsIgnoreCase("true") ||
137                 theString.equalsIgnoreCase("no") ||
138                 theString.equalsIgnoreCase("false") ||
139                 theString.equals("1") ||
140                 theString.equals("0") ||
141                 theString.equalsIgnoreCase("y") ||
142                 theString.equalsIgnoreCase("n"))) {
143             throw new IllegalArgumentException JavaDoc(theMessage);
144         }
145     }
146
147     /**
148      * parse a boolean value
149      *
150      * @param theString the string to parse
151      * @return a boolean value parse from input; if input cannot be parsed, return false
152      */

153     public static final boolean toBoolean(String JavaDoc theString) {
154         boolean result = false;
155         if (theString != null) {
156             // Rearranged with commons conditions first
157
result = theString.equalsIgnoreCase("true")
158                     || theString.equals("1")
159                     || theString.equalsIgnoreCase("yes")
160                     || theString.equalsIgnoreCase("y")
161                     || theString.equalsIgnoreCase("on")
162                     || theString.equalsIgnoreCase("set");
163         }
164
165         return result;
166     }
167
168     /**
169      * Same thing but using a serializable string as the parameter instead
170      *
171      * @param theString The string to check against null
172      * @return theString or an empty string if it is null
173      */

174     public static String JavaDoc notNull(SerializableString theString) {
175         if (theString == null) {
176             return EMPTY_STRING;
177         }
178
179         return theString.toString();
180     }
181
182     /**
183      * This method is useful for creating lists that use letters instead of
184      * numbers, such as a, b, c, d...instead of 1, 2, 3, 4.
185      * Valid numbers are from 1 to 26, corresponding to the 26 letters of the alphabet.
186      * By default, the letter is returned as a lowercase, but if the boolean
187      * upperCaseFlag is true, the letter will be returned as an uppercase.
188      * Creation date: (5/11/00 12:52:23 PM)
189      * author: Adam Rossi
190      *
191      * @param number The number to convert
192      * @param upperCaseFlag True if you want the final data to be uppercase
193      * @return java.lang.String
194      */

195     public static String JavaDoc numberToLetter(int number, boolean upperCaseFlag)
196             throws IllegalArgumentException JavaDoc {
197
198         //add nine to bring the numbers into the right range (in java, a= 10, z = 35)
199
if (number < 1 || number > 26) {
200             throw new IllegalArgumentException JavaDoc("The number is out of the proper range (1 to " +
201                     "26) to be converted to a letter.");
202         }
203
204         int modnumber = number + 9;
205         char thechar = Character.forDigit(modnumber, 36);
206
207         if (upperCaseFlag) {
208             thechar = Character.toUpperCase(thechar);
209         }
210
211         return "" + thechar;
212     } /* numberToLetter(int, boolean) */
213
214
215     /**
216      * replace substrings within string.
217      *
218      * @param s The string to work with
219      * @param sub The string to substitude the occurances of
220      * @param with The string to replace with
221      * @return A processed java.util.String
222      */

223     public static String JavaDoc replace(String JavaDoc s, String JavaDoc sub, String JavaDoc with) {
224         if (s == null) {
225             return null;
226         }
227         int c = 0;
228         int i = s.indexOf(sub, c);
229
230         if (i == -1) {
231             return s;
232         }
233
234         FastStringBuffer buf = new FastStringBuffer(s.length() + with.length());
235
236         do {
237             buf.append(s.substring(c, i));
238             buf.append(with);
239             c = i + sub.length();
240         } while ((i = s.indexOf(sub, c)) != -1);
241
242         if (c < s.length()) {
243             buf.append(s.substring(c, s.length()));
244         }
245
246         return buf.toString();
247     } /* replace(String, String, String) */
248
249     /**
250      * Formats the string to an XML/XHTML escaped character. Useful for &'s, etc
251      *
252      * @param s the String to format
253      * @return The escaped formatted String.
254      * @see org.apache.xml.serialize.BaseMarkupSerializer for example of original
255      * code.
256      */

257     public static String JavaDoc xmlEscape(String JavaDoc s) {
258         int length = s.length();
259         FastStringBuffer fsb = new FastStringBuffer(length);
260
261         for (int i = 0; i < length; i++) {
262             fsb = printEscaped(s.charAt(i), fsb);
263         }
264
265         return fsb.toString();
266     }
267
268     /**
269      * Formats a particular character to something workable in xml Helper to xmlEscape()
270      *
271      * @param ch the character to print.
272      * @param fsb The FastStringBuffer to add this to.
273      * @return a FastStringBuffer that is modified
274      */

275     protected static FastStringBuffer printEscaped(char ch,
276                                                    FastStringBuffer fsb) {
277         String JavaDoc charRef;
278
279         // If there is a suitable entity reference for this
280
// character, print it. The list of available entity
281
// references is almost but not identical between
282
// XML and HTML.
283
charRef = getEntityRef(ch);
284
285         if (charRef != null) {
286             fsb.append('&');
287             fsb.append(charRef);
288             fsb.append(';');
289
290             //ch<0xFF == isPrintable()
291
} else if ((ch >= ' ' && ch < 0xFF && ch != 0xF7) || ch == '\n' ||
292                 ch == '\r' || ch == '\t') {
293
294             // If the character is not printable, print as character reference.
295
// Non printables are below ASCII space but not tab or line
296
// terminator, ASCII delete, or above a certain Unicode threshold.
297
if (ch < 0x10000) {
298                 fsb.append(ch);
299             } else {
300                 fsb.append((char) ((((int) ch - 0x10000) >> 10) + 0xd800));
301                 fsb.append((char) ((((int) ch - 0x10000) & 0x3ff) + 0xdc00));
302             }
303         } else {
304             fsb.append("&#x");
305             fsb.append(Integer.toHexString(ch));
306             fsb.append(';');
307         }
308
309         return fsb;
310     }
311
312     /**
313      * Helper to xmlEscape()
314      *
315      * @param ch the character to escape
316      * @return A modified string representing the tanlation of the character
317      * or null if there is no translation for it.
318      */

319     protected static String JavaDoc getEntityRef(int ch) {
320
321         // Encode special XML characters into the equivalent character references.
322
// These five are defined by default for all XML documents.
323
switch (ch) {
324             case '<':
325                 return "lt";
326
327             case '>':
328                 return "gt";
329
330             case '"':
331                 return "quot";
332
333             case '\'':
334                 return "apos";
335
336             case '&':
337                 return "amp";
338         }
339
340         return null;
341     }
342
343     /**
344      * HTML code for ellipses (3 dots, like '...' as one character)
345      * used for appending to a truncate() line if necessary
346      */

347     public static final String JavaDoc ELLIPSES = "&#133";
348
349     /**
350      * truncate a string at the given length if necessary,
351      * adding an ellipses at the end if truncation occurred;
352      * uses ELLIPSES static String from this class
353      *
354      * @param str The string to process
355      * @param len The maximum length to process the string to.
356      * @return the appropriately trimmed string.
357      */

358     public static String JavaDoc truncate(String JavaDoc str, int len) {
359         String JavaDoc result = str;
360         if (str.length() > len) {
361             result = str.substring(0, len) + ELLIPSES;
362         }
363         return result;
364     }
365
366
367     /**
368      * Map accent characters with equivalent without accent.
369      * <p/>
370      * author Henri Yves AMAIZO
371      *
372      * @return Hashtable Character mapping table.
373      */

374     public static Hashtable JavaDoc characterMap() {
375         Hashtable JavaDoc characterMap = new Hashtable JavaDoc();
376
377         characterMap.put(new Character JavaDoc('à'), new Character JavaDoc('a'));
378         characterMap.put(new Character JavaDoc('â'), new Character JavaDoc('a'));
379         characterMap.put(new Character JavaDoc('ä'), new Character JavaDoc('a'));
380         characterMap.put(new Character JavaDoc('á'), new Character JavaDoc('a'));
381         characterMap.put(new Character JavaDoc('À'), new Character JavaDoc('A'));
382         characterMap.put(new Character JavaDoc('Á'), new Character JavaDoc('A'));
383         characterMap.put(new Character JavaDoc('Â'), new Character JavaDoc('A'));
384         characterMap.put(new Character JavaDoc('Ä'), new Character JavaDoc('A'));
385         characterMap.put(new Character JavaDoc('è'), new Character JavaDoc('e'));
386         characterMap.put(new Character JavaDoc('é'), new Character JavaDoc('e'));
387         characterMap.put(new Character JavaDoc('ê'), new Character JavaDoc('e'));
388         characterMap.put(new Character JavaDoc('ë'), new Character JavaDoc('e'));
389         characterMap.put(new Character JavaDoc('È'), new Character JavaDoc('E'));
390         characterMap.put(new Character JavaDoc('É'), new Character JavaDoc('E'));
391         characterMap.put(new Character JavaDoc('Ê'), new Character JavaDoc('E'));
392         characterMap.put(new Character JavaDoc('Ë'), new Character JavaDoc('E'));
393         characterMap.put(new Character JavaDoc('î'), new Character JavaDoc('i'));
394         characterMap.put(new Character JavaDoc('ï'), new Character JavaDoc('i'));
395         characterMap.put(new Character JavaDoc('Î'), new Character JavaDoc('I'));
396         characterMap.put(new Character JavaDoc('Ï'), new Character JavaDoc('I'));
397         characterMap.put(new Character JavaDoc('ô'), new Character JavaDoc('o'));
398         characterMap.put(new Character JavaDoc('ö'), new Character JavaDoc('o'));
399         characterMap.put(new Character JavaDoc('Ô'), new Character JavaDoc('O'));
400         characterMap.put(new Character JavaDoc('Ö'), new Character JavaDoc('O'));
401         characterMap.put(new Character JavaDoc('û'), new Character JavaDoc('u'));
402         characterMap.put(new Character JavaDoc('ü'), new Character JavaDoc('u'));
403         characterMap.put(new Character JavaDoc('Û'), new Character JavaDoc('U'));
404         characterMap.put(new Character JavaDoc('Ü'), new Character JavaDoc('U'));
405         characterMap.put(new Character JavaDoc('ç'), new Character JavaDoc('c'));
406         characterMap.put(new Character JavaDoc('Ç'), new Character JavaDoc('C'));
407
408         return characterMap;
409     }
410
411     /**
412      * Remove from the parameter the accent characters and
413      * return the remain string or null if empty
414      * <p/>
415      * author Henri Yves AMAIZO
416      *
417      * @param s the string to remove the accent characters
418      * @return String
419      */

420     public static String JavaDoc removeAccents(String JavaDoc s) {
421         String JavaDoc out = null;
422         if (s != null) {
423             Hashtable JavaDoc charRemove = characterMap();
424             StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
425             for (int i = 0; i < s.length(); i++) {
426                 Character JavaDoc c = new Character JavaDoc(s.charAt(i));
427                 if (charRemove.containsKey(c)) {
428                     c = (Character JavaDoc) charRemove.get(c);
429                 }
430                 sb.append(c.charValue());
431             }
432             out = sb.toString();
433         }
434         return out;
435     }
436
437
438     /**
439      * Replace all comma by dot
440      * <p/>
441      * author Henri Yves AMAIZO
442      *
443      * @param str String to change
444      * @return String The result of substitution
445      */

446     public static String JavaDoc convertCommaToDot(String JavaDoc str) {
447         if (str == null) {
448             return null;
449         }
450
451         return str.replace(',', '.');
452     }
453
454     /**
455      * Compare 2 decimals string
456      * <p/>
457      * author Henri Yves AMAIZO
458      *
459      * @param decim1 First string to compare
460      * @param decim2 Second string to compare
461      * @return int return 1 if decim1 > decim2<BR> retourne 0 if decim1 == decim2<BR> return -1 if decim1 < decim2
462      */

463     public static int compareDecimals(String JavaDoc decim1, String JavaDoc decim2) {
464         BigDecimal JavaDoc dec1 = new BigDecimal JavaDoc(decim1);
465         BigDecimal JavaDoc dec2 = new BigDecimal JavaDoc(decim2);
466         return dec1.compareTo(dec2);
467     }
468
469     /**
470      * Compare 2 integers string.
471      * <p/>
472      * author Henri Yves AMAIZO
473      *
474      * @param int1 first string to compare
475      * @param int2 second string to compare
476      * @return int return 1 if decim1 > decim2<BR> return 0 if decim1 == decim2<BR> return -1 if decim1 < decim2
477      */

478     public static int compareIntegers(String JavaDoc int1, String JavaDoc int2) {
479         BigInteger JavaDoc dec1 = new BigInteger JavaDoc(int1);
480         BigInteger JavaDoc dec2 = new BigInteger JavaDoc(int2);
481         return dec1.compareTo(dec2);
482     }
483
484     /**
485      * Check if string is alphanumeric or not.
486      * <p/>
487      * author Henri Yves AMAIZO
488      *
489      * @param s String to check.
490      * @return boolean true if alphanumeric, false if not.
491      */

492     public static boolean isAlphaNumeric(String JavaDoc s) {
493         return isAlphaNumeric(s, "");
494     }
495
496     /**
497      * Check if string is alphanumeric with addons chararcters or not.
498      * <p/>
499      * author Henri Yves AMAIZO
500      *
501      * @param str string to check
502      * @param otherChars extra characters to check with
503      * @return boolean true if parameter string contains only alpha numerics,<BR> plus addons characters and false if not.
504      */

505     public static boolean isAlphaNumeric(String JavaDoc str, String JavaDoc otherChars) {
506         String JavaDoc alphaNum =
507                 "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" + otherChars;
508         for (int i = 0; i < str.length(); i++) {
509             if (alphaNum.indexOf(str.charAt(i)) == -1) {
510                 return false;
511             }
512         }
513         return true;
514     }
515
516     /**
517      * Check if an input string is an empty string, just contains
518      * whitespace characters, or is <code>null</code>. If it is then
519      * return <code>true</code>
520      *
521      * @param str the input string
522      * @return boolean true if the string is blank or null
523      */

524     public static boolean isBlankOrNull(String JavaDoc str) {
525         if (str == null) {
526             return true;
527         }
528         if (str.trim().length() < 1) {
529             return true;
530         } else {
531             return false;
532         }
533     }
534
535     /**
536      * Check if decimal number
537      * <p/>
538      * author Henri Yves AMAIZO
539      *
540      * @param s string to check.
541      * @return boolean true if the value is decimal number false if not
542      */

543     public static boolean isDecimal(String JavaDoc s) {
544         try {
545             new BigDecimal JavaDoc(s);
546             return true;
547         } catch (NumberFormatException JavaDoc e) {
548             return false;
549         }
550     }
551
552     /**
553      * Check if string pass is a vlaid email address
554      * <p/>
555      * author Henri Yves AMAIZO
556      *
557      * @param email string to check
558      * @return int 0 if valid address, 1 more than 2 tokens (".", "@")<BR> and 2 if the second token is not "." .
559      */

560     public static int isEmail(String JavaDoc email) {
561         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc(email, "@");
562
563         if (st.countTokens() != 2) {
564             return 1;
565         }
566
567         st.nextToken();
568         if (st.nextToken().indexOf(".") == -1) {
569             return 2;
570         }
571
572         return 0;
573     }
574
575     /**
576      * Check if integer string
577      * <p/>
578      * author Henri Yves AMAIZO
579      *
580      * @param str string to check
581      * @return boolean true if all characters is digit
582      */

583     public static boolean isInteger(String JavaDoc str) {
584         try {
585             new BigInteger JavaDoc(str);
586             return true;
587         } catch (NumberFormatException JavaDoc e) {
588             return false;
589         }
590     }
591
592     /**
593      * Check if number
594      * author Henri Yves AMAIZO
595      *
596      * @param str to check
597      * @return boolean
598      */

599     public static boolean isNumber(String JavaDoc str) {
600         try {
601             Double.parseDouble(str);
602             return true;
603         } catch (NumberFormatException JavaDoc ex) {
604             return false;
605         }
606     }
607
608     /**
609      * Check French company siren number.
610      * <p/>
611      * author Henri Yves AMAIZO
612      *
613      * @param siren the company number
614      * @return boolean true if ok.
615      */

616     public static boolean isSiren(String JavaDoc siren) {
617         StringBuffer JavaDoc temp = new StringBuffer JavaDoc("");
618         int value = 0;
619
620         // Check if numeric digit.
621
try {
622             Double.parseDouble(siren);
623         } catch (NumberFormatException JavaDoc nbe) {
624             return false;
625         }
626
627         // string length must be 9
628
if (siren.length() != 9) {
629             return false;
630         }
631
632         //
633
for (int i = 0; i < 9; i++) {
634             int n =
635                     Integer.parseInt(siren.substring(i, i + 1)) * (((i % 2) != 0) ? 2 : 1);
636             temp.append(n);
637         }
638
639         // sum of all digits
640
for (int i = 0; i < (temp.length()); i++) {
641             value += Integer.parseInt(temp.substring(i, i + 1));
642         }
643
644         //value must divide by 10
645
if ((value % 10) != 0) {
646             return false;
647         }
648
649         return true;
650     }
651
652     /**
653      * Check French company siret number
654      * <p/>
655      * author Henri Yves AMAIZO
656      *
657      * @param siret The siret number
658      * @return boolean true if equivalent to siret number false if not.
659      */

660     public static boolean isSiret(String JavaDoc siret) {
661         // Check the length
662
if (siret.length() != 14) {
663             return false;
664         }
665
666         //
667
try {
668             Double.parseDouble(siret);
669             return isSiren(siret.substring(0, 9));
670         } catch (NumberFormatException JavaDoc nfe) {
671             return false;
672         }
673     }
674
675     /**
676      * Return empty string if parameter is null
677      * <p/>
678      * author Henri Yves AMAIZO
679      *
680      * @param s the parameter to check
681      * @return String return the parameter if empty or if the string == null
682      */

683     public static String JavaDoc nullToEmpty(String JavaDoc s) {
684         if (s == null) {
685             return "";
686         } else {
687             return s;
688         }
689     }
690
691     /**
692      * Reformat string by converting "," by "."
693      * <p/>
694      * author Henri Yves AMAIZO
695      *
696      * @param str string to reformat
697      * @return String return reformatted string.
698      */

699     public static String JavaDoc reformatDecimalString(String JavaDoc str) {
700         if (str == null) {
701             return null;
702         }
703
704         // replace all ',' by '.'
705
str = str.replace(',', '.');
706         try {
707             Double.parseDouble(str);
708             return str;
709         } catch (NumberFormatException JavaDoc nbe) {
710             return "";
711         }
712     }
713
714     /**
715      * Replace all dots byt comma
716      * <p/>
717      * author Henri Yves AMAIZO
718      *
719      * @param str string to change
720      * @return String reformatted
721      */

722     public static String JavaDoc convertDotToComma(String JavaDoc str) {
723         return str.replace('.', ',');
724     }
725
726     /**
727      * Replace all occurences of key by value in text.
728      * <p/>
729      * author Henri Yves AMAIZO
730      *
731      * @param text string in
732      * @param key occurence to replace
733      * @param value string to use
734      * @return String with the replace value
735      */

736     public static String JavaDoc replaceAll(String JavaDoc text, String JavaDoc key, String JavaDoc value) {
737         if (text == null) {
738             return null;
739         }
740
741         String JavaDoc buffer = text;
742         if (buffer != null && key != null && value != null) {
743             int length = key.length();
744             for (int start = buffer.indexOf(key);
745                  start != -1;
746                  start = buffer.indexOf(key, start + value.length())) {
747                 buffer = buffer.substring(0, start) + value + buffer.substring(start + length);
748             }
749         }
750         return buffer;
751     }
752
753     /**
754      * Substituate once str1 by str2 in text
755      * Commentaire Anglais
756      * <p/>
757      * author Henri Yves AMAIZO
758      *
759      * @param text search and replace in
760      * @param str1 to search for
761      * @param str2 to replace with
762      * @return String replaced
763      */

764     static public String JavaDoc replaceStringOnce(String JavaDoc text, String JavaDoc str1, String JavaDoc str2) {
765         return replaceString(text, str1, str2, 1);
766     }
767
768     /**
769      * Substituate all occurence of str1 by str2 in text
770      * <p/>
771      * author Henri Yves AMAIZO
772      *
773      * @param text search and replace in
774      * @param str1 search for
775      * @param str2 replace with
776      * @return String with all values replaced
777      */

778     static public String JavaDoc replaceString(String JavaDoc text, String JavaDoc str1, String JavaDoc str2) {
779         return replaceString(text, str1, str2, -1);
780     }
781
782     /**
783      * Replace n occurences of str1 in text by str2.
784      * if n = -1 all occurrences are replaced
785      * <p/>
786      * author Henri Yves AMAIZO
787      *
788      * @param text search and replace in
789      * @param str1 search for
790      * @param str2 replace with
791      * @param max int values of occrrences to replace
792      * @return String replaced
793      */

794     static public String JavaDoc replaceString(String JavaDoc text, String JavaDoc str1, String JavaDoc str2, int max) {
795         if (text == null) {
796             return null;
797         }
798
799         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc(text.length());
800         int start = 0;
801         int end = 0;
802         while ((end = text.indexOf(str1, start)) != -1) {
803             buffer.append(text.substring(start, end)).append(str2);
804             start = end + str1.length();
805             if (--max == 0) {
806                 break;
807             }
808         }
809         buffer.append(text.substring(start));
810         return buffer.toString();
811     }
812
813     /**
814      * Convert string to list
815      * <p/>
816      * author Henri Yves AMAIZO
817      *
818      * @param s String comma delimited string to format
819      * @return List
820      */

821     public static List JavaDoc string2List(String JavaDoc s) {
822         return string2List(s, ",");
823     }
824
825     /**
826      * Convert string to list using sep separator to divide
827      * <p/>
828      * author Henri Yves AMAIZO
829      *
830      * @param s String comma delimited string to format
831      * @param sep a string containing the seprator characters
832      * @return List
833      */

834     public static List JavaDoc string2List(String JavaDoc s, String JavaDoc sep) {
835         return string2List(s, sep, s != null ? s.length() : Integer.MAX_VALUE);
836     }
837
838     /**
839      * Convert string to list using sep separator to divide
840      * <p/>
841      * author Henri Yves AMAIZO
842      *
843      * @param s String comma delimited string to format
844      * @param sep a string containing the seprator characters
845      * @param maxSize the maximum size of the list
846      * @return List
847      */

848     public static List JavaDoc string2List(String JavaDoc s, String JavaDoc sep, int maxSize) {
849         List JavaDoc l = null;
850         if (s != null) {
851             l = new Vector JavaDoc();
852             for (int i = 0; i < maxSize;) {
853                 int index = s.indexOf(sep, i);
854                 String JavaDoc token;
855                 if (index != -1) {
856                     token = s.substring(i, index);
857                 } else {
858                     token = s.substring(i);
859                 }
860                 if (token.length() > 0 && !token.equals(sep)) {
861                     l.add(token.trim());
862                 }
863                 i += token.length() + sep.length();
864             }
865         }
866         return l;
867     }
868
869     /**
870      * convert the first character of string in lower case
871      * <p/>
872      * author Henri Yves AMAIZO
873      *
874      * @param str String to un-upper case the first character
875      * @return String
876      */

877     static public String JavaDoc unUpperFirstChar(String JavaDoc str) {
878         if (str == null) {
879             return null;
880         }
881
882         FastStringBuffer fsb = null;
883         ;
884         try {
885             fsb = FastStringBuffer.getInstance();
886             fsb.append(Character.toLowerCase(str.charAt(0)));
887             fsb.append(str.substring(1));
888             return fsb.toString();
889         } finally {
890             if (fsb != null) {
891                 fsb.release();
892             }
893         }
894     }
895
896     /**
897      * convert the first character of the string upper case
898      * <p/>
899      * author Henri Yves AMAIZO
900      *
901      * @param str String to make the first character upper.
902      * @return String
903      */

904     static public String JavaDoc upperFirstChar(String JavaDoc str) {
905         if (str == null) {
906             return null;
907         }
908
909         FastStringBuffer fsb = FastStringBuffer.getInstance();
910         try {
911             fsb.append(Character.toTitleCase(str.charAt(0)));
912             fsb.append(str.substring(1));
913             return fsb.toString();
914         } finally {
915             fsb.release();
916         }
917
918         // return "" + Character.toTitleCase(str.charAt(0)) + str.substring(1);
919
}
920
921     /**
922      * Repeat str n time to format another string.
923      * <p/>
924      * author Henri Yves AMAIZO
925      *
926      * @param str String to repeat
927      * @param n int n repeat
928      * @return String
929      */

930     static public String JavaDoc repeatString(String JavaDoc str, int n) {
931         if (str == null) {
932             return null;
933         }
934
935         FastStringBuffer buffer = FastStringBuffer.getInstance();
936         try {
937             //FastStringBuffer is preallocated for 1K, so we may not
938
//need to do any memory allocation here.
939
int val = n * str.length();
940             if (val > buffer.capacity()) {
941                 buffer.ensureCapacity(val);
942             }
943             // StringBuffer buffer = new StringBuffer(n * str.length());
944
for (int i = 0; i < n; i++) {
945                 buffer.append(str);
946             }
947             return buffer.toString();
948         } finally {
949             buffer.release();
950         }
951     }
952
953     /**
954      * enclosed the string with padding character.
955      * Space is padding character
956      * <p/>
957      * author Henri Yves AMAIZO
958      *
959      * @param str String str string to center padding
960      * @param n int n size of the new string
961      * @return String Result
962      */

963     static public String JavaDoc centerPad(String JavaDoc str, int n) {
964         return centerPad(str, n, " ");
965     }
966
967     /**
968      * Enclosed the string with padding character
969      * <p/>
970      * author Henri Yves AMAIZO
971      *
972      * @param str String str string to pad with
973      * @param n int n size of the final string
974      * @param delim String delim padding character
975      * @return String result of the center padding
976      */

977     static public String JavaDoc centerPad(String JavaDoc str, int n, String JavaDoc delim) {
978         if (str == null) {
979             return null;
980         }
981
982         int sz = str.length();
983         int p = n - sz;
984         if (p < 1) {
985             return str;
986         }
987         str = leftPad(str, sz + p / 2, delim);
988         str = rightPad(str, n, delim);
989         return str;
990     }
991
992     /**
993      * Right padding with delimiter
994      * <p/>
995      * author Henri Yves AMAIZO
996      *
997      * @param str String
998      * @param n int size of the final string
999      * @param delim padding character
1000     * @return String padding string
1001     */

1002    static public String JavaDoc rightPad(String JavaDoc str, int n, String JavaDoc delim) {
1003        if (str == null) {
1004            return null;
1005        }
1006
1007        int sz = str.length();
1008        n = (n - sz) / delim.length();
1009        if (n > 0) {
1010            str += repeatString(delim, n);
1011        }
1012        return str;
1013    }
1014
1015    /**
1016     * Right padding
1017     * delimiter is space
1018     * <p/>
1019     * author Henri Yves AMAIZO
1020     *
1021     * @param str String
1022     * @param n int size of the new string
1023     * @return String
1024     */

1025    static public String JavaDoc rightPad(String JavaDoc str, int n) {
1026        return rightPad(str, n, " ");
1027    }
1028
1029    /**
1030     * Left padding
1031     * padding character is space
1032     * <p/>
1033     * author Henri Yves AMAIZO
1034     *
1035     * @param str String
1036     * @param n int size of the new string
1037     * @return String
1038     */

1039    static public String JavaDoc leftPad(String JavaDoc str, int n) {
1040        return leftPad(str, n, " ");
1041    }
1042
1043    /**
1044     * Left padding
1045     * <p/>
1046     * author Henri Yves AMAIZO
1047     *
1048     * @param str String
1049     * @param n int size of the new string
1050     * @param delim padding character
1051     * @return String result
1052     */

1053    static public String JavaDoc leftPad(String JavaDoc str, int n, String JavaDoc delim) {
1054        if (str == null) {
1055            return null;
1056        }
1057        int sz = str.length();
1058        n = (n - sz) / delim.length();
1059        if (n > 0) {
1060            str = repeatString(delim, n) + str;
1061        }
1062        return str;
1063    }
1064
1065    /**
1066     * Reverse the String.
1067     *
1068     * @param str the String to reverse.
1069     * @return a reversed string
1070     */

1071    static public String JavaDoc reverseString(String JavaDoc str) {
1072        if (str == null) {
1073            return null;
1074        }
1075        FastStringBuffer fsb = FastStringBuffer.getInstance();
1076        try {
1077            fsb.append(str);
1078            return fsb.reverse().toString();
1079        } finally {
1080            fsb.release();
1081        }
1082    }
1083
1084    /**
1085     * Reverse the character case in the string
1086     * <p/>
1087     * author Henri Yves AMAIZO
1088     *
1089     * @param str String
1090     * @return String
1091     */

1092    static public String JavaDoc swapCase(String JavaDoc str) {
1093        if (str == null) {
1094            return null;
1095        }
1096
1097        int sz = str.length();
1098        FastStringBuffer buffer = FastStringBuffer.getInstance();
1099        // StringBuffer buffer = new StringBuffer(sz);
1100
try {
1101            if (sz > buffer.capacity()) {
1102                buffer.ensureCapacity(sz);
1103            }
1104            boolean whiteSpace = false;
1105            char ch = 0;
1106            char tmp = 0;
1107            for (int i = 0; i < sz; i++) {
1108                ch = str.charAt(i);
1109                if (Character.isUpperCase(ch)) {
1110                    tmp = Character.toLowerCase(ch);
1111                } else if (Character.isTitleCase(ch)) {
1112                    tmp = Character.toLowerCase(ch);
1113                } else if (Character.isLowerCase(ch)) {
1114                    if (whiteSpace) {
1115                        tmp = Character.toTitleCase(ch);
1116                    } else {
1117                        tmp = Character.toUpperCase(ch);
1118                    }
1119                }
1120                buffer.append(tmp);
1121                whiteSpace = Character.isWhitespace(ch);
1122            }
1123            return buffer.toString();
1124        } finally {
1125            buffer.release();
1126        }
1127    }
1128
1129    /**
1130     * Create a random string
1131     * author Henri Yves AMAIZO
1132     *
1133     * @param count size of string.
1134     * @return randomly generated string of size count
1135     */

1136    static public String JavaDoc random(int count) {
1137        return random(count, false, false);
1138    }
1139
1140    /**
1141     * Create a random Ascii String
1142     * author Henri Yves AMAIZO
1143     *
1144     * @param count the size of the string
1145     * @return randomly generated string of size count
1146     */

1147    static public String JavaDoc randomAscii(int count) {
1148        return random(count, 32, 127, false, false);
1149    }
1150
1151    /**
1152     * Create a random character only string
1153     * author Henri Yves AMAIZO
1154     *
1155     * @param count size of string
1156     * @return randomly generated string of size count
1157     */

1158    static public String JavaDoc randomAlphabetic(int count) {
1159        return random(count, true, false);
1160    }
1161
1162    /**
1163     * Create a random alpha numeric string
1164     * author Henri Yves AMAIZO
1165     *
1166     * @param count the size of the string
1167     * @return randomly generated string of size count
1168     */

1169    static public String JavaDoc randomAlphanumeric(int count) {
1170        return random(count, true, true);
1171    }
1172
1173    /**
1174     * Create a random numeric string
1175     * author Henri Yves AMAIZO
1176     *
1177     * @param count the size of the final string
1178     * @return randomly generated string of size count
1179     */

1180    static public String JavaDoc randomNumeric(int count) {
1181        return random(count, false, true);
1182    }
1183
1184    /**
1185     * Create a random numeric string where you have control over size, and
1186     * whether you want letters, numbers, or both.
1187     * <p/>
1188     * author Henri Yves AMAIZO
1189     *
1190     * @param count the size of the string
1191     * @param letters true if you want letters included
1192     * @param numbers true if you want numbers included
1193     * @return randomly generated string of size count
1194     */

1195    static public String JavaDoc random(int count, boolean letters, boolean numbers) {
1196        return random(count, 0, 0, letters, numbers);
1197    }
1198
1199    /**
1200     * Create a random numeric string where you have control over size, and
1201     * whether you want letters, numbers, as well as ANSI minimum and maximum values
1202     * of the characters.
1203     * author Henri Yves AMAIZO
1204     *
1205     * @param count the size of the string
1206     * @param start int minimum 'value' of the character
1207     * @param end maximum 'value' of the character
1208     * @param letters true if you want letters included
1209     * @param numbers true if you want numbers included
1210     * @return randomly generated string of size count
1211     */

1212    static public String JavaDoc random(int count, int start, int end, boolean letters, boolean numbers) {
1213        return random(count, start, end, letters, numbers, null);
1214    }
1215
1216    /**
1217     * Create a random numeric string where you have control over size, and
1218     * whether you want letters, numbers, as well as ANSI minimum and maximum values
1219     * of the characters.
1220     * author Henri Yves AMAIZO
1221     *
1222     * @param count the size of the string
1223     * @param start int minimum 'value' of the character
1224     * @param end maximum 'value' of the character
1225     * @param letters true if you want letters included
1226     * @param numbers true if you want numbers included
1227     * @param set the set of possible characters that you're willing to let
1228     * the string contain. may be null if all values are open.
1229     * @return randomly generated string of size count
1230     * @todo make this cryptographically string
1231     */

1232    static public String JavaDoc random(int count, int start, int end, boolean letters, boolean numbers, char[] set) {
1233        if ((start == 0) && (end == 0)) {
1234            end = (int) 'z';
1235            start = (int) ' ';
1236            if (!letters && !numbers) {
1237                start = 0;
1238                end = Integer.MAX_VALUE;
1239            }
1240        }
1241        Random JavaDoc rnd = new Random JavaDoc();
1242        // StringBuffer buffer = new StringBuffer();
1243
FastStringBuffer buffer = FastStringBuffer.getInstance();
1244        try {
1245            int gap = end - start;
1246            while (count-- != 0) {
1247                char ch;
1248                if (set == null) {
1249                    ch = (char) (rnd.nextInt(gap) + start);
1250                } else {
1251                    ch = set[rnd.nextInt(gap) + start];
1252                }
1253                if ((letters && numbers && Character.isLetterOrDigit(ch))
1254                        || (letters && Character.isLetter(ch))
1255                        || (numbers && Character.isDigit(ch))
1256                        || (!letters && !numbers)) {
1257                    buffer.append(ch);
1258                } else {
1259                    count++;
1260                }
1261            }
1262            return buffer.toString();
1263        } finally {
1264            buffer.release();
1265        }
1266    }
1267
1268    /**
1269     * Create a random string
1270     * author Henri Yves AMAIZO
1271     *
1272     * @param count the size of the string
1273     * @param set the set of characters that are allowed
1274     * @return randomly generated string of size count
1275     */

1276    static public String JavaDoc random(int count, String JavaDoc set) {
1277        return random(count, set.toCharArray());
1278    }
1279
1280    /**
1281     * Create a random string
1282     * author Henri Yves AMAIZO
1283     *
1284     * @param count the size of the string
1285     * @param set the set of characters that are allowed
1286     * @return randomly generated string of size count
1287     */

1288    static public String JavaDoc random(int count, char[] set) {
1289        return random(count, 0, set.length - 1, false, false, set);
1290    }
1291
1292    /**
1293     * return empty string the string is null
1294     * <p/>
1295     * author Henri Yves AMAIZO
1296     *
1297     * @param str The string to split String
1298     * @param lg the length to subgstring
1299     * @return a substring of parameter str.
1300     */

1301    public static String JavaDoc substring(String JavaDoc str, int lg) {
1302        return substring(str, 0, lg);
1303    }
1304
1305    /**
1306     * return empty string the string is null
1307     * <p/>
1308     * author Henri Yves AMAIZO
1309     *
1310     * @param str The string to split String
1311     * @param start the location to start
1312     * @param end the end location of the substring
1313     * @return a substring of parameter str.
1314     */

1315    public static String JavaDoc substring(String JavaDoc str, int start, int end) {
1316        if (str == null || str.length() <= start) {
1317            return null;
1318        } else if (str.length() >= end) {
1319            return str.substring(start, end);
1320        } else {
1321            return str.substring(start);
1322        }
1323    }
1324
1325    /**
1326     * utility to get just name of class
1327     *
1328     * @param obj the object of the given class, the name of which will be returned
1329     * @return name of class, less any package prefix
1330     */

1331    public static String JavaDoc omitPackages(Object JavaDoc obj) {
1332        int i = obj.getClass().getPackage().getName().length();
1333        if (i > 0) {
1334            i++;
1335        }
1336        return obj.getClass().getName().substring(i);
1337    }
1338
1339    /**
1340     * utility to get just name of class
1341     *
1342     * @param theclass the given class, the name of which will be returned
1343     * @return name of class, less any package prefix
1344     */

1345    public static String JavaDoc omitPackages(Class JavaDoc theclass) {
1346        int i = theclass.getPackage().getName().length();
1347        if (i > 0) {
1348            i++;
1349        }
1350        return theclass.getName().substring(i);
1351    }
1352
1353
1354    /**
1355     * A utility method to return an exception stacktrace as a String
1356     * <p/>
1357     * <p><small>Written by Peter Pilgrim Mon Mar 15 23:12:15 GMT 2004</small></p>
1358     */

1359    public static String JavaDoc getStackTraceAsString(Throwable JavaDoc t) {
1360        StringWriter JavaDoc swriter = new StringWriter JavaDoc();
1361        PrintWriter JavaDoc pwriter = new PrintWriter JavaDoc(swriter);
1362        t.printStackTrace(pwriter);
1363        pwriter.flush();
1364        return swriter.toString();
1365    }
1366
1367    /**
1368     * Concatenate array of string into one string with constant delimiter <code>", "</code>
1369     * <p/>
1370     * <p><small>Written by Peter Pilgrim Mon Mar 15 23:12:15 GMT 2004</small></p>
1371     *
1372     * @param input the input array string
1373     * @return the joined string
1374     */

1375    public static String JavaDoc join(String JavaDoc[] input) {
1376        return join(input, ", ");
1377    }
1378
1379    /**
1380     * Concatenate array of string into one string with delimiter
1381     * <p/>
1382     * <p><small>Written by Peter Pilgrim Mon Mar 15 23:12:15 GMT 2004</small></p>
1383     *
1384     * @param input the input array string
1385     * @param delimiter the delimiter
1386     * @return the joined string
1387     */

1388    public static String JavaDoc join(String JavaDoc[] input, String JavaDoc delimiter) {
1389        if (input == null) {
1390            return "";
1391        }
1392
1393        StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
1394        for (int q = 0; q < input.length; ++q) {
1395            if (q > 0) {
1396                buf.append(delimiter);
1397            }
1398
1399            buf.append(input[q]);
1400        }
1401
1402        return buf.toString();
1403    }
1404
1405
1406    /**
1407     * Take an input string S, break the string into parts of N up to
1408     * 72 characters long which word wrapped with respective to blank
1409     * space characters and separated with the newline
1410     * characters. This static call has parameters set up for
1411     * electronic mail standards.
1412     * <p/>
1413     * <p><small>Written by Peter Pilgrim Mon Mar 15 23:12:15 GMT 2004</small></p>
1414     *
1415     * @param input the input string
1416     * @return wrapped broken string
1417     * @see #createWordWrappedString( String input, int fixedLength, String delimiter )
1418     */

1419    public static String JavaDoc createWordWrappedString(String JavaDoc input) {
1420        return createWordWrappedString(input, 72, "\n");
1421    }
1422
1423    /**
1424     * Take an input string S, break the string into parts of N up to
1425     * F characters long which word wrapped with respective to blank
1426     * space characters and separated with the supplied delimiter D.
1427     * <p/>
1428     * <p><small>Written by Peter Pilgrim Mon Mar 15 23:12:15 GMT 2004</small></p>
1429     *
1430     * @param input the input string
1431     * @param fixedLength the maximum fixed length
1432     * @param delimiter the delimiter
1433     * @return wrapped broken string
1434     */

1435    public static String JavaDoc createWordWrappedString(String JavaDoc input, int fixedLength, String JavaDoc delimiter) {
1436        int inputLength = input.length();
1437        char c;
1438
1439        // Case #1 Initial string is smaller than the fixed length
1440
if (inputLength < fixedLength) {
1441            return input;
1442        }
1443
1444        // Case #2 Word wrapping is required
1445
StringBuffer JavaDoc buf = new StringBuffer JavaDoc(1024);
1446        int pos = 0; // current cursor position
1447
int lineLength = 0; // the line length
1448
while (pos < inputLength) {
1449            // System.out.println( "start:"+start+" end:"+end+" buf:["+buf.toString()+"]" );
1450

1451            // Read the white space
1452
c = input.charAt(pos);
1453            while (pos < inputLength && Character.isWhitespace(c)) {
1454                buf.append(c);
1455                if (c == '\t')
1456                // If current character is a tab increase the line length
1457
{
1458                    lineLength += 8;
1459                } else if (c == '\n')
1460                // If current character is a new line, reset the line length
1461
{
1462                    lineLength = 0;
1463                } else
1464// Increase line space by one
1465
{
1466                    ++lineLength;
1467                }
1468
1469                ++pos; /*1*/
1470                if (pos < inputLength) {
1471                    c = input.charAt(pos); /*2*/
1472                }
1473            }
1474
1475            // Read the word
1476
StringBuffer JavaDoc word = new StringBuffer JavaDoc(64);
1477            if (pos < inputLength) {
1478                c = input.charAt(pos);
1479            }
1480            while (pos < inputLength && !Character.isWhitespace(c)) {
1481                word.append(c);
1482                ++pos; /*1*/
1483                if (pos < inputLength) {
1484                    c = input.charAt(pos); /*2*/
1485                }
1486            }
1487
1488            int wordLength = word.length();
1489            if (lineLength + wordLength >= fixedLength) {
1490                // Force a word wrap here, because the length of the
1491
// text line exceeds the fixed length
1492
buf.append(delimiter);
1493                lineLength = 0;
1494            }
1495
1496            // Add the word
1497
buf.append(word);
1498            lineLength += wordLength;
1499        }
1500
1501        return buf.toString();
1502    }
1503
1504    public static void main(String JavaDoc args[]) {
1505        // 01234567890123456789
1506
String JavaDoc text = "CAT SAT ON THE MAT";
1507
1508        String JavaDoc textResult = createWordWrappedString(text, 12, "\n");
1509
1510        System.out.println(textResult);
1511
1512    }
1513
1514    /**
1515     * remove surrounding quote marks (either "" or ''), only if quotes are at both the beginning and end of the string
1516     *
1517     * @param s string for testing
1518     * @return string which has surrounding quotes, if any, removed
1519     */

1520    public static String JavaDoc unquote(String JavaDoc s) {
1521        String JavaDoc result = s;
1522        if (startsAndEnds(s, "\"") || startsAndEnds(s, "'")) {
1523            result = s.substring(1, s.length() - 1);
1524        }
1525
1526        return result;
1527    }
1528
1529
1530    /**
1531     * determine whether a string both starts and ends with the given substring
1532     *
1533     * @param s string to look at
1534     * @param search substring to search for
1535     * @return true if string is surrounded by search string
1536     */

1537    public static boolean startsAndEnds(String JavaDoc s, String JavaDoc search) {
1538        if (s != null && s.length() >= 2 && s.startsWith(search) && s.endsWith(search)) {
1539            return true;
1540        }
1541
1542        return false;
1543    }
1544
1545} /* StringUtil */
1546
Popular Tags