Top Description Fields Constructors Methods
org.apache.log.output.io.rotate

public Class RevolvingFileStrategy

extends Object
implements FileStrategy
Class Inheritance
All Implemented Interfaces
org.apache.log.output.io.rotate.FileStrategy
Imports
java.io.File, java.text.DecimalFormat, .FieldPosition, .NumberFormat

strategy for naming log files based on appending revolving suffix. If the initial rotation is not specified then the class will attempt to calculate the rotation number via the following algorithm. It will search for the file with the highest number in the rotation. It will then increment its rotation number and use that number. If all files in rotation are present then it will then set the initial rotation to the next rotation after the most recently created file.
Authors
Avalon Development Team, Bernhard Huber, Peter Donald, David Gray

Field Summary

Modifier and TypeField and Description
private File
private DecimalFormat
private int
private int
private static final String

Constructor Summary

AccessConstructor and Description
public
RevolvingFileStrategy(final File
the base file
baseFile
,
final int
the maximum number of rotations ??
maxRotations
)

Creation of a new instane ofthe revolving file strategy.

public
RevolvingFileStrategy(final File
the base file
baseFile
,
final int
the number of initial rotations ??
initialRotation
,
final int
the maximum number of rotations??
maxRotations
)

Creation of a new instane ofthe revolving file strategy.

Method Summary

Modifier and TypeMethod and Description
private int

Returns:

the initial rotation
calculateInitialRotation
()

Method that searches through files that match the pattern for resolving file and determine the last generation written to.

private int

Returns:

the rotation of the file
calculateRotationForFile
(final File
the file to check
file
)

Return the rotation for the specified file

private int[]

Returns:

the array containing rotations
calculateRotations
(final File[]
the files to generate rotation numbers for
matchingFiles
)

Generate an array of rotation numbers for all the files specified.

public int

Returns:

the current rotation number.
getCurrentRotation
()

Retrieve the current rotation number.

private File[]

Returns:

the list of files that match
getMatchingFiles
()

Get a list of files that could have been part of the rotation.

public File

Returns:

File the calculated file name
nextFile
()

Implements org.apache.log.output.io.rotate.FileStrategy.nextFile.

Calculate the real file name from the base filename.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

m_baseFileback to summary
private File m_baseFile
m_decimalFormatback to summary
private DecimalFormat m_decimalFormat
m_maxRotationsback to summary
private int m_maxRotations
m_rotationback to summary
private int m_rotation
PATTERNback to summary
private static final String PATTERN

Constructor Detail

RevolvingFileStrategyback to summary
public RevolvingFileStrategy(final File baseFile, final int maxRotations)

Creation of a new instane ofthe revolving file strategy.

Parameters
baseFile:File

the base file

maxRotations:int

the maximum number of rotations ??

RevolvingFileStrategyback to summary
public RevolvingFileStrategy(final File baseFile, final int initialRotation, final int maxRotations)

Creation of a new instane ofthe revolving file strategy.

Parameters
baseFile:File

the base file

initialRotation:int

the number of initial rotations ??

maxRotations:int

the maximum number of rotations??

Method Detail

calculateInitialRotationback to summary
private int calculateInitialRotation()

Method that searches through files that match the pattern for resolving file and determine the last generation written to.

Returns:int

the initial rotation

calculateRotationForFileback to summary
private int calculateRotationForFile(final File file)

Return the rotation for the specified file

Parameters
file:File

the file to check

Returns:int

the rotation of the file

calculateRotationsback to summary
private int[] calculateRotations(final File[] matchingFiles)

Generate an array of rotation numbers for all the files specified.

Parameters
matchingFiles:File[]

the files to generate rotation numbers for

Returns:int[]

the array containing rotations

getCurrentRotationback to summary
public int getCurrentRotation()

Retrieve the current rotation number.

Returns:int

the current rotation number.

getMatchingFilesback to summary
private File[] getMatchingFiles()

Get a list of files that could have been part of the rotation.

Returns:File[]

the list of files that match

nextFileback to summary
public File nextFile()

Implements org.apache.log.output.io.rotate.FileStrategy.nextFile.

Calculate the real file name from the base filename.

Returns:File

File the calculated file name