public static Map < String , ExportedVariable > parseExportedVariables ( String line ) { Pattern randomPattern = Pattern . compile ( ParsingConstants . PROPERTY_GRAPH_RANDOM_PATTERN , Pattern . CASE_INSENSITIVE ) ; Pattern varPattern = Pattern . compile ( "([^,=]+)(\\s*=\\s*(\"([^\",]+)\"|([^,]+)))?" ) ; Map < String , ExportedVariable > result = new LinkedHashMap <> ( ) ; Matcher varMatcher = varPattern . matcher ( line ) ; while ( varMatcher . find ( ) ) { String key = varMatcher . group ( 1 ) . trim ( ) ; if ( Utils . isEmptyOrWhitespaces ( key ) ) continue ; String value = null ; if ( varMatcher . group ( 3 ) != null ) { // We do not always trim! // Surrounding white spaces are kept when defined between quotes. if ( varMatcher . group ( 5 ) != null ) value = varMatcher . group ( 5 ) . trim ( ) ; else value = varMatcher . group ( 4 ) ; } ExportedVariable var = new ExportedVariable ( ) ; Matcher m = randomPattern . matcher ( key ) ; if ( m . matches ( ) ) { var . setRandom ( true ) ; var . setRawKind ( m . group ( 1 ) ) ; key = m . group ( 2 ) . trim ( ) ; } var . setName ( key . trim ( ) ) ; if ( value != null ) var . setValue ( value ) ; result . put ( var . getName ( ) , var ) ; } return result ; }
Parse a list of exported variables .