void parse ( Reader reader ) throws ParseException { if ( reader == null ) { //just log and return default properties Log . warn ( "parsing NULL reader, so fallback on default configuration!" ) ; return ; } BufferedReader br = new BufferedReader ( reader ) ; String line ; try { while ( ( line = br . readLine ( ) ) != null ) { int commentMarker = line . indexOf ( ' ' ) ; if ( commentMarker != - 1 ) { if ( commentMarker == 0 ) { //skip its a comment continue ; } else { //it's a malformed comment throw new ParseException ( line , commentMarker ) ; } } else { if ( line . isEmpty ( ) || line . matches ( "^\\s*$" ) ) { //skip it's a black line continue ; } //split till the first space int deilimiterIdx = line . indexOf ( ' ' ) ; String key = line . substring ( 0 , deilimiterIdx ) . trim ( ) ; String value = line . substring ( deilimiterIdx ) . trim ( ) ; m_properties . put ( key , value ) ; } } } catch ( IOException ex ) { throw new ParseException ( "Failed to read" , 1 ) ; } }
Parse the configuration