private String addStringEvidence ( Dependency dependency , EvidenceType type , String contents , String blockVariable , String field , String fieldPattern , Confidence confidence ) { String value = "" ; //capture array value between [ ] final Matcher arrayMatcher = Pattern . compile ( String . format ( "\\s*?%s\\.%s\\s*?=\\s*?\\[(.*?)\\]" , blockVariable , fieldPattern ) , Pattern . CASE_INSENSITIVE ) . matcher ( contents ) ; if ( arrayMatcher . find ( ) ) { final String arrayValue = arrayMatcher . group ( 1 ) ; value = arrayValue . replaceAll ( "['\"]" , "" ) . trim ( ) ; //strip quotes } else { //capture single value between quotes final Matcher matcher = Pattern . compile ( String . format ( "\\s*?%s\\.%s\\s*?=\\s*?(['\"])(.*?)\\1" , blockVariable , fieldPattern ) , Pattern . CASE_INSENSITIVE ) . matcher ( contents ) ; if ( matcher . find ( ) ) { value = matcher . group ( 2 ) ; } } if ( value . length ( ) > 0 ) { dependency . addEvidence ( type , GEMSPEC , field , value , confidence ) ; } return value ; }
Adds the specified evidence to the given evidence collection .