org.apache.lucene.index
Class CompoundFileWriter

java.lang.Object
  extended by org.apache.lucene.index.CompoundFileWriter

public final class CompoundFileWriter
extends Object

Combines multiple files into a single compound file. The file format:

The fileCount integer indicates how many files are contained in this compound file. The {directory} that follows has that many entries. Each directory entry contains a long pointer to the start of this file's data section, and a String with that file's name.

NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.

Constructor Summary
CompoundFileWriter(Directory dir, String name)
          Create the compound stream in the specified file.
 
Method Summary
 void addFile(String file)
          Add a source stream.
 void addFile(String file, Directory dir)
          Same as addFile(String), only for files that are found in an external Directory.
 void close()
          Merge files with the extensions added up to now.
 Directory getDirectory()
          Returns the directory of the compound file.
 String getName()
          Returns the name of the compound file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompoundFileWriter

public CompoundFileWriter(Directory dir,
                          String name)
Create the compound stream in the specified file. The file name is the entire name (no extensions are added).

Throws:
NullPointerException - if dir or name is null
Method Detail

getDirectory

public Directory getDirectory()
Returns the directory of the compound file.


getName

public String getName()
Returns the name of the compound file.


addFile

public void addFile(String file)
Add a source stream. file is the string by which the sub-stream will be known in the compound stream.

Throws:
IllegalStateException - if this writer is closed
NullPointerException - if file is null
IllegalArgumentException - if a file with the same name has been added already

addFile

public void addFile(String file,
                    Directory dir)
Same as addFile(String), only for files that are found in an external Directory.


close

public void close()
           throws IOException
Merge files with the extensions added up to now. All files with these extensions are combined sequentially into the compound stream.

Throws:
IllegalStateException - if close() had been called before or if no file has been added to this object
IOException