ikrs.httpd.resource
Class ReplacingResource
java.lang.Object
ikrs.httpd.resource.AbstractResource
ikrs.httpd.resource.BufferedResource
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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.
main
public static void main(java.lang.String[] argv)
- For testing only.