/** * Append a key-value pair to the string builder. Keys may not contain a * colon. * * @param buff the target buffer * @param key the key * @param value the value */ public static void appendMap(StringBuilder buff, String key, int value) { appendMapKey(buff, key).append(Integer.toHexString(value)); }
/** * Append a key-value pair to the string builder. Keys may not contain a * colon. * * @param buff the target buffer * @param key the key * @param value the value */ public static void appendMap(StringBuilder buff, String key, long value) { appendMapKey(buff, key).append(Long.toHexString(value)); }
/** * Append a key-value pair to the string builder. Keys may not contain a * colon. Values that contain a comma or a double quote are enclosed in * double quotes, with special characters escaped using a backslash. * * @param buff the target buffer * @param key the key * @param value the value */ public static void appendMap(StringBuilder buff, String key, String value) { appendMapKey(buff, key); if (value.indexOf(',') < 0 && value.indexOf('\"') < 0) { buff.append(value); } else { buff.append('\"'); for (int i = 0, size = value.length(); i < size; i++) { char c = value.charAt(i); if (c == '\"') { buff.append('\\'); } buff.append(c); } buff.append('\"'); } }
/** * Append a key-value pair to the string builder. Keys may not contain a * colon. * * @param buff the target buffer * @param key the key * @param value the value */ public static void appendMap(StringBuilder buff, String key, long value) { appendMapKey(buff, key).append(Long.toHexString(value)); }
/** * Append a key-value pair to the string builder. Keys may not contain a * colon. * * @param buff the target buffer * @param key the key * @param value the value */ public static void appendMap(StringBuilder buff, String key, int value) { appendMapKey(buff, key).append(Integer.toHexString(value)); }
/** * Append a key-value pair to the string builder. Keys may not contain a * colon. Values that contain a comma or a double quote are enclosed in * double quotes, with special characters escaped using a backslash. * * @param buff the target buffer * @param key the key * @param value the value */ public static void appendMap(StringBuilder buff, String key, String value) { appendMapKey(buff, key); if (value.indexOf(',') < 0 && value.indexOf('\"') < 0) { buff.append(value); } else { buff.append('\"'); for (int i = 0, size = value.length(); i < size; i++) { char c = value.charAt(i); if (c == '\"') { buff.append('\\'); } buff.append(c); } buff.append('\"'); } }