Apache Tomcat 7.0.37

org.apache.tomcat.util.buf
Class UEncoder

java.lang.Object
  extended by org.apache.tomcat.util.buf.UEncoder

public final class UEncoder
extends Object

Efficient implementation for encoders. This class is not thread safe - you need one encoder per thread. The encoder will save and recycle the internal objects, avoiding garbage. You can add extra characters that you want preserved, for example while encoding a URL you can add "/".

Author:
Costin Manolache

Constructor Summary
UEncoder()
           
 
Method Summary
 void addSafeCharacter(char c)
           
 String encodeURL(String uri)
          Utility function to re-encode the URL.
 void setEncoding(String s)
          Deprecated. Unused. Will be removed in Tomcat 8.0.x onwards.
 void urlEncode(Writer buf, byte[] bytes, int off, int len)
           
 void urlEncode(Writer buf, String s)
          URL Encode string, using a specified encoding.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UEncoder

public UEncoder()
Method Detail

setEncoding

@Deprecated
public void setEncoding(String s)
Deprecated. Unused. Will be removed in Tomcat 8.0.x onwards.


addSafeCharacter

public void addSafeCharacter(char c)

urlEncode

public void urlEncode(Writer buf,
                      String s)
               throws IOException
URL Encode string, using a specified encoding.

Parameters:
buf - The writer
s - string to be encoded
Throws:
IOException - If an I/O error occurs

urlEncode

public void urlEncode(Writer buf,
                      byte[] bytes,
                      int off,
                      int len)
               throws IOException
Throws:
IOException

encodeURL

public String encodeURL(String uri)
Utility function to re-encode the URL. Still has problems with charset, since UEncoder mostly ignores it.


Apache Tomcat 7.0.37

Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.