Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/backend/utils/StringUtil.java @ 8856:5e38e2924c07 3.2.x
Fix code style.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 18 Jan 2018 20:12:01 +0100 |
parents | d7c005e12af0 |
children |
comparison
equal
deleted
inserted
replaced
8855:d7c005e12af0 | 8856:5e38e2924c07 |
---|---|
316 n[0] = ""; | 316 n[0] = ""; |
317 System.arraycopy(str, 0, n, 1, str.length); | 317 System.arraycopy(str, 0, n, 1, str.length); |
318 return n; | 318 return n; |
319 } | 319 } |
320 | 320 |
321 public static final String ensureWidthPadLeft(String s, int width, char pad) { | 321 public static final String ensureWidthPadLeft( |
322 String s, | |
323 int width, | |
324 char pad | |
325 ) { | |
322 int N = s.length(); | 326 int N = s.length(); |
323 if (N >= width) { | 327 if (N >= width) { |
324 return s; | 328 return s; |
325 } | 329 } |
326 StringBuilder sb = new StringBuilder(width); | 330 StringBuilder sb = new StringBuilder(width); |
506 | 510 |
507 public static final String repeat(String what, int times) { | 511 public static final String repeat(String what, int times) { |
508 return repeat(what, times, new StringBuilder()).toString(); | 512 return repeat(what, times, new StringBuilder()).toString(); |
509 } | 513 } |
510 | 514 |
511 public static final StringBuilder repeat(String what, int times, StringBuilder sb) { | 515 public static final StringBuilder repeat( |
516 String what, | |
517 int times, | |
518 StringBuilder sb | |
519 ) { | |
512 while (times-- > 0) { | 520 while (times-- > 0) { |
513 sb.append(what); | 521 sb.append(what); |
514 } | 522 } |
515 return sb; | 523 return sb; |
516 } | 524 } |
543 return null; | 551 return null; |
544 } | 552 } |
545 int i = x.lastIndexOf('.'); | 553 int i = x.lastIndexOf('.'); |
546 return i < 0 | 554 return i < 0 |
547 ? new String[] { x, null } | 555 ? new String[] { x, null } |
548 : new String[] { x.substring(0, Math.max(0, i)), x.substring(i+1).toLowerCase() }; | 556 : new String[] { x.substring(0, Math.max(0, i)), |
557 x.substring(i+1).toLowerCase() }; | |
549 } | 558 } |
550 | 559 |
551 public static String entityEncode(String s) { | 560 public static String entityEncode(String s) { |
552 if (s == null || s.length() == 0) { | 561 if (s == null || s.length() == 0) { |
553 return s; | 562 return s; |
676 public static String sprintf(String format, Object... args) { | 685 public static String sprintf(String format, Object... args) { |
677 return sprintf(null, format, args); | 686 return sprintf(null, format, args); |
678 } | 687 } |
679 */ | 688 */ |
680 | 689 |
681 public static String sprintf(Locale locale, String format, Object ... args) { | 690 public static String sprintf( |
691 Locale locale, | |
692 String format, | |
693 Object ... args | |
694 ) { | |
682 StringWriter sw = new StringWriter(); | 695 StringWriter sw = new StringWriter(); |
683 PrintWriter pw = new PrintWriter(sw); | 696 PrintWriter pw = new PrintWriter(sw); |
684 pw.printf(locale, format, args); | 697 pw.printf(locale, format, args); |
685 pw.flush(); | 698 pw.flush(); |
686 return sw.toString(); | 699 return sw.toString(); |