public static String createPropertyFilter ( String name , String value ) { assert name . matches ( "[^=><~()]+" ) ; StringBuilder builder = new StringBuilder ( name . length ( ) + 3 + ( value == null ? 0 : value . length ( ) * 2 ) ) ; builder . append ( ' ' ) . append ( name ) . append ( ' ' ) ; int begin = 0 ; if ( value != null ) { for ( int i = 0 ; i < value . length ( ) ; i ++ ) { if ( "\\*()" . indexOf ( value . charAt ( i ) ) != - 1 ) { builder . append ( value , begin , i ) . append ( ' ' ) ; begin = i ; } } return builder . append ( value , begin , value . length ( ) ) . append ( ' ' ) . toString ( ) ; } else { return builder . append ( ' ' ) . toString ( ) ; } }
Creates a filter string that matches an attribute value exactly . Characters in the value with special meaning will be escaped .