Package org.apache.wicket.util.encoding
Class UrlEncoder
- java.lang.Object
-
- org.apache.wicket.util.encoding.UrlEncoder
-
public class UrlEncoder extends java.lang.ObjectAdapted from java.net.URLEncoder, but defines instances for query string encoding versus URL path component encoding. The difference is important because a space is encoded as a + in a query string, but this is a valid value in a path component (and is therefore not decode back to a space).- Author:
- Doug Donohoe
- See Also:
URLEncoder, RFC-2396
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classUrlEncoder.Typeencoder types
-
Field Summary
Fields Modifier and Type Field Description protected static intcaseDiffprotected java.util.BitSetdontNeedEncodingList of what not to encode, i.e.static UrlEncoderHEADER_INSTANCEEncoder used to encode a header.static UrlEncoderPATH_INSTANCEEncoder used to encode segments of a path.
For example: http://org.acme/foo/thispart/orthispart?butnot=thispartstatic UrlEncoderQUERY_INSTANCEEncoder used to encode name or value components of a query string.
For example: http://org.acme/notthis/northis/oreventhis?buthis=isokay&asis=thispart
-
Constructor Summary
Constructors Modifier Constructor Description protectedUrlEncoder(UrlEncoder.Type type)Allow subclass to call constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Stringencode(java.lang.String unsafeInput, java.lang.String charsetName)java.lang.Stringencode(java.lang.String s, java.nio.charset.Charset charset)
-
-
-
Field Detail
-
dontNeedEncoding
protected java.util.BitSet dontNeedEncoding
List of what not to encode, i.e. characters (e.g. A-Z) and other allowed signs (e.g. !) that are allowed but don't have a special meaning.
-
caseDiff
protected static final int caseDiff
- See Also:
- Constant Field Values
-
QUERY_INSTANCE
public static final UrlEncoder QUERY_INSTANCE
Encoder used to encode name or value components of a query string.
For example: http://org.acme/notthis/northis/oreventhis?buthis=isokay&asis=thispart
-
PATH_INSTANCE
public static final UrlEncoder PATH_INSTANCE
Encoder used to encode segments of a path.
For example: http://org.acme/foo/thispart/orthispart?butnot=thispart
-
HEADER_INSTANCE
public static final UrlEncoder HEADER_INSTANCE
Encoder used to encode a header.
-
-
Constructor Detail
-
UrlEncoder
protected UrlEncoder(UrlEncoder.Type type)
Allow subclass to call constructor.- Parameters:
type- encoder type
-
-
Method Detail
-
encode
public java.lang.String encode(java.lang.String s, java.nio.charset.Charset charset)- Parameters:
s- string to encodecharset- charset to use for encoding- Returns:
- encoded string
- See Also:
URLEncoder.encode(String, String)
-
encode
public java.lang.String encode(java.lang.String unsafeInput, java.lang.String charsetName)- Parameters:
unsafeInput- string to encodecharsetName- encoding to use- Returns:
- encoded string
- See Also:
URLEncoder.encode(String, String)
-
-