public String validate ( String value ) { if ( value == null ) { return null ; } for ( int i = 0 ; i < patterns . length ; i ++ ) { Matcher matcher = patterns [ i ] . matcher ( value ) ; if ( matcher . matches ( ) ) { int count = matcher . groupCount ( ) ; if ( count == 1 ) { return matcher . group ( 1 ) ; } StringBuffer buffer = new StringBuffer ( ) ; for ( int j = 0 ; j < count ; j ++ ) { String component = matcher . group ( j + 1 ) ; if ( component != null ) { buffer . append ( component ) ; } } return buffer . toString ( ) ; } } return null ; }
Validate a value against the set of regular expressions returning a String value of the aggregated groups .