org.apache.wicket.request
Class UrlEncoder

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

public class UrlEncoder
extends java.lang.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  java.util.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, char stopChar)
          Allow subclass to call constructor.
 
Method Summary
 java.lang.String encode(java.lang.String s, java.nio.charset.Charset charset)
           
 java.lang.String encode(java.lang.String s, java.lang.String charsetName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dontNeedEncoding

protected java.util.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,
                     char stopChar)
Allow subclass to call constructor.

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

encode

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

encode

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


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