net.sf.j2ep
Class UrlRewritingOutputStream

java.lang.Object
  extended by ServletOutputStream
      extended by net.sf.j2ep.UrlRewritingOutputStream

public final class UrlRewritingOutputStream
extends ServletOutputStream

A wrapper for the default output stream. This class will make sure all data being sent is cached by the stream and can rewrite all the links.

Author:
Anders Nyman

Constructor Summary
UrlRewritingOutputStream(ServletOutputStream originalStream, java.lang.String ownHostName, java.lang.String contextPath, ServerChain serverChain)
          Basic constructor.
 
Method Summary
 void close()
           
 void rewrite(Server server)
          Processes the stream looking for links, all links found are rewritten.
 void write(byte[] b)
           
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UrlRewritingOutputStream

public UrlRewritingOutputStream(ServletOutputStream originalStream,
                                java.lang.String ownHostName,
                                java.lang.String contextPath,
                                ServerChain serverChain)
Basic constructor.

Parameters:
originalStream - The stream we are wrapping
Method Detail

write

public void write(int b)
           throws java.io.IOException
Throws:
java.io.IOException
See Also:
OutputStream.write(int)

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Throws:
java.io.IOException
See Also:
OutputStream.write(byte[], int, int)

write

public void write(byte[] b)
           throws java.io.IOException
Throws:
java.io.IOException
See Also:
OutputStream.write(byte[])

rewrite

public void rewrite(Server server)
             throws java.io.IOException
Processes the stream looking for links, all links found are rewritten. After this the stream is written to the response.

Parameters:
server - The server that we are using for this request.
Throws:
java.io.IOException - Is thrown when there is a problem with the streams

close

public void close()
           throws java.io.IOException
Throws:
java.io.IOException
See Also:
Closeable.close()