org.jasig.portal.utils
Class SubstitutionServletOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by javax.servlet.ServletOutputStream
          extended by org.jasig.portal.utils.SubstitutionServletOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class SubstitutionServletOutputStream
extends javax.servlet.ServletOutputStream

A filter presenting a ServletOutputStream that performs word substitution (search&replace) on the fly. 7/25/05 - UP-1180 - dmindler@rutgers.edu Modified to make use of optimized SubstitutionIntegerFilter

Version:
$Revision: 1.6.4.1 $
Author:
Peter Kharchenko

Field Summary
(package private)  SubstitutionIntegerFilter filter
           
 
Constructor Summary
SubstitutionServletOutputStream(javax.servlet.ServletOutputStream out, byte[] target, byte[] substitute)
          Creates a new SubstitutionServletOutputStream instance.
SubstitutionServletOutputStream(javax.servlet.ServletOutputStream out, byte[] target, byte[] substitute, int bufferSize)
          Creates a new SubstitutionServletOutputStream instance.
 
Method Summary
 void close()
           
 void flush()
           
private static char[] getCharArrayFromByteArray(byte[] c)
          A helper method to convert byte array to int array.
 void write(int i)
           
 
Methods inherited from class javax.servlet.ServletOutputStream
print, print, print, print, print, print, print, println, println, println, println, println, println, println, println
 
Methods inherited from class java.io.OutputStream
write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filter

SubstitutionIntegerFilter filter
Constructor Detail

SubstitutionServletOutputStream

public SubstitutionServletOutputStream(javax.servlet.ServletOutputStream out,
                                       byte[] target,
                                       byte[] substitute)
Creates a new SubstitutionServletOutputStream instance.

Parameters:
out - a true ServletOutputStream value where processed stream should be directed
target - a byte[] value of a target to be replaced
substitute - a byte[] value with which the target will be replaced

SubstitutionServletOutputStream

public SubstitutionServletOutputStream(javax.servlet.ServletOutputStream out,
                                       byte[] target,
                                       byte[] substitute,
                                       int bufferSize)
Creates a new SubstitutionServletOutputStream instance.

Parameters:
out - a true ServletOutputStream value where processed stream should be directed
target - a byte[] value of a target to be replaced
substitute - a byte[] value with which the target will be replaced
bufferSize - a buffer size
Method Detail

write

public void write(int i)
           throws java.io.IOException
Specified by:
write in class java.io.OutputStream
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class java.io.OutputStream
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.OutputStream
Throws:
java.io.IOException

getCharArrayFromByteArray

private static char[] getCharArrayFromByteArray(byte[] c)
A helper method to convert byte array to int array. I am sure there's a way to cast it correctly, but I don't want to take my chances :)

Parameters:
c - a byte[] value
Returns:
an int[] value