public void handle(char[] buf, int start, int end, Result result) { Parameter param = new Parameter(); param.name = decodeString(buf, start, end, result.encoding); result.params.addLast(param); } }
/** * Charsets for which a byte with an ascii value does not necessarily map * to the corresponding ascii character. */ private static boolean requiresByteLevelDecoding(String encoding) { encoding = getCanonicalEncodingName(encoding).toUpperCase(); // Use endsWith() to include our wrapper character sets, whose names are // of the form "X-Variant-Shift_JIS" or "X-Variant-windows-31j". return (encoding.endsWith("SHIFT_JIS") || encoding.endsWith("WINDOWS-31J")); }
/** * @deprecated Do not use. (Currently only needed internally by * UriParameterMap.) */ @Deprecated public static void parseWithCallback(String str, String encoding, Callback callback) { if (StringUtil.isEmpty(str)) { return; } Result result = new Result(encoding); parser.parse(str, result); for (Parameter param : result.params) { callback.handleParameter(param.name, param.value); } }
/** * @deprecated Use {@code UriParameterMap.parse(query, encoding)}. To convert * from the string to the {@link java.nio.charset.Charset} instance, see * {@link com.google.gdata.util.common.base.Charsets}. Note that an encoding of null * will default to ISO-8859-1 in this deprecated implementation, whereas the * classes in common.net default to UTF-8 encoding. */ @Deprecated public static ParamMap parse(String str, ParamMap map, String encoding) { // If the parameters string is empty, we shouldn't add a key/value pair of // empty strings. if ("".equals(str)) { return map == null ? new ParamMap() : map; } final AtomicReference<ParamMap> outMap = new AtomicReference<ParamMap>(map); parseWithCallback(str, encoding, new Callback() { public void handleParameter(String name, String value) { ParamMap map = outMap.get(); if (map == null) { map = new ParamMap(); outMap.set(map); } map.append(name, value); } }); return outMap.get(); }
/** * This should be a direct replacement for java.net.URLEncoder.encode(), * but appends its output to an Appendable. * * @see java.net.URLEncoder#encode(String, String) * @param s String to encode. * @param encoding character encoding to use (e.g., "UTF-8") * @param out the Appendable destination for the encoded string. * * @throws UnsupportedEncodingException if {@code encoding} is not supported. * @throws IOException if {@code out} does so when appended to. * * @deprecated Use {@link com.google.gdata.util.common.base.CharEscapers#uriEscaper()}. * See {@link FastURLEncoder} for more details. */ @Deprecated public static void encode(String s, String encoding, Appendable out) throws UnsupportedEncodingException, IOException { /* * Note that this method never compares its result with Java's * encoding; it does not not respect the verifyAgainstJava value */ encode(s, encoding, DEFAULT_SAFE_OCTETS, true, out); }
/** * Populates the parameter map from the specified query using the specified * encoding. Package-private so that it can be used by {@link * UriBuilder#setQuery(String)}; it might be reasonable to make this method * public, though. */ // this package and make it private @SuppressWarnings("deprecation") void merge(String query, Charset encoding) { checkNotNull(query); checkNotNull(encoding); FormUrlDecoder.parseWithCallback(query, encoding.name(), new FormUrlDecoder.Callback() { public void handleParameter(String name, String value) { put(name, value); } }); }
/** * @deprecated Do not use. (Currently only needed internally by * UriParameterMap.) */ @Deprecated public static void parseWithCallback(String str, String encoding, Callback callback) { if (StringUtil.isEmpty(str)) { return; } Result result = new Result(encoding); parser.parse(str, result); for (Parameter param : result.params) { callback.handleParameter(param.name, param.value); } }
/** * This should be a direct replacement for java.net.URLEncoder.encode(), * but appends its output to an Appendable. * * @see java.net.URLEncoder#encode(String, String) * @param s String to encode. * @param encoding character encoding to use (e.g., "UTF-8") * @param out the Appendable destination for the encoded string. * * @throws UnsupportedEncodingException if {@code encoding} is not supported. * @throws IOException if {@code out} does so when appended to. * * @deprecated Use {@link com.google.gdata.util.common.base.CharEscapers#uriEscaper()}. * See {@link FastURLEncoder} for more details. */ @Deprecated public static void encode(String s, String encoding, Appendable out) throws UnsupportedEncodingException, IOException { /* * Note that this method never compares its result with Java's * encoding; it does not not respect the verifyAgainstJava value */ encode(s, encoding, DEFAULT_SAFE_OCTETS, true, out); }
/** * Charsets for which a byte with an ascii value does not necessarily map * to the corresponding ascii character. */ private static boolean requiresByteLevelDecoding(String encoding) { encoding = getCanonicalEncodingName(encoding).toUpperCase(); // Use endsWith() to include our wrapper character sets, whose names are // of the form "X-Variant-Shift_JIS" or "X-Variant-windows-31j". return (encoding.endsWith("SHIFT_JIS") || encoding.endsWith("WINDOWS-31J")); }
public void handle(char[] buf, int start, int end, Result result) { Parameter param = new Parameter(); param.name = decodeString(buf, start, end, result.encoding); result.params.addLast(param); } }
/** * @deprecated Do not use. (Currently only needed internally by * UriParameterMap.) */ @Deprecated public static void parseWithCallback(String str, String encoding, Callback callback) { if (StringUtil.isEmpty(str)) { return; } Result result = new Result(encoding); parser.parse(str, result); for (Parameter param : result.params) { callback.handleParameter(param.name, param.value); } }
/** * This should be a direct replacement for java.net.URLEncoder.encode(), * but appends its output to an Appendable. * * @see java.net.URLEncoder#encode(String, String) * @param s String to encode. * @param encoding character encoding to use (e.g., "UTF-8") * @param out the Appendable destination for the encoded string. * * @throws UnsupportedEncodingException if {@code encoding} is not supported. * @throws IOException if {@code out} does so when appended to. * * @deprecated Use {@link com.google.gdata.util.common.base.CharEscapers#uriEscaper()}. * See {@link FastURLEncoder} for more details. */ @Deprecated public static void encode(String s, String encoding, Appendable out) throws UnsupportedEncodingException, IOException { /* * Note that this method never compares its result with Java's * encoding; it does not not respect the verifyAgainstJava value */ encode(s, encoding, DEFAULT_SAFE_OCTETS, true, out); }
/** * Charsets for which a byte with an ascii value does not necessarily map * to the corresponding ascii character. */ private static boolean requiresByteLevelDecoding(String encoding) { encoding = getCanonicalEncodingName(encoding).toUpperCase(); // Use endsWith() to include our wrapper character sets, whose names are // of the form "X-Variant-Shift_JIS" or "X-Variant-windows-31j". return (encoding.endsWith("SHIFT_JIS") || encoding.endsWith("WINDOWS-31J")); }
public void handle(char[] buf, int start, int end, Result result) { Parameter param = new Parameter(); param.name = decodeString(buf, start, end, result.encoding); result.params.addLast(param); } }
/** * Shortcut for encode(s, "UTF-8"). * This is very similiar to java.net.URLEncoder.encode() except that it * uses UTF-8 instead of the platform's default encoding. * @see java.net.URLEncoder#encode(String) * @param s String to encode. * * @deprecated Use {@link com.google.gdata.util.common.base.CharEscapers#uriEscaper()}. */ @Deprecated public static String encode(String s) { try { return encode(s, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new AssertionError(e); } }
/** * Shortcut for encode(s, "UTF-8"). * This is very similiar to java.net.URLEncoder.encode() except that it * uses UTF-8 instead of the platform's default encoding. * @see java.net.URLEncoder#encode(String) * @param s String to encode. * * @deprecated Use {@link com.google.gdata.util.common.base.CharEscapers#uriEscaper()}. */ @Deprecated public static String encode(String s) { try { return encode(s, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new AssertionError(e); } }
/** * Shortcut for encode(s, "UTF-8"). * This is very similiar to java.net.URLEncoder.encode() except that it * uses UTF-8 instead of the platform's default encoding. * @see java.net.URLEncoder#encode(String) * @param s String to encode. * * @deprecated Use {@link com.google.gdata.util.common.base.CharEscapers#uriEscaper()}. */ @Deprecated public static String encode(String s) { try { return encode(s, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new AssertionError(e); } }