org.egothor.merger
Class Merge

java.lang.Object
  extended by org.egothor.merger.Merge
All Implemented Interfaces:
BarrelReader

public class Merge
extends java.lang.Object
implements BarrelReader

A Merge object is an implementation of BarrelReader. When a Merge is constructed the object is supplied with an enumeration of BarrelReaders (an implementation of Barrel). The given Barrels are merged into a single BarrelReader represented by this class.

Author:
Leo Galambos

Constructor Summary
Merge()
          Constructor for the Merge object.
 
Method Summary
 void add(BarrelReader bf)
          Add another barrel reader into this class.
 void close()
          Closes this Merger and all the inner structures.
 SequenceWithClose<DocumentData> getDocuments()
          Return an enumeration of DocumentData objects.
 SequenceWithClose<IListReader> getILists()
          Return an enumeration of IListReaders.
 long length()
          Return the length of the final product of this object.
 void rewind()
          Restart operation is not supported.
 int size()
          How many readers are merged?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Merge

public Merge()
Constructor for the Merge object. The given Enumeration should be a collection of BarrelReaders.

Method Detail

getDocuments

public SequenceWithClose<DocumentData> getDocuments()
Return an enumeration of DocumentData objects. The first element represents the metadata of document number 0, and the last element has an index number equal to length()-1. The collection is generated without gaps

Specified by:
getDocuments in interface BarrelReader
Returns:
a Sequence

getILists

public SequenceWithClose<IListReader> getILists()
Return an enumeration of IListReaders.

Specified by:
getILists in interface BarrelReader
Returns:
a Sequence

size

public int size()
How many readers are merged?

Returns:
the value

add

public void add(BarrelReader bf)
Add another barrel reader into this class. The barrel reader will be closed by this Merger. This method can only be called before any other method of this class is called.

Parameters:
bf - BarrelReader passed to this Merger

close

public void close()
Closes this Merger and all the inner structures.

Specified by:
close in interface BarrelReader

length

public long length()
Return the length of the final product of this object.

Specified by:
length in interface BarrelReader
Returns:
the length

rewind

public void rewind()
            throws java.lang.UnsupportedOperationException
Restart operation is not supported.

Specified by:
rewind in interface BarrelReader
Throws:
java.lang.UnsupportedOperationException