org.owasp.encoder
Class EncodedWriter

java.lang.Object
  extended by java.io.Writer
      extended by org.owasp.encoder.EncodedWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable

public class EncodedWriter
extends Writer

EncodedWriter -- A writer the encodes all input for a specific context and writes the encoded output to another writer.

Author:
Jeff Ichnowski

Field Summary
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
EncodedWriter(Writer out, Encoder encoder)
          Creates an EncodedWriter that uses the specified encoder to encode all input before sending it to the wrapped writer.
EncodedWriter(Writer out, String contextName)
          Creates an EncodedWriter that uses the specified encoder to encode all input before sending it to the wrapped writer.
 
Method Summary
 void close()
           
 void flush()
           
 void write(char[] cbuf, int off, int len)
           
 
Methods inherited from class java.io.Writer
append, append, append, write, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EncodedWriter

public EncodedWriter(Writer out,
                     Encoder encoder)
Creates an EncodedWriter that uses the specified encoder to encode all input before sending it to the wrapped writer.

Parameters:
out - the target for all writes
encoder - the encoder to use

EncodedWriter

public EncodedWriter(Writer out,
                     String contextName)
              throws UnsupportedContextException
Creates an EncodedWriter that uses the specified encoder to encode all input before sending it to the wrapped writer. This method is equivalent to calling:
     new EncodedWriter(out, Encoders.forName(contextName));
 

Parameters:
out - the target for all writes
contextName - the encoding context name.
Throws:
UnsupportedContextException - if the contextName is unrecognized or not supported.
Method Detail

write

public void write(char[] cbuf,
                  int off,
                  int len)
           throws IOException
Specified by:
write in class Writer
Throws:
IOException

flush

public void flush()
           throws IOException
Specified by:
flush in interface Flushable
Specified by:
flush in class Writer
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Specified by:
close in class Writer
Throws:
IOException


Copyright © 2011-2013 OWASP (Open Web-Application Security Project). All Rights Reserved.