ikrs.httpd.resource
Class ReplacingResource

java.lang.Object
  extended by ikrs.httpd.resource.AbstractResource
      extended by ikrs.httpd.resource.BufferedResource
          extended by ikrs.httpd.resource.ReplacingResource
All Implemented Interfaces:
Resource

public class ReplacingResource
extends BufferedResource

The ReplacingResource extends the BufferedResource and applies a replacement map on the underlying stream. Actually it's just a wrapper to hide the ikrs.util.ReplacingInputStream from the rest of the package. Note: as no one can tell if or how many placeholder will appear in the stream data, the final stream length it is not predictable. That's why the whole (!) incoming data needs to be buffered. Keep that in mind if you want pass large files or infinite streams.


Constructor Summary
ReplacingResource(HTTPHandler handler, CustomLogger logger, java.io.InputStream in, boolean useFairLocks, java.util.Map<byte[],byte[]> replacementMap)
          Create a new ReplacingResource.
 
Method Summary
static void main(java.lang.String[] argv)
          For testing only.
 
Methods inherited from class ikrs.httpd.resource.BufferedResource
close, getInputStream, getLength, getOutputStream, isOpen, isReadOnly, open
 
Methods inherited from class ikrs.httpd.resource.AbstractResource
getHTTPHandler, getHypertextAccessFile, getLogger, getMetaData, getReadLock, getWriteLock, setHypertextAccessFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReplacingResource

public ReplacingResource(HTTPHandler handler,
                         CustomLogger logger,
                         java.io.InputStream in,
                         boolean useFairLocks,
                         java.util.Map<byte[],byte[]> replacementMap)
                  throws java.lang.NullPointerException
Create a new ReplacingResource.

Parameters:
handler - The HTTPHandler (may be null if not available).
logger - A custom logger to write log messages to (must not be null).
in - The input stream to read the data for buffering from.
useFairLocks - If set to true the class will use fair read locks (writing isn't possible at all with this class).
replacementMap - The map containing the (placeholder replacement) pairs; the map may be empty but must not be null.
Throws:
java.lang.NullPointerException - If logger, the input stream, the replacement map is null or if the replacement map contains null entries.
Method Detail

main

public static void main(java.lang.String[] argv)
For testing only.