From 0bef1af00590c627982efc7bafa32e1867331a27 Mon Sep 17 00:00:00 2001 From: Sebastian Bazley Date: Mon, 25 Jun 2012 00:58:19 +0000 Subject: [PATCH] Javadoc git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1353368 13f79535-47bb-0310-9956-ffa450edef68 --- .../http/client/utils/URLEncodedUtils.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java b/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java index 111ed7da8..1ba95af69 100644 --- a/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java +++ b/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java @@ -258,9 +258,13 @@ public class URLEncodedUtils { return result.toString(); } + /** Unreserved characters, i.e. alphanumeric, plus: _ - ! . ~ ' ( ) * */ private static final BitSet UNRESERVED = new BitSet(256); + /** Punctuation characters: , ; : $ & + = */ private static final BitSet PUNCT = new BitSet(256); + /** Characters which are safe to use, i.e. {@link #UNRESERVED} plus {@link #PUNCT}uation */ private static final BitSet SAFE = new BitSet(256); + /** Characters which are safe to use in a path, i.e. {@link #UNRESERVED} plus {@link #PUNCT}uation plus / @ */ private static final BitSet PATHSAFE = new BitSet(256); static { @@ -384,10 +388,24 @@ public class URLEncodedUtils { return urlencode(content, charset != null ? charset : Consts.UTF_8, UNRESERVED); } + /** + * Encode a String using the {@link #SAFE} set of characters. + * + * @param content the string to encode + * @param charset the charset to use + * @return the encoded string + */ static String enc(final String content, final Charset charset) { return urlencode(content, charset, SAFE); } + /** + * Encode a String using the {@link #PATHSAFE} set of characters. + * + * @param content the string to encode + * @param charset the charset to use + * @return the encoded string + */ static String encPath(final String content, final Charset charset) { return urlencode(content, charset, PATHSAFE); }