org.mmbase.util.transformers
Class UrlEscaper

java.lang.Object
  extended by org.mmbase.util.transformers.ReaderTransformer
      extended by org.mmbase.util.transformers.UrlEscaper
All Implemented Interfaces:
Serializable, CharTransformer, Transformer

public class UrlEscaper
extends ReaderTransformer

Escapes and Unescapes undesirable characters using % (URLEncoding) Contrary to java.net.URLEncoder, it does not encode '+'.

Version:
$Id: UrlEscaper.java 41057 2010-02-16 00:12:33Z michiel $
Author:
vpro (as org.mmbase.util.URLEscape, still present in SCAN application), Michiel Meeuwissen
See Also:
Serialized Form

Field Summary
static UrlEscaper INSTANCE
           
 
Constructor Summary
UrlEscaper()
           
 
Method Summary
static void escape(BufferedInputStream r, Writer w)
           
static void main(String[] args)
          Method for testing this class from the command line
 Writer transform(Reader r, Writer w)
          Escape a url.
 Writer transformBack(Reader reader, Writer writer)
          Unescape a url.
 
Methods inherited from class org.mmbase.util.transformers.ReaderTransformer
transform, transform, transformBack, transformBack
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mmbase.util.transformers.Transformer
toString
 

Field Detail

INSTANCE

public static final UrlEscaper INSTANCE
Since:
MMBase-1.9.2
Constructor Detail

UrlEscaper

public UrlEscaper()
Method Detail

transform

public Writer transform(Reader r,
                        Writer w)
Escape a url. Replaces 'invalid characters' with their Escaped code, i.e. the questionmark (?) is escaped with %3F.

Specified by:
transform in interface CharTransformer
Specified by:
transform in class ReaderTransformer

escape

public static void escape(BufferedInputStream r,
                          Writer w)

transformBack

public Writer transformBack(Reader reader,
                            Writer writer)
Unescape a url. Replaces escape sequences with the actual character. i.e %3F is replaced with the the question mark (?).

Specified by:
transformBack in interface CharTransformer
Overrides:
transformBack in class ReaderTransformer
Returns:
the unescaped url.

main

public static void main(String[] args)
Method for testing this class from the command line



MMBase 2.0-SNAPSHOT - null