@Test public void testFormatWithNoPlaceholdersAndCorrectArgumentCount() { assertEquals( "(cn=foo)", FilterEncoder.format( "(cn=foo)", (String[])null ) ); assertEquals( "(cn=foo)", FilterEncoder.format( "(cn=foo)", ZERO ) ); }
public static String format( String filterTemplate, String... values ) { if ( values == null ) { values = Strings.EMPTY_STRING_ARRAY; } MessageFormat mf = new MessageFormat( filterTemplate, Locale.ROOT ); Format[] formats = mf.getFormatsByArgumentIndex(); if ( formats.length != values.length ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13300_BAD_PLACE_HOLDERS_NUMBER, filterTemplate, formats.length, values.length ) ); } for ( int i = 0; i < values.length; i++ ) { values[i] = encodeFilterValue( values[i] ); } return mf.format( values ); }
FilterEncoder { public static String format( String filterTemplate, String... values ) { if ( values == null ) { values = Strings.EMPTY_STRING_ARRAY; } MessageFormat mf = new MessageFormat( filterTemplate, Locale.ROOT ); Format[] formats = mf.getFormatsByArgumentIndex(); if ( formats.length != values.length ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13300_BAD_PLACE_HOLDERS_NUMBER, filterTemplate, formats.length, values.length ) ); } for ( int i = 0; i < values.length; i++ ) { values[i] = encodeFilterValue( values[i] ); } return mf.format( values ); } }
FilterEncoder { public static String format( String filterTemplate, String... values ) { if ( values == null ) { values = Strings.EMPTY_STRING_ARRAY; } MessageFormat mf = new MessageFormat( filterTemplate, Locale.ROOT ); Format[] formats = mf.getFormatsByArgumentIndex(); if ( formats.length != values.length ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13300_BAD_PLACE_HOLDERS_NUMBER, filterTemplate, formats.length, values.length ) ); } for ( int i = 0; i < values.length; i++ ) { values[i] = encodeFilterValue( values[i] ); } return mf.format( values ); } private  FilterEncoder(); }
FilterEncoder { public static String format( String filterTemplate, String... values ) { if ( values == null ) { values = Strings.EMPTY_STRING_ARRAY; } MessageFormat mf = new MessageFormat( filterTemplate, Locale.ROOT ); Format[] formats = mf.getFormatsByArgumentIndex(); if ( formats.length != values.length ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13300_BAD_PLACE_HOLDERS_NUMBER, filterTemplate, formats.length, values.length ) ); } for ( int i = 0; i < values.length; i++ ) { values[i] = encodeFilterValue( values[i] ); } return mf.format( values ); } private  FilterEncoder(); static String format( String filterTemplate, String... values ); static String encodeFilterValue( String value ); }
FilterEncoder { public static String format( String filterTemplate, String... values ) { if ( values == null ) { values = Strings.EMPTY_STRING_ARRAY; } MessageFormat mf = new MessageFormat( filterTemplate, Locale.ROOT ); Format[] formats = mf.getFormatsByArgumentIndex(); if ( formats.length != values.length ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13300_BAD_PLACE_HOLDERS_NUMBER, filterTemplate, formats.length, values.length ) ); } for ( int i = 0; i < values.length; i++ ) { values[i] = encodeFilterValue( values[i] ); } return mf.format( values ); } private  FilterEncoder(); static String format( String filterTemplate, String... values ); static String encodeFilterValue( String value );  }