Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.result.textwriter
Class MultipleFilesOutput

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.result.textwriter.MultipleFilesOutput
All Implemented Interfaces:
StreamFactory

public class MultipleFilesOutput
extends Object
implements StreamFactory

Manage output to multiple files.

Author:
Erich Schubert

Field Summary
private  File basename
          Base file name.
private  PrintStream defaultStream
          Default stream to write to when no name is supplied.
private static String EXTENSION
          File name extension.
private static String GZIP_EXTENSION
          GZip extra file extension
private static Logging logger
          Logger for debugging.
private  HashMap<String,PrintStream> map
          HashMap of open print streams.
private  boolean usegzip
          Control gzip compression of output.
 
Constructor Summary
MultipleFilesOutput(File base)
          Constructor
MultipleFilesOutput(File base, boolean gzip)
          Constructor
 
Method Summary
 void closeAllStreams()
          Close (and forget) all output streams.
private  PrintStream getDefaultStream()
          Retrieve/open the default output stream.
protected  boolean isGzipCompression()
          Get GZIP compression flag.
private  PrintStream newStream(String name)
          Open a new stream of the given name
 PrintStream openStream(String filename)
          Retrieve the output stream for the given file name.
protected  void setGzipCompression(boolean usegzip)
          Set GZIP compression flag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXTENSION

private static final String EXTENSION
File name extension.

See Also:
Constant Field Values

GZIP_EXTENSION

private static final String GZIP_EXTENSION
GZip extra file extension

See Also:
Constant Field Values

defaultStream

private PrintStream defaultStream
Default stream to write to when no name is supplied.


basename

private File basename
Base file name.


map

private HashMap<String,PrintStream> map
HashMap of open print streams.


usegzip

private boolean usegzip
Control gzip compression of output.


logger

private static final Logging logger
Logger for debugging.

Constructor Detail

MultipleFilesOutput

public MultipleFilesOutput(File base)
Constructor

Parameters:
base - Base file name (folder name)

MultipleFilesOutput

public MultipleFilesOutput(File base,
                           boolean gzip)
Constructor

Parameters:
base - Base file name (folder name)
gzip - Use gzip compression.
Method Detail

getDefaultStream

private PrintStream getDefaultStream()
                              throws IOException
Retrieve/open the default output stream.

Returns:
default output stream
Throws:
IOException

newStream

private PrintStream newStream(String name)
                       throws IOException
Open a new stream of the given name

Parameters:
name - file name (which will be appended to the base name)
Returns:
stream object for the given name
Throws:
IOException

openStream

public PrintStream openStream(String filename)
                       throws IOException
Retrieve the output stream for the given file name.

Specified by:
openStream in interface StreamFactory
Parameters:
filename - Output label.
Returns:
stream object for the given label
Throws:
IOException

isGzipCompression

protected boolean isGzipCompression()
Get GZIP compression flag.

Returns:
if GZIP compression is enabled

setGzipCompression

protected void setGzipCompression(boolean usegzip)
Set GZIP compression flag.

Parameters:
usegzip - use GZIP compression

closeAllStreams

public void closeAllStreams()
Close (and forget) all output streams.

Specified by:
closeAllStreams in interface StreamFactory

Release 0.2.1 (2009-07-13_1605)