litesoft
Diff Revisions
810
vs
811
for /trunk/Java/core/Anywhere/src/org/litesoft/core/typeutils/Strings.java
|
@@ -1,5 +1,7 @@ |
1 |
1 |
|
package org.litesoft.core.typeutils; |
2 |
2 |
|
|
|
3 |
+ |
import java.util.*; |
|
4 |
+ |
|
3 |
5 |
|
import org.litesoft.core.annotations.*; |
4 |
6 |
|
import org.litesoft.core.util.stringmatching.*; |
5 |
7 |
|
|
|
@@ -580,4 +582,79 @@ |
580 |
582 |
|
StringMatcher zSM = StringMatcherFactory.createEquals( pParts ); |
581 |
583 |
|
return (zSM != null) && zSM.matches( pInQuestion ); |
582 |
584 |
|
} |
|
585 |
+ |
|
|
586 |
+ |
public static String[] removeAllBlankOrCommentLines( String[] pLines ) |
|
587 |
+ |
{ |
|
588 |
+ |
List<String> lines = new LinkedList<String>(); |
|
589 |
+ |
|
|
590 |
+ |
for ( String line : deNull( pLines ) ) |
|
591 |
+ |
{ |
|
592 |
+ |
String s = line.trim(); |
|
593 |
+ |
if ( (s.length() != 0) && !(s.startsWith( "#" ) || s.startsWith( "//" )) ) |
|
594 |
+ |
{ |
|
595 |
+ |
lines.add( line ); |
|
596 |
+ |
} |
|
597 |
+ |
} |
|
598 |
+ |
return lines.toArray( new String[lines.size()] ); |
|
599 |
+ |
} |
|
600 |
+ |
|
|
601 |
+ |
public static String merge( String[] pLines ) |
|
602 |
+ |
{ |
|
603 |
+ |
if ( (pLines == null) || (pLines.length == 0) ) |
|
604 |
+ |
{ |
|
605 |
+ |
return ""; |
|
606 |
+ |
} |
|
607 |
+ |
if ( pLines.length == 1 ) |
|
608 |
+ |
{ |
|
609 |
+ |
return pLines[0]; |
|
610 |
+ |
} |
|
611 |
+ |
int length = 0; |
|
612 |
+ |
for ( String line : pLines ) |
|
613 |
+ |
{ |
|
614 |
+ |
if ( line != null ) |
|
615 |
+ |
{ |
|
616 |
+ |
length += line.length() + 2; |
|
617 |
+ |
} |
|
618 |
+ |
} |
|
619 |
+ |
StringBuilder sb = new StringBuilder( length ); |
|
620 |
+ |
for ( String line : pLines ) |
|
621 |
+ |
{ |
|
622 |
+ |
if ( line != null ) |
|
623 |
+ |
{ |
|
624 |
+ |
sb.append( line ).append( '\r' ).append( '\n' ); |
|
625 |
+ |
} |
|
626 |
+ |
} |
|
627 |
+ |
return sb.toString(); |
|
628 |
+ |
} |
|
629 |
+ |
|
|
630 |
+ |
public static boolean isAllUppercaseOrSpaces( String pToTest ) |
|
631 |
+ |
{ |
|
632 |
+ |
if ( isNotNullOrEmpty( pToTest ) ) |
|
633 |
+ |
{ |
|
634 |
+ |
for ( int i = 0; i < pToTest.length(); i++ ) |
|
635 |
+ |
{ |
|
636 |
+ |
char c = pToTest.charAt( i ); |
|
637 |
+ |
if ( (c != ' ') && !Character.isUpperCase( c ) ) |
|
638 |
+ |
{ |
|
639 |
+ |
return false; |
|
640 |
+ |
} |
|
641 |
+ |
} |
|
642 |
+ |
} |
|
643 |
+ |
return true; |
|
644 |
+ |
} |
|
645 |
+ |
|
|
646 |
+ |
public static boolean isAllUppercase( String pToTest ) |
|
647 |
+ |
{ |
|
648 |
+ |
if ( isNotNullOrEmpty( pToTest ) ) |
|
649 |
+ |
{ |
|
650 |
+ |
for ( int i = 0; i < pToTest.length(); i++ ) |
|
651 |
+ |
{ |
|
652 |
+ |
if ( !Character.isUpperCase( pToTest.charAt( i ) ) ) |
|
653 |
+ |
{ |
|
654 |
+ |
return false; |
|
655 |
+ |
} |
|
656 |
+ |
} |
|
657 |
+ |
} |
|
658 |
+ |
return true; |
|
659 |
+ |
} |
583 |
660 |
|
} |