de.phleisch.app.itsucks.processing.impl
Class SeekDataProcessorWrapper

java.lang.Object
  extended by de.phleisch.app.itsucks.processing.impl.SeekDataProcessorWrapper
All Implemented Interfaces:
DataProcessor

public class SeekDataProcessorWrapper
extends java.lang.Object
implements DataProcessor

This is data processor wrapper which encapsulates another data processor and skips a given count of bytes before giving the data to the encapsulates processor. This is useful for resuming a file to skip the bytes which are already on the disk.

Author:
olli

Field Summary
protected  DataProcessor mDataProcessor
           
protected  long mSeekPosition
           
 
Constructor Summary
SeekDataProcessorWrapper(DataProcessor pDataProcessor, long pSeekPosition)
           
 
Method Summary
 void abort()
          Will be called when the chain is aborted.
 boolean canResume()
          Supports this data processor resuming?
 void finish()
          Shutdown the data processor.
 void init()
          Initializes the data processor.
 boolean isConsumer()
          'Consumes' (saves, parses etc.) this processor to the data or is it only an filter?
 boolean needsDataAsWholeChunk()
          Asks the processor if it needs the data from the data retriever in one chunk and not in multiple pieces.
 DataChunk process(DataChunk pDataChunk)
          Processes the given data chunk.
 void resumeAt(long pByteOffset)
          Resumes the processing at the given position.
 void rollback()
          Will be called when the chain is unexpectly aborted.
 void setProcessorChain(DataProcessorChain pChain)
          Sets the processor chain the processor is a part of.
 boolean supports(Job pJob)
          Returns true if this processor supports the given type of job.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mDataProcessor

protected DataProcessor mDataProcessor

mSeekPosition

protected long mSeekPosition
Constructor Detail

SeekDataProcessorWrapper

public SeekDataProcessorWrapper(DataProcessor pDataProcessor,
                                long pSeekPosition)
Method Detail

canResume

public boolean canResume()
Description copied from interface: DataProcessor
Supports this data processor resuming?

Specified by:
canResume in interface DataProcessor
Returns:
true == yes

finish

public void finish()
Description copied from interface: DataProcessor
Shutdown the data processor. (Release buffers, file handles etc.)

Specified by:
finish in interface DataProcessor

init

public void init()
          throws ProcessingException
Description copied from interface: DataProcessor
Initializes the data processor. (Create buffers, open file handles etc.)

Specified by:
init in interface DataProcessor
Throws:
ProcessingException

abort

public void abort()
Description copied from interface: DataProcessor
Will be called when the chain is aborted. After calling abort, finish is also called.

Specified by:
abort in interface DataProcessor

rollback

public void rollback()
Description copied from interface: DataProcessor
Will be called when the chain is unexpectly aborted. After calling rollback, finish is also called.

Specified by:
rollback in interface DataProcessor

needsDataAsWholeChunk

public boolean needsDataAsWholeChunk()
Description copied from interface: DataProcessor
Asks the processor if it needs the data from the data retriever in one chunk and not in multiple pieces.

Specified by:
needsDataAsWholeChunk in interface DataProcessor
Returns:

process

public DataChunk process(DataChunk pDataChunk)
                  throws ProcessingException
Description copied from interface: DataProcessor
Processes the given data chunk.

Specified by:
process in interface DataProcessor
Returns:
The pDataChunk pointer or a new pointer to changed data.
Throws:
ProcessingException

resumeAt

public void resumeAt(long pByteOffset)
Description copied from interface: DataProcessor
Resumes the processing at the given position.

Specified by:
resumeAt in interface DataProcessor
Parameters:
pByteOffset - The offset position in bytes.

setProcessorChain

public void setProcessorChain(DataProcessorChain pChain)
Description copied from interface: DataProcessor
Sets the processor chain the processor is a part of.

Specified by:
setProcessorChain in interface DataProcessor

supports

public boolean supports(Job pJob)
Description copied from interface: DataProcessor
Returns true if this processor supports the given type of job.

Specified by:
supports in interface DataProcessor
Returns:

isConsumer

public boolean isConsumer()
Description copied from interface: DataProcessor
'Consumes' (saves, parses etc.) this processor to the data or is it only an filter? If an chain contains no consumer, the data is not processed.

Specified by:
isConsumer in interface DataProcessor
Returns:
true == yes


Copyright © 2008. All Rights Reserved.