/** * Form decode a string * @param text * @return */ @Functions.Expose(prefix = "os", names = {"urlDecode"}) public static String formDecode(String text) { if (text == null) { return null; } return Utf8UrlCoder.decode(text); }
/** * Form encode a string */ @Functions.Expose(prefix = "osx", names = {"urlEncode"}) public static String formEncode(String text) { if (text == null) { return null; } return Utf8UrlCoder.encode(text); }
/** * Form encode a string */ @Functions.Expose(prefix = "os", names = {"urlEncode"}) public static String formEncode(String text) { if (text == null) { return null; } return Utf8UrlCoder.encode(text); }
/** * Form decode a string * @param text * @return */ @Functions.Expose(prefix = "os", names = {"urlDecode"}) public static String formDecode(String text) { if (text == null) { return null; } return Utf8UrlCoder.decode(text); }
/** * Form encode a string */ @Functions.Expose(prefix = "os", names = {"urlEncode"}) public static String formEncode(String text) { if (text == null) { return null; } return Utf8UrlCoder.encode(text); }
/** * Form decode a string * @param text * @return */ @Functions.Expose(prefix = "os", names = {"urlDecode"}) public static String formDecode(String text) { if (text == null) { return null; } return Utf8UrlCoder.decode(text); }
/** * Form encode a string */ @Functions.Expose(prefix = "os", names = {"urlEncode"}) public static String formEncode(String text) { if (text == null) { return null; } return Utf8UrlCoder.encode(text); }
private Map<String, String> deserialize(byte[] plain) { String base = CharsetUtil.newUtf8String(plain); // replaces [&=] regex String[] items = StringUtils.splitPreserveAllTokens(base, "&="); Map<String, String> map = Maps.newHashMapWithExpectedSize(items.length); for (int i=0; i < items.length; ) { String key = Utf8UrlCoder.decode(items[i++]); String val = Utf8UrlCoder.decode(items[i++]); map.put(key, val); } return map; } }
/** * Form encode a string */ @Functions.Expose(prefix = "osx", names = {"urlEncode"}) public static String formEncode(String text) { if (text == null) { return null; } return Utf8UrlCoder.encode(text); }
private Map<String, String> deserialize(byte[] plain) { String base = CharsetUtil.newUtf8String(plain); // replaces [&=] regex String[] items = StringUtils.splitPreserveAllTokens(base, "&="); Map<String, String> map = Maps.newHashMapWithExpectedSize(items.length); for (int i=0; i < items.length; ) { String key = Utf8UrlCoder.decode(items[i++]); String val = Utf8UrlCoder.decode(items[i++]); map.put(key, val); } return map; } }
/** * Encode the input for transfer. We use something a lot like HTML form * encodings. * @param in map of parameters to encode */ private byte[] serialize(Map<String, String> in) { StringBuilder sb = new StringBuilder(); for (Map.Entry<String, String> val : in.entrySet()) { sb.append(Utf8UrlCoder.encode(val.getKey())); sb.append('='); sb.append(Utf8UrlCoder.encode(val.getValue())); sb.append('&'); } if (sb.length() > 0) { sb.deleteCharAt(sb.length() - 1); // Remove the last & } return CharsetUtil.getUtf8Bytes(sb.toString()); }
/** * Form decode a string * @param text * @return */ @Functions.Expose(prefix = "osx", names = {"urlDecode"}) public static String formDecode(String text) { if (text == null) { return null; } return Utf8UrlCoder.decode(text); } }
/** * Encode the input for transfer. We use something a lot like HTML form * encodings. * @param in map of parameters to encode */ private byte[] serialize(Map<String, String> in) { StringBuilder sb = new StringBuilder(); for (Map.Entry<String, String> val : in.entrySet()) { sb.append(Utf8UrlCoder.encode(val.getKey())); sb.append('='); sb.append(Utf8UrlCoder.encode(val.getValue())); sb.append('&'); } if (sb.length() > 0) { sb.deleteCharAt(sb.length() - 1); // Remove the last & } return CharsetUtil.getUtf8Bytes(sb.toString()); }
private Map<String, String> deserialize(byte[] plain) { String base = CharsetUtil.newUtf8String(plain); // replaces [&=] regex String[] items = StringUtils.splitPreserveAllTokens(base, "&="); Map<String, String> map = Maps.newHashMapWithExpectedSize(items.length); for (int i=0; i < items.length; ) { String key = Utf8UrlCoder.decode(items[i++]); String val = Utf8UrlCoder.decode(items[i++]); map.put(key, val); } return map; } }
/** * Utility method for joining key / value pair parameters into a url-encoded string. */ public static String joinParameters(Map<String, List<String>> query) { if (query.isEmpty()) { return null; } StringBuilder buf = new StringBuilder(); boolean firstDone = false; for (Map.Entry<String, List<String>> entry : query.entrySet()) { String name = Utf8UrlCoder.encode(entry.getKey()); for (String value : entry.getValue()) { if (firstDone) { buf.append('&'); } firstDone = true; buf.append(name) .append('=') .append(Utf8UrlCoder.encode(value)); } } return buf.toString(); }
/** * Form decode a string * @param text * @return */ @Functions.Expose(prefix = "osx", names = {"urlDecode"}) public static String formDecode(String text) { if (text == null) { return null; } return Utf8UrlCoder.decode(text); } }
/** * Encode the input for transfer. We use something a lot like HTML form * encodings. * @param in map of parameters to encode */ private byte[] serialize(Map<String, String> in) { StringBuilder sb = new StringBuilder(); for (Map.Entry<String, String> val : in.entrySet()) { sb.append(Utf8UrlCoder.encode(val.getKey())); sb.append('='); sb.append(Utf8UrlCoder.encode(val.getValue())); sb.append('&'); } if (sb.length() > 0) { sb.deleteCharAt(sb.length() - 1); // Remove the last & } return CharsetUtil.getUtf8Bytes(sb.toString()); }
/** * Utility method for splitting a parameter string into key / value pairs. */ public static Map<String, List<String>> splitParameters(String query) { if (query == null) { return Collections.emptyMap(); } Map<String, List<String>> params = Maps.newLinkedHashMap(); Matcher paramMatcher = QUERY_PATTERN.matcher(query); while (paramMatcher.find()) { String name = Utf8UrlCoder.decode(paramMatcher.group(1)); String value = Utf8UrlCoder.decode(paramMatcher.group(2)); List<String> values = params.get(name); if (values == null) { values = Lists.newArrayList(); params.put(name, values); } values.add(value); } return Collections.unmodifiableMap(params); }
/** * Utility method for joining key / value pair parameters into a url-encoded string. */ public static String joinParameters(Map<String, List<String>> query) { if (query.isEmpty()) { return null; } StringBuilder buf = new StringBuilder(); boolean firstDone = false; for (Map.Entry<String, List<String>> entry : query.entrySet()) { String name = Utf8UrlCoder.encode(entry.getKey()); for (String value : entry.getValue()) { if (firstDone) { buf.append('&'); } firstDone = true; buf.append(name) .append('=') .append(Utf8UrlCoder.encode(value)); } } return buf.toString(); }
/** * Utility method for splitting a parameter string into key / value pairs. */ public static Map<String, List<String>> splitParameters(String query) { if (query == null) { return Collections.emptyMap(); } Map<String, List<String>> params = Maps.newLinkedHashMap(); Matcher paramMatcher = QUERY_PATTERN.matcher(query); while (paramMatcher.find()) { String name = Utf8UrlCoder.decode(paramMatcher.group(1)); String value = Utf8UrlCoder.decode(paramMatcher.group(2)); List<String> values = params.get(name); if (values == null) { values = Lists.newArrayList(); params.put(name, values); } values.add(value); } return Collections.unmodifiableMap(params); }