Top Description Inners Fields Constructors Methods
org.jboss.logmanager.handlers

pack-priv Class SuffixRotator

extends Object
Class Inheritance
Imports
java.io.IOException, .InputStream, .OutputStream, .UncheckedIOException, java.nio.charset.StandardCharsets, java.nio.file.Files, .Path, .Paths, .StandardCopyOption, java.security.AccessControlContext, .AccessController, .PrivilegedAction, java.text.SimpleDateFormat, java.util.Date, .Locale, java.util.logging.ErrorManager, java.util.zip.GZIPOutputStream, .ZipEntry, .ZipOutputStream

A utility for rotating files based on a files suffix.
Author
James R. Perkins

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
SuffixRotator.CompressionType

The compression type for the rotation

private static class
private static class
private static class
private static class
private static class

Field Summary

Modifier and TypeField and Description
private final AccessControlContext
acc

References Deprecated AccessControlContext is deprecated or references (maybe indirectly) at least one deprecated element.
private final String
private final SuffixRotator.CompressionType
private final String
pack-priv static final SuffixRotator
EMPTY

An empty rotation suffix.

private final SimpleDateFormat
private final String

Constructor Summary

AccessConstructor and Description
private
SuffixRotator(final AccessControlContext acc, final String originalSuffix, final String datePattern, final String compressionSuffix, final SuffixRotator.CompressionType compressionType)
References Deprecated AccessControlContext is deprecated or references (maybe indirectly) at least one deprecated element.

Method Summary

Modifier and TypeMethod and Description
private void
archiveGzip(final Path source, final Path target)

private void
archiveZip(final Path source, final Path target)

private boolean
deleteFile(final Path path)

private boolean
fileExists(final Path file)

pack-priv String

Returns:

the compression suffix or an empty string
getCompressionSuffix
()

The compression suffix or an empty string

pack-priv SuffixRotator.CompressionType

Returns:

the compression type
getCompressionType
()

The compression type.

pack-priv String

Returns:

the date pattern or an empty string
getDatePattern
()

The date format pattern for the suffix or an empty string.

private void
move(final ErrorManager errorManager, final Path src, final Path target)

private InputStream
newInputStream(final Path file)

private OutputStream
newOutputStream(final Path file)

pack-priv static SuffixRotator

Returns:

the file rotator used to determine the suffix parts and rotate the file.
parse
(final AccessControlContext acc, final String
the suffix to parse
suffix
)
References Deprecated AccessControlContext is deprecated or references (maybe indirectly) at least one deprecated element.

Parses a suffix into possible parts for rotation.

pack-priv void
rotate(final ErrorManager
the error manager used to report errors to, if null an IOException will be thrown
errorManager
,
final Path
the file to be rotated
source
,
final String
the suffix to append to the rotated file.
suffix
)

Rotates the file to a new file appending the suffix to the target.

pack-priv void
rotate(final ErrorManager
the error manager used to report errors to, if null an IOException will be thrown
errorManager
,
final Path
the file to be rotated
source
,
final int
the number of backups to keep
maxBackupIndex
)

Rotates the file to a new file appending the suffix to the target.

pack-priv void
rotate(final ErrorManager
the error manager used to report errors to, if null an IOException will be thrown
errorManager
,
final Path
the file to be rotated
source
,
final String
the optional suffix to append to the file before the index and optional compression suffix
suffix
,
final int
the number of backups to keep
maxBackupIndex
)

Rotates the file to a new file appending the suffix to the target.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

accback to summary
private final AccessControlContext acc

References Deprecated

AccessControlContext is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

compressionSuffixback to summary
private final String compressionSuffix
compressionTypeback to summary
private final SuffixRotator.CompressionType compressionType
datePatternback to summary
private final String datePattern
EMPTYback to summary
pack-priv static final SuffixRotator EMPTY

An empty rotation suffix.

formatterback to summary
private final SimpleDateFormat formatter
originalSuffixback to summary
private final String originalSuffix

Constructor Detail

SuffixRotatorback to summary
private SuffixRotator(final AccessControlContext acc, final String originalSuffix, final String datePattern, final String compressionSuffix, final SuffixRotator.CompressionType compressionType)

References Deprecated

AccessControlContext is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Method Detail

archiveGzipback to summary
private void archiveGzip(final Path source, final Path target) throws IOException
archiveZipback to summary
private void archiveZip(final Path source, final Path target) throws IOException
deleteFileback to summary
private boolean deleteFile(final Path path) throws IOException
Annotations
@SuppressWarnings:UnusedReturnValue
fileExistsback to summary
private boolean fileExists(final Path file)
getCompressionSuffixback to summary
pack-priv String getCompressionSuffix()

The compression suffix or an empty string

Returns:String

the compression suffix or an empty string

Annotations
@SuppressWarnings:unused
getCompressionTypeback to summary
pack-priv SuffixRotator.CompressionType getCompressionType()

The compression type.

Returns:SuffixRotator.CompressionType

the compression type

Annotations
@SuppressWarnings:unused
getDatePatternback to summary
pack-priv String getDatePattern()

The date format pattern for the suffix or an empty string.

Returns:String

the date pattern or an empty string

moveback to summary
private void move(final ErrorManager errorManager, final Path src, final Path target)
newInputStreamback to summary
private InputStream newInputStream(final Path file) throws IOException
newOutputStreamback to summary
private OutputStream newOutputStream(final Path file) throws IOException
parseback to summary
pack-priv static SuffixRotator parse(final AccessControlContext acc, final String suffix)

References Deprecated

AccessControlContext is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Parses a suffix into possible parts for rotation.

Parameters
suffix:String

the suffix to parse

Returns:SuffixRotator

the file rotator used to determine the suffix parts and rotate the file.

rotateback to summary
pack-priv void rotate(final ErrorManager errorManager, final Path source, final String suffix)

Rotates the file to a new file appending the suffix to the target.

The compression suffix will automatically be appended to target file if compression is being used. If compression is not being used the file is just moved replacing the target file if it already exists.

Parameters
errorManager:ErrorManager

the error manager used to report errors to, if null an IOException will be thrown

source:Path

the file to be rotated

suffix:String

the suffix to append to the rotated file.

rotateback to summary
pack-priv void rotate(final ErrorManager errorManager, final Path source, final int maxBackupIndex)

Rotates the file to a new file appending the suffix to the target. If a date suffix was specified the suffix will be added before the index or compression suffix. The current date will be used for the suffix.

If the maxBackupIndex is greater than 0 previously rotated files will be moved to an numerically incremented target. The compression suffix, if required, will be appended to this indexed file name.

Parameters
errorManager:ErrorManager

the error manager used to report errors to, if null an IOException will be thrown

source:Path

the file to be rotated

maxBackupIndex:int

the number of backups to keep

rotateback to summary
pack-priv void rotate(final ErrorManager errorManager, final Path source, final String suffix, final int maxBackupIndex)

Rotates the file to a new file appending the suffix to the target.

If the maxBackupIndex is greater than 0 previously rotated files will be moved to an numerically incremented target. The compression suffix, if required, will be appended to this indexed file name.

Parameters
errorManager:ErrorManager

the error manager used to report errors to, if null an IOException will be thrown

source:Path

the file to be rotated

suffix:String

the optional suffix to append to the file before the index and optional compression suffix

maxBackupIndex:int

the number of backups to keep

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
org.jboss.logmanager.handlers back to summary

public final Enum SuffixRotator.CompressionType

extends Enum<SuffixRotator.CompressionType>
Class Inheritance

The compression type for the rotation

Field Summary

Modifier and TypeField and Description
public static final SuffixRotator.CompressionType
public static final SuffixRotator.CompressionType
public static final SuffixRotator.CompressionType

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static SuffixRotator.CompressionType
public static SuffixRotator.CompressionType[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

GZIPback to summary
public static final SuffixRotator.CompressionType GZIP
NONEback to summary
public static final SuffixRotator.CompressionType NONE
ZIPback to summary
public static final SuffixRotator.CompressionType ZIP

Constructor Detail

CompressionTypeback to summary
private CompressionType()

Method Detail

valueOfback to summary
public static SuffixRotator.CompressionType valueOf(String name)
valuesback to summary
public static SuffixRotator.CompressionType[] values()
org.jboss.logmanager.handlers back to summary

private Class SuffixRotator.DeleteFileAction

extends Object
implements PrivilegedAction<Boolean>
Class Inheritance
All Implemented Interfaces
java.security.PrivilegedAction

Field Summary

Modifier and TypeField and Description
private final Path

Constructor Summary

AccessConstructor and Description
private
DeleteFileAction(final Path file)

Method Summary

Modifier and TypeMethod and Description
public Boolean
run()

Implements java.security.PrivilegedAction.run.

Performs the computation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fileback to summary
private final Path file

Constructor Detail

DeleteFileActionback to summary
private DeleteFileAction(final Path file)

Method Detail

runback to summary
public Boolean run()

Implements java.security.PrivilegedAction.run.

Doc from java.security.PrivilegedAction.run.

Performs the computation. This method will be called by AccessController.doPrivileged after enabling privileges.

Returns:Boolean

a class-dependent value that may represent the results of the computation. Each class that implements PrivilegedAction should document what (if anything) this value represents.

Annotations
@Override
org.jboss.logmanager.handlers back to summary

private Class SuffixRotator.FileExistsAction

extends Object
implements PrivilegedAction<Boolean>
Class Inheritance
All Implemented Interfaces
java.security.PrivilegedAction

Field Summary

Modifier and TypeField and Description
private final Path

Constructor Summary

AccessConstructor and Description
private
FileExistsAction(final Path file)

Method Summary

Modifier and TypeMethod and Description
public Boolean
run()

Implements java.security.PrivilegedAction.run.

Performs the computation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fileback to summary
private final Path file

Constructor Detail

FileExistsActionback to summary
private FileExistsAction(final Path file)

Method Detail

runback to summary
public Boolean run()

Implements java.security.PrivilegedAction.run.

Doc from java.security.PrivilegedAction.run.

Performs the computation. This method will be called by AccessController.doPrivileged after enabling privileges.

Returns:Boolean

a class-dependent value that may represent the results of the computation. Each class that implements PrivilegedAction should document what (if anything) this value represents.

Annotations
@Override
org.jboss.logmanager.handlers back to summary

private Class SuffixRotator.InputStreamAction

extends Object
implements PrivilegedAction<InputStream>
Class Inheritance
  • java.lang.Object
  • org.jboss.logmanager.handlers.SuffixRotator.InputStreamAction
All Implemented Interfaces
java.security.PrivilegedAction

Field Summary

Modifier and TypeField and Description
private final Path

Constructor Summary

AccessConstructor and Description
private
InputStreamAction(final Path file)

Method Summary

Modifier and TypeMethod and Description
public InputStream
run()

Implements java.security.PrivilegedAction.run.

Performs the computation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fileback to summary
private final Path file

Constructor Detail

InputStreamActionback to summary
private InputStreamAction(final Path file)

Method Detail

runback to summary
public InputStream run()

Implements java.security.PrivilegedAction.run.

Doc from java.security.PrivilegedAction.run.

Performs the computation. This method will be called by AccessController.doPrivileged after enabling privileges.

Returns:InputStream

a class-dependent value that may represent the results of the computation. Each class that implements PrivilegedAction should document what (if anything) this value represents.

Annotations
@Override
org.jboss.logmanager.handlers back to summary

private Class SuffixRotator.MoveFileAction

extends Object
implements PrivilegedAction<Path>
Class Inheritance
All Implemented Interfaces
java.security.PrivilegedAction

Field Summary

Modifier and TypeField and Description
private final ErrorManager
private final Path
private final Path

Constructor Summary

AccessConstructor and Description
private
MoveFileAction(final ErrorManager errorManager, final Path source, final Path target)

Method Summary

Modifier and TypeMethod and Description
public Path
run()

Implements java.security.PrivilegedAction.run.

Performs the computation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

errorManagerback to summary
private final ErrorManager errorManager
sourceback to summary
private final Path source
targetback to summary
private final Path target

Constructor Detail

MoveFileActionback to summary
private MoveFileAction(final ErrorManager errorManager, final Path source, final Path target)

Method Detail

runback to summary
public Path run()

Implements java.security.PrivilegedAction.run.

Doc from java.security.PrivilegedAction.run.

Performs the computation. This method will be called by AccessController.doPrivileged after enabling privileges.

Returns:Path

a class-dependent value that may represent the results of the computation. Each class that implements PrivilegedAction should document what (if anything) this value represents.

Annotations
@Override
org.jboss.logmanager.handlers back to summary

private Class SuffixRotator.OutputStreamAction

extends Object
implements PrivilegedAction<OutputStream>
Class Inheritance
  • java.lang.Object
  • org.jboss.logmanager.handlers.SuffixRotator.OutputStreamAction
All Implemented Interfaces
java.security.PrivilegedAction

Field Summary

Modifier and TypeField and Description
private final Path

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public OutputStream
run()

Implements java.security.PrivilegedAction.run.

Performs the computation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fileback to summary
private final Path file

Constructor Detail

OutputStreamActionback to summary
private OutputStreamAction(final Path file)

Method Detail

runback to summary
public OutputStream run()

Implements java.security.PrivilegedAction.run.

Doc from java.security.PrivilegedAction.run.

Performs the computation. This method will be called by AccessController.doPrivileged after enabling privileges.

Returns:OutputStream

a class-dependent value that may represent the results of the computation. Each class that implements PrivilegedAction should document what (if anything) this value represents.

Annotations
@Override