org.apache.wicket.protocol.http
Class WicketURLEncoder

java.lang.Object
  extended by org.apache.wicket.protocol.http.WicketURLEncoder

public class WicketURLEncoder
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, "http://www.ietf.org/rfc/rfc2396.txt"}

Nested Class Summary
static class WicketURLEncoder.Type
          encoder types
 
Field Summary
protected static int caseDiff
           
protected  BitSet dontNeedEncoding
           
static WicketURLEncoder FULL_PATH_INSTANCE
          Encoder used to encode all path segments.
static WicketURLEncoder PATH_INSTANCE
          Encoder used to encode components of a path.

For example: http://org.acme/foo/thispart/orthispart?butnot=thispart
static WicketURLEncoder 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 WicketURLEncoder(WicketURLEncoder.Type type, char stopChar)
          Allow subclass to call constructor.
 
Method Summary
 String encode(String s)
          Calls encode with the application response request encoding as returned by Application.get().getRequestCycleSettings().getResponseRequestEncoding()
 String encode(String s, String enc)
           
 
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 WicketURLEncoder 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 WicketURLEncoder 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 WicketURLEncoder 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

WicketURLEncoder

protected WicketURLEncoder(WicketURLEncoder.Type type,
                           char stopChar)
Allow subclass to call constructor.

Parameters:
type - encoder type
stopChar - stop encoding when stopChar found
Method Detail

encode

public String encode(String s)
Calls encode with the application response request encoding as returned by Application.get().getRequestCycleSettings().getResponseRequestEncoding()

Parameters:
s - Value to encode
Returns:
String encoded using default Application request/respose encoding

encode

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


Copyright © 2004-2011 Apache Software Foundation. All Rights Reserved.