org.objectledge.encodings
Class URLEncoder

java.lang.Object
  extended by org.objectledge.encodings.URLEncoder

public class URLEncoder
extends Object

Tool for encoding URLs in a less restrictive manner, ie. allowing / (slash) character in encoded values, what is useful for putting path values in Query String fields.

Version:
$Id: URLEncoder.java,v 1.7 2006/02/08 18:21:20 zwierzem Exp $
Author:
Damian Gajda

Field Summary
private static String HEX_CHARS
           
private static boolean[] PASS_THROUGH
           
 
Constructor Summary
URLEncoder()
           
 
Method Summary
private  String encode(String text, String encodingName, boolean isQSValue)
          Encodes a given text as a query string value or content path with UTF-8 encoding.
 String encodeContentPath(String text, String encodingName)
          Encodes a given text as a query string value with UTF-8 encoding.
 String encodeQueryStringValue(String text, String encodingName)
          Encodes a given text as a query string value with UTF-8 encoding.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PASS_THROUGH

private static final boolean[] PASS_THROUGH

HEX_CHARS

private static final String HEX_CHARS
See Also:
Constant Field Values
Constructor Detail

URLEncoder

public URLEncoder()
Method Detail

encodeQueryStringValue

public String encodeQueryStringValue(String text,
                                     String encodingName)
                              throws UnsupportedEncodingException
Encodes a given text as a query string value with UTF-8 encoding.

Parameters:
text - Text to be encoded
encodingName - name of a chosen encoding.
Returns:
encoded text
Throws:
UnsupportedEncodingException - if the requested encoding is not supported.

encodeContentPath

public String encodeContentPath(String text,
                                String encodingName)
                         throws UnsupportedEncodingException
Encodes a given text as a query string value with UTF-8 encoding.

Parameters:
text - Text to be encoded
encodingName - name of a chosen encoding.
Returns:
encoded text
Throws:
UnsupportedEncodingException - if the requested encoding is not supported.

encode

private String encode(String text,
                      String encodingName,
                      boolean isQSValue)
               throws UnsupportedEncodingException
Encodes a given text as a query string value or content path with UTF-8 encoding.

Parameters:
text - Text to be encoded
encodingName - name of a chosen encoding.
isQSValue - true for encoding a query string value
Returns:
encoded text
Throws:
UnsupportedEncodingException - if the requested encoding is not supported.


Copyright © 2003-2006 objectledge.org. All Rights Reserved.