org.apache.wicket.request
Class UrlEncoder

java.lang.Object
  extended by org.apache.wicket.request.UrlEncoder

public class UrlEncoder
extends Object

Adapted 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
static class UrlEncoder.Type
          encoder types
 
Field Summary
protected static int caseDiff
           
protected  BitSet dontNeedEncoding
           
static UrlEncoder FULL_PATH_INSTANCE
          Encoder used to encode all path segments.
static UrlEncoder PATH_INSTANCE
          Encoder used to encode components of a path.

For example: http://org.acme/foo/thispart/orthispart?butnot=thispart
static 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
 
Constructor Summary
protected UrlEncoder(UrlEncoder.Type type)
          Allow subclass to call constructor.
 
Method Summary
 String encode(String s, Charset charset)
           
 String encode(String unsafeInput, String charsetName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dontNeedEncoding

protected BitSet dontNeedEncoding

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 components of a path.

For example: http://org.acme/foo/thispart/orthispart?butnot=thispart


FULL_PATH_INSTANCE

public static final UrlEncoder FULL_PATH_INSTANCE
Encoder used to encode all path segments. Querystring will be excluded.

For example: http://org.acme/foo/thispart/orthispart?butnot=thispart

Constructor Detail

UrlEncoder

protected UrlEncoder(UrlEncoder.Type type)
Allow subclass to call constructor.

Parameters:
type - encoder type
Method Detail

encode

public String encode(String s,
                     Charset charset)
Parameters:
s - string to encode
charset - charset to use for encoding
Returns:
encoded string
See Also:
URLEncoder.encode(String, String)

encode

public String encode(String unsafeInput,
                     String charsetName)
Parameters:
s - string to encode
charsetName - encoding to use
Returns:
encoded string
See Also:
URLEncoder.encode(String, String)


Copyright © 2006-2012 Apache Software Foundation. All Rights Reserved.