org.onebusaway.container.rotation
Class TimeRotationStrategy

java.lang.Object
  extended by org.onebusaway.container.rotation.TimeRotationStrategy
All Implemented Interfaces:
RotationStrategy

public class TimeRotationStrategy
extends Object
implements RotationStrategy

An implementation of RotationStrategy that writes output to file whose named is specified using a format processed using the the SimpleDateFormat class. This allows one to get standard time-based file rotation with whatever time granularity and formatting you may desire.

Author:
bdferris

Constructor Summary
TimeRotationStrategy(String format)
           
 
Method Summary
 Writer getFirstWriter()
           
 Writer getNextWriter(Writer writer, int charactersWritten)
          Called to get the next output writer when a call is made to RotationWriter.flush().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimeRotationStrategy

public TimeRotationStrategy(String format)
Method Detail

getFirstWriter

public Writer getFirstWriter()
                      throws IOException
Specified by:
getFirstWriter in interface RotationStrategy
Returns:
the Writer that will be used for initial output
Throws:
IOException

getNextWriter

public Writer getNextWriter(Writer writer,
                            int charactersWritten)
                     throws IOException
Description copied from interface: RotationStrategy
Called to get the next output writer when a call is made to RotationWriter.flush(). The current writer is provided as a parameter, so if no rotation should occur, just return the current writer.

Specified by:
getNextWriter in interface RotationStrategy
Parameters:
writer - the current output writer
charactersWritten - the number of characters written to the current writer
Returns:
the writer to output to in the future
Throws:
IOException


Copyright © 2012 OneBusAway. All Rights Reserved.