public static Properties parseInstructions ( final String query ) throws MalformedURLException { final Properties instructions = new Properties ( ) ; if ( query != null ) { try { // just ignore for the moment and try out if we have valid properties separated by "&" final String segments [ ] = query . split ( "&" ) ; for ( String segment : segments ) { // do not parse empty strings if ( segment . trim ( ) . length ( ) > 0 ) { final Matcher matcher = INSTRUCTIONS_PATTERN . matcher ( segment ) ; if ( matcher . matches ( ) ) { String key = matcher . group ( 1 ) ; String val = matcher . group ( 2 ) ; instructions . setProperty ( verifyKey ( key ) , val != null ? URLDecoder . decode ( val , "UTF-8" ) : "" ) ; } else { throw new MalformedURLException ( "Invalid syntax for instruction [" + segment + "]. Take a look at http://www.aqute.biz/Code/Bnd." ) ; } } } } catch ( UnsupportedEncodingException e ) { // thrown by URLDecoder but it should never happen throwAsMalformedURLException ( "Could not retrieve the instructions from [" + query + "]" , e ) ; } } return instructions ; }
Parses bnd instructions out of an url query string .