org.archive.io
Class ReplayCharSequenceFactory

java.lang.Object
  extended by org.archive.io.ReplayCharSequenceFactory

public class ReplayCharSequenceFactory
extends java.lang.Object

Factory that returns a ReplayCharSequence view on to a recording stream. This factory encapsulates the decision-making figuring which ReplayCharSequence to return whether the single byte or multibyte handling ReplayCharSequence implementations. Get instance of this factory using getInstance() and then call getReplayCharSequence(byte [], long, long, String, String).

Version:
$Revision: 1.40 $, $Date: 2006/11/20 23:40:11 $
Author:
stack

Field Summary
protected static java.util.logging.Logger logger
          Logger.
 
Method Summary
protected  void checkParameters(byte[] buffer, long size, long responseBodyStart)
          Test passed arguments.
static ReplayCharSequenceFactory getInstance()
           
 ReplayCharSequence getReplayCharSequence(byte[] buffer, long size, long responseBodyStart, java.lang.String backingFilename, java.lang.String encoding)
          Return appropriate ReplayCharSequence switching off passed encoding.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static java.util.logging.Logger logger
Logger. Logger used by this factory and by the ReplayCharSequence's returned.

Method Detail

getInstance

public static ReplayCharSequenceFactory getInstance()
Returns:
Instance of the singleton ReplayCharSequenceFactory.

getReplayCharSequence

public ReplayCharSequence getReplayCharSequence(byte[] buffer,
                                                long size,
                                                long responseBodyStart,
                                                java.lang.String backingFilename,
                                                java.lang.String encoding)
                                         throws java.io.IOException
Return appropriate ReplayCharSequence switching off passed encoding. We look at the encoding and try to figure whether to pass back a byte-orientated ReplayCharSequence or a character-orientated ReplayCharStream.

Parameters:
buffer - In-memory buffer of recordings prefix. We read from here first and will only go to the backing file if size requested is greater than buffer.length.
size - Total size of stream to replay in bytes. Used to find EOS. This is total length of content including HTTP headers if present.
responseBodyStart - Where the response body starts in bytes. Used to skip over the HTTP headers if present.
backingFilename - Full path to backing file with content in excess of whats in buffer.
encoding - Encoding to use reading the passed prefix buffer and backing file. For now, should be java canonical name for the encoding. (If null is passed, we will default to ByteReplayCharSequence).
Returns:
A ReplayCharSequence.
Throws:
java.io.IOException - Problems accessing backing file or writing new file of the decoded content.

checkParameters

protected void checkParameters(byte[] buffer,
                               long size,
                               long responseBodyStart)
                        throws java.lang.IllegalArgumentException
Test passed arguments.

Parameters:
buffer - In-memory buffer of recordings prefix. We read from here first and will only go to the backing file if size requested is greater than buffer.length.
size - Total size of stream to replay in bytes. Used to find EOS. This is total length of content including HTTP headers if present.
responseBodyStart - Where the response body starts in bytes. Used to skip over the HTTP headers if present.
Throws:
java.lang.IllegalArgumentException - Thrown if passed an illegal argument.


Copyright © 2003-2006 Internet Archive. All Rights Reserved.