private static String [ ] getPathStrings ( String commaSeparatedPaths ) { int length = commaSeparatedPaths . length ( ) ; int curlyOpen = 0 ; int pathStart = 0 ; boolean globPattern = false ; List < String > pathStrings = new ArrayList < String > ( ) ; for ( int i = 0 ; i < length ; i ++ ) { char ch = commaSeparatedPaths . charAt ( i ) ; switch ( ch ) { case ' ' : { curlyOpen ++ ; if ( ! globPattern ) { globPattern = true ; } break ; } case ' ' : { curlyOpen -- ; if ( curlyOpen == 0 && globPattern ) { globPattern = false ; } break ; } case ' ' : { if ( ! globPattern ) { pathStrings . add ( commaSeparatedPaths . substring ( pathStart , i ) ) ; pathStart = i + 1 ; } break ; } } } pathStrings . add ( commaSeparatedPaths . substring ( pathStart , length ) ) ; return pathStrings . toArray ( new String [ 0 ] ) ; }
This method escapes commas in the glob pattern of the given paths .