Nice! Gary ---------- Forwarded message ---------- From: <[email protected]> Date: Thu, Sep 10, 2015 at 9:09 AM Subject: logging-log4j2 git commit: Checkstyle fixes; use loop over enum values instead of explicitly specifying enum values; fixed typo in enum value name To: [email protected]
Repository: logging-log4j2 Updated Branches: refs/heads/master 56ccdc586 -> 0c9f056bc Checkstyle fixes; use loop over enum values instead of explicitly specifying enum values; fixed typo in enum value name Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/0c9f056b Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/0c9f056b Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/0c9f056b Branch: refs/heads/master Commit: 0c9f056bcbeea8880df0e5e54bf56cc21f03778c Parents: 56ccdc5 Author: rpopma <[email protected]> Authored: Fri Sep 11 01:09:25 2015 +0900 Committer: rpopma <[email protected]> Committed: Fri Sep 11 01:09:25 2015 +0900 ---------------------------------------------------------------------- .../rolling/DefaultRolloverStrategy.java | 60 ++++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0c9f056b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java index 6da1b77..8c26650 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java @@ -80,52 +80,59 @@ import org.apache.logging.log4j.status.StatusLogger; @Plugin(name = "DefaultRolloverStrategy", category = "Core", printObject = true) public class DefaultRolloverStrategy implements RolloverStrategy { + /** + * Enumerates over supported file extensions. + */ private enum FileExtensions { ZIP(".zip") { @Override - Action createCompressAction(final String renameTo, final String compressedName, final boolean deleteSource, - final int compressionLevel) { + Action createCompressAction(final String renameTo, final String compressedName, + final boolean deleteSource, final int compressionLevel) { return new ZipCompressAction(new File(baseName(renameTo)), new File(compressedName), deleteSource, compressionLevel); } }, GZIP(".gz") { @Override - Action createCompressAction(final String renameTo, final String compressedName, final boolean deleteSource, - final int compressionLevel) { + Action createCompressAction(final String renameTo, final String compressedName, + final boolean deleteSource, final int compressionLevel) { return new GzCompressAction(new File(baseName(renameTo)), new File(compressedName), deleteSource); } }, BZIP2(".bz2") { @Override - Action createCompressAction(final String renameTo, final String compressedName, final boolean deleteSource, - final int compressionLevel) { + Action createCompressAction(final String renameTo, final String compressedName, + final boolean deleteSource, final int compressionLevel) { // One of "gz", "bzip2", "xz", "pack200", or "deflate". - return new CommonsCompressAction("bzip2", new File(baseName(renameTo)), new File(compressedName), deleteSource); + return new CommonsCompressAction("bzip2", new File(baseName(renameTo)), new File(compressedName), + deleteSource); } }, - DEFALTE(".deflate") { + DEFLATE(".deflate") { @Override - Action createCompressAction(final String renameTo, final String compressedName, final boolean deleteSource, - final int compressionLevel) { + Action createCompressAction(final String renameTo, final String compressedName, + final boolean deleteSource, final int compressionLevel) { // One of "gz", "bzip2", "xz", "pack200", or "deflate". - return new CommonsCompressAction("deflate", new File(baseName(renameTo)), new File(compressedName), deleteSource); + return new CommonsCompressAction("deflate", new File(baseName(renameTo)), new File(compressedName), + deleteSource); } }, PACK200(".pack200") { @Override - Action createCompressAction(final String renameTo, final String compressedName, final boolean deleteSource, - final int compressionLevel) { + Action createCompressAction(final String renameTo, final String compressedName, + final boolean deleteSource, final int compressionLevel) { // One of "gz", "bzip2", "xz", "pack200", or "deflate". - return new CommonsCompressAction("pack200", new File(baseName(renameTo)), new File(compressedName), deleteSource); + return new CommonsCompressAction("pack200", new File(baseName(renameTo)), new File(compressedName), + deleteSource); } }, XY(".xy") { @Override - Action createCompressAction(final String renameTo, final String compressedName, final boolean deleteSource, - final int compressionLevel) { + Action createCompressAction(final String renameTo, final String compressedName, + final boolean deleteSource, final int compressionLevel) { // One of "gz", "bzip2", "xz", "pack200", or "deflate". - return new CommonsCompressAction("xy", new File(baseName(renameTo)), new File(compressedName), deleteSource); + return new CommonsCompressAction("xy", new File(baseName(renameTo)), new File(compressedName), + deleteSource); } }; @@ -220,7 +227,8 @@ public class DefaultRolloverStrategy implements RolloverStrategy { * @param minIndex The minimum index. * @param maxIndex The maximum index. */ - protected DefaultRolloverStrategy(final int minIndex, final int maxIndex, final boolean useMax, final int compressionLevel, final StrSubstitutor subst) { + protected DefaultRolloverStrategy(final int minIndex, final int maxIndex, final boolean useMax, + final int compressionLevel, final StrSubstitutor subst) { this.minIndex = minIndex; this.maxIndex = maxIndex; this.useMax = useMax; @@ -449,18 +457,10 @@ public class DefaultRolloverStrategy implements RolloverStrategy { } private int suffixLength(final String lowFilename) { - if (FileExtensions.GZIP.isExtensionFor(lowFilename)) { - return FileExtensions.GZIP.length(); - } else if (FileExtensions.ZIP.isExtensionFor(lowFilename)) { - return FileExtensions.ZIP.length(); - } else if (FileExtensions.BZIP2.isExtensionFor(lowFilename)) { - return FileExtensions.BZIP2.length(); - } else if (FileExtensions.DEFALTE.isExtensionFor(lowFilename)) { - return FileExtensions.DEFALTE.length(); - } else if (FileExtensions.PACK200.isExtensionFor(lowFilename)) { - return FileExtensions.PACK200.length(); - } else if (FileExtensions.XY.isExtensionFor(lowFilename)) { - return FileExtensions.XY.length(); + for (FileExtensions extension : FileExtensions.values()) { + if (extension.isExtensionFor(lowFilename)) { + return extension.length(); + } } return 0; } -- E-Mail: [email protected] | [email protected] Java Persistence with Hibernate, Second Edition <http://www.manning.com/bauer3/> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/> Spring Batch in Action <http://www.manning.com/templier/> Blog: http://garygregory.wordpress.com Home: http://garygregory.com/ Tweet! http://twitter.com/GaryGregory
