Guava CharEscaperBuilder - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Guava CharEscaperBuilder class.

This code example shows how to use the following methods:
        "EXTRAINFO=? " + // 27 
        "WHERE ID=? "; 
 
    private final static int ADDITIONAL_FIELDS = 14;
 
    private static final Escaper AS_PERCENT_VALUE = new CharEscaperBuilder().
            addEscape('%', "%25").
            addEscape(',', "%2C").
            addEscape('=', "%3D").
            toEscaper();
 
    private static String serialiseMap(Map<String,String> map)
    { 
        Map<String,String> transformed = Maps.newHashMapWithExpectedSize(map.size());
        for (Map.Entry<String,String> e : map.entrySet()) {
            transformed.put(AS_PERCENT_VALUE.escape(e.getKey()),
                    AS_PERCENT_VALUE.escape(e.getValue()));
        } 
        return Joiner.on(',').withKeyValueSeparator("=").join(transformed);
    } 
3
CodeRank