|
@@ -541,7 +541,7 @@ |
541 |
541 |
|
|
542 |
542 |
|
public static String[] splitLines( String pString ) |
543 |
543 |
|
{ |
544 |
|
- |
pString = normalizeNewLines( pString ); |
|
544 |
+ |
pString = Strings.normalizeNewLines( pString ); |
545 |
545 |
|
|
546 |
546 |
|
return Strings.parseChar( pString, '\n' ); |
547 |
547 |
|
} |
|
@@ -582,87 +582,6 @@ |
582 |
582 |
|
return sb.toString(); |
583 |
583 |
|
} |
584 |
584 |
|
|
585 |
|
- |
public static String normalizeNewLines( String pString ) |
586 |
|
- |
{ |
587 |
|
- |
pString = replace( pString, "\r\n", "\n" ); |
588 |
|
- |
pString = replace( pString, "\n\r", "\n" ); |
589 |
|
- |
pString = replace( pString, '\r', "\n" ); |
590 |
|
- |
|
591 |
|
- |
return pString; |
592 |
|
- |
} |
593 |
|
- |
|
594 |
|
- |
public static String[] stringToLines( String pString ) |
595 |
|
- |
{ |
596 |
|
- |
return Strings.parseChar( replace( normalizeNewLines( pString ), "\f", "\n" ), '\n' ); |
597 |
|
- |
} |
598 |
|
- |
|
599 |
|
- |
public static String linesToString( String[] pLines ) |
600 |
|
- |
{ |
601 |
|
- |
StringBuilder sb = new StringBuilder(); |
602 |
|
- |
if ( pLines != null ) |
603 |
|
- |
{ |
604 |
|
- |
for ( String zLine : pLines ) |
605 |
|
- |
{ |
606 |
|
- |
sb.append( zLine ); |
607 |
|
- |
sb.append( '\n' ); |
608 |
|
- |
} |
609 |
|
- |
} |
610 |
|
- |
return sb.toString(); |
611 |
|
- |
} |
612 |
|
- |
|
613 |
|
- |
public static String makeNonBlankLines( String pSource, int pLinesToMake ) |
614 |
|
- |
{ |
615 |
|
- |
pSource = normalizeNewLines( Strings.deNull( pSource ) ); |
616 |
|
- |
StringBuilder sb = new StringBuilder(); |
617 |
|
- |
for ( int i = 0; i < pLinesToMake; i++ ) |
618 |
|
- |
{ |
619 |
|
- |
int at = (pSource += '\n').indexOf( '\n' ); |
620 |
|
- |
String line = pSource.substring( 0, at ); |
621 |
|
- |
pSource = pSource.substring( at + 1 ); |
622 |
|
- |
if ( sb.length() != 0 ) |
623 |
|
- |
{ |
624 |
|
- |
sb.append( '\n' ); |
625 |
|
- |
} |
626 |
|
- |
sb.append( line ).append( ' ' ); |
627 |
|
- |
} |
628 |
|
- |
return sb.toString(); |
629 |
|
- |
} |
630 |
|
- |
|
631 |
|
- |
public static String replace( String pSource, char pToFind, String pToReplaceWith ) |
632 |
|
- |
{ |
633 |
|
- |
if ( (pSource != null) && (pToReplaceWith != null) ) |
634 |
|
- |
{ |
635 |
|
- |
int removeFor = 1; |
636 |
|
- |
int adjustFromBy = pToReplaceWith.length(); |
637 |
|
- |
int from = 0; |
638 |
|
- |
for ( int at; -1 != (at = pSource.indexOf( pToFind, from )); from = at + adjustFromBy ) |
639 |
|
- |
{ |
640 |
|
- |
pSource = pSource.substring( 0, at ) + pToReplaceWith + pSource.substring( at + removeFor ); |
641 |
|
- |
} |
642 |
|
- |
} |
643 |
|
- |
return pSource; |
644 |
|
- |
} |
645 |
|
- |
|
646 |
|
- |
public static String replace( String pSource, String pToFind, String pToReplaceWith ) |
647 |
|
- |
{ |
648 |
|
- |
if ( (pSource != null) && (pToFind != null) && (pToReplaceWith != null) ) |
649 |
|
- |
{ |
650 |
|
- |
int removeFor = pToFind.length(); |
651 |
|
- |
int adjustFromBy = pToReplaceWith.length(); |
652 |
|
- |
int from = 0; |
653 |
|
- |
for ( int at; -1 != (at = pSource.indexOf( pToFind, from )); from = at + adjustFromBy ) |
654 |
|
- |
{ |
655 |
|
- |
pSource = pSource.substring( 0, at ) + pToReplaceWith + pSource.substring( at + removeFor ); |
656 |
|
- |
} |
657 |
|
- |
} |
658 |
|
- |
return pSource; |
659 |
|
- |
} |
660 |
|
- |
|
661 |
|
- |
public static String defaultIfNull( String pTestString, String pDefault ) |
662 |
|
- |
{ |
663 |
|
- |
return Strings.isNullOrEmpty( pTestString ) ? pDefault : pTestString; |
664 |
|
- |
} |
665 |
|
- |
|
666 |
585 |
|
public static void assertAll7BitAsciiAlpha( String pObjectName, String pToBeAssert ) |
667 |
586 |
|
throws IllegalArgumentException |
668 |
587 |
|
{ |