You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2021/12/03 00:33:29 UTC

[commons-compress] branch master updated (f3c9448 -> 2143257)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git.


    from f3c9448  Make some private instance variables final.
     new 2f3abe3  Extract constants.
     new aa9e91f  Make some private instance variables final.
     new 2e4b0d6  Sort members.
     new 2143257  Refactor common pattern.

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../compress/harmony/pack200/PackingOptions.java   | 356 ++++++++++-----------
 1 file changed, 171 insertions(+), 185 deletions(-)

[commons-compress] 02/04: Make some private instance variables final.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit aa9e91ff703acfc7933d71833fd2e14512ff9efb
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 2 19:11:26 2021 -0500

    Make some private instance variables final.
---
 .../compress/harmony/pack200/PackingOptions.java   | 31 +++++++++-------------
 1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/harmony/pack200/PackingOptions.java b/src/main/java/org/apache/commons/compress/harmony/pack200/PackingOptions.java
index 4a63534..fdb9df8 100644
--- a/src/main/java/org/apache/commons/compress/harmony/pack200/PackingOptions.java
+++ b/src/main/java/org/apache/commons/compress/harmony/pack200/PackingOptions.java
@@ -42,7 +42,7 @@ public class PackingOptions {
     private int effort = 5;
     private String deflateHint = KEEP;
     private String modificationTime = KEEP;
-    private List<String> passFiles;
+    private final List<String> passFiles = new ArrayList<>();
     private String unknownAttributeAction = PASS;
     private final Map<String, String> classAttributeActions= new HashMap<>();
     private final Map<String, String> fieldAttributeActions= new HashMap<>();
@@ -139,21 +139,19 @@ public class PackingOptions {
     }
 
     public boolean isPassFile(final String passFileName) {
-        if (passFiles != null) {
-            for (String pass : passFiles) {
-                if (passFileName.equals(pass)) {
-                    return true;
-                }
-                if (!pass.endsWith(".class")) { // a whole directory is
-                    // passed
-                    if (!pass.endsWith("/")) {
-                        // Make sure we don't get any false positives (e.g.
-                        // exclude "org/apache/harmony/pack" should not match
-                        // files under "org/apache/harmony/pack200/")
-                        pass = pass + "/";
-                    }
-                    return passFileName.startsWith(pass);
+        for (String pass : passFiles) {
+            if (passFileName.equals(pass)) {
+                return true;
+            }
+            if (!pass.endsWith(".class")) { // a whole directory is
+                // passed
+                if (!pass.endsWith("/")) {
+                    // Make sure we don't get any false positives (e.g.
+                    // exclude "org/apache/harmony/pack" should not match
+                    // files under "org/apache/harmony/pack200/")
+                    pass = pass + "/";
                 }
+                return passFileName.startsWith(pass);
             }
         }
         return false;
@@ -166,9 +164,6 @@ public class PackingOptions {
      * @param passFileName the file name
      */
     public void addPassFile(String passFileName) {
-        if (passFiles == null) {
-            passFiles = new ArrayList<>();
-        }
         String fileSeparator = System.getProperty("file.separator");
         if (fileSeparator.equals("\\")) {
             // Need to escape backslashes for replaceAll(), which uses regex

[commons-compress] 01/04: Extract constants.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit 2f3abe3f2a73c409e908d5618539358a0d3a17f8
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 2 19:10:15 2021 -0500

    Extract constants.
---
 .../apache/commons/compress/harmony/pack200/PackingOptions.java  | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/harmony/pack200/PackingOptions.java b/src/main/java/org/apache/commons/compress/harmony/pack200/PackingOptions.java
index 0a46e68..4a63534 100644
--- a/src/main/java/org/apache/commons/compress/harmony/pack200/PackingOptions.java
+++ b/src/main/java/org/apache/commons/compress/harmony/pack200/PackingOptions.java
@@ -24,10 +24,11 @@ import java.util.Map;
 import org.objectweb.asm.Attribute;
 
 /**
- * Utility class to manage the various options available for pack200
+ * Utility class to manage the various options available for pack200.
  */
 public class PackingOptions {
 
+    public static final long SEGMENT_LIMIT = 1_000_000L;
     public static final String STRIP = "strip";
     public static final String ERROR = "error";
     public static final String PASS = "pass";
@@ -35,9 +36,9 @@ public class PackingOptions {
 
     // All options are initially set to their defaults
     private boolean gzip = true;
-    private boolean stripDebug = false;
+    private boolean stripDebug;
     private boolean keepFileOrder = true;
-    private long segmentLimit = 1_000_000L;
+    private long segmentLimit = SEGMENT_LIMIT;
     private int effort = 5;
     private String deflateHint = KEEP;
     private String modificationTime = KEEP;
@@ -47,7 +48,7 @@ public class PackingOptions {
     private final Map<String, String> fieldAttributeActions= new HashMap<>();
     private final Map<String, String> methodAttributeActions= new HashMap<>();
     private final Map<String, String> codeAttributeActions= new HashMap<>();
-    private boolean verbose = false;
+    private boolean verbose;
     private String logFile;
 
     private Attribute[] unknownAttributeTypes;

[commons-compress] 04/04: Refactor common pattern.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit 2143257e4edef50c4fad643949dc736b07809a56
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 2 19:33:25 2021 -0500

    Refactor common pattern.
    
    Use final. Extract constant. Javadoc.
---
 .../compress/harmony/pack200/PackingOptions.java   | 62 +++++++++-------------
 1 file changed, 26 insertions(+), 36 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/harmony/pack200/PackingOptions.java b/src/main/java/org/apache/commons/compress/harmony/pack200/PackingOptions.java
index 19b33f4..cda71f4 100644
--- a/src/main/java/org/apache/commons/compress/harmony/pack200/PackingOptions.java
+++ b/src/main/java/org/apache/commons/compress/harmony/pack200/PackingOptions.java
@@ -28,6 +28,7 @@ import org.objectweb.asm.Attribute;
  */
 public class PackingOptions {
 
+    private static final Attribute[] EMPTY_ATTRIBUTE_ARRAY = new Attribute[0];
     public static final long SEGMENT_LIMIT = 1_000_000L;
     public static final String STRIP = "strip";
     public static final String ERROR = "error";
@@ -44,10 +45,10 @@ public class PackingOptions {
     private String modificationTime = KEEP;
     private final List<String> passFiles = new ArrayList<>();
     private String unknownAttributeAction = PASS;
-    private final Map<String, String> classAttributeActions= new HashMap<>();
-    private final Map<String, String> fieldAttributeActions= new HashMap<>();
-    private final Map<String, String> methodAttributeActions= new HashMap<>();
-    private final Map<String, String> codeAttributeActions= new HashMap<>();
+    private final Map<String, String> classAttributeActions = new HashMap<>();
+    private final Map<String, String> fieldAttributeActions = new HashMap<>();
+    private final Map<String, String> methodAttributeActions = new HashMap<>();
+    private final Map<String, String> codeAttributeActions = new HashMap<>();
     private boolean verbose;
     private String logFile;
 
@@ -70,12 +71,12 @@ public class PackingOptions {
     }
 
     private void addOrUpdateAttributeActions(final List<Attribute> prototypes, final Map<String, String> attributeActions, final int tag) {
-        if ((attributeActions != null) && (attributeActions.size() > 0)) {
+        if (attributeActions != null && attributeActions.size() > 0) {
             NewAttribute newAttribute;
-            for (String name : attributeActions.keySet()) {
-                String action = attributeActions.get(name);
+            for (final String name : attributeActions.keySet()) {
+                final String action = attributeActions.get(name);
                 boolean prototypeExists = false;
-                for (Object prototype : prototypes) {
+                for (final Object prototype : prototypes) {
                     newAttribute = (NewAttribute) prototype;
                     if (newAttribute.type.equals(name)) {
                         // if the attribute exists, update its context
@@ -133,6 +134,10 @@ public class PackingOptions {
         return modificationTime;
     }
 
+    private String getOrDefault(final Map<String, String> map, final String type, final String defaultValue) {
+        return map == null ? defaultValue : map.getOrDefault(type, defaultValue);
+    }
+
     public long getSegmentLimit() {
         return segmentLimit;
     }
@@ -148,37 +153,25 @@ public class PackingOptions {
             addOrUpdateAttributeActions(prototypes, methodAttributeActions, AttributeDefinitionBands.CONTEXT_METHOD);
             addOrUpdateAttributeActions(prototypes, fieldAttributeActions, AttributeDefinitionBands.CONTEXT_FIELD);
             addOrUpdateAttributeActions(prototypes, codeAttributeActions, AttributeDefinitionBands.CONTEXT_CODE);
-            unknownAttributeTypes = prototypes.toArray(new Attribute[0]);
+            unknownAttributeTypes = prototypes.toArray(EMPTY_ATTRIBUTE_ARRAY);
         }
         return unknownAttributeTypes;
     }
 
     public String getUnknownClassAttributeAction(final String type) {
-        if (classAttributeActions == null) {
-            return unknownAttributeAction;
-        }
-        return classAttributeActions.getOrDefault(type, unknownAttributeAction);
+        return getOrDefault(classAttributeActions, type, unknownAttributeAction);
     }
 
     public String getUnknownCodeAttributeAction(final String type) {
-        if (codeAttributeActions == null) {
-            return unknownAttributeAction;
-        }
-        return codeAttributeActions.getOrDefault(type, unknownAttributeAction);
+        return getOrDefault(codeAttributeActions, type, unknownAttributeAction);
     }
 
     public String getUnknownFieldAttributeAction(final String type) {
-        if (fieldAttributeActions == null) {
-            return unknownAttributeAction;
-        }
-        return fieldAttributeActions.getOrDefault(type, unknownAttributeAction);
+        return getOrDefault(fieldAttributeActions, type, unknownAttributeAction);
     }
 
     public String getUnknownMethodAttributeAction(final String type) {
-        if (methodAttributeActions == null) {
-            return unknownAttributeAction;
-        }
-        return methodAttributeActions.getOrDefault(type, unknownAttributeAction);
+        return getOrDefault(methodAttributeActions, type, unknownAttributeAction);
     }
 
     public boolean isGzip() {
@@ -226,8 +219,7 @@ public class PackingOptions {
 
     public void setDeflateHint(final String deflateHint) {
         if (!KEEP.equals(deflateHint) && !"true".equals(deflateHint) && !"false".equals(deflateHint)) {
-            throw new IllegalArgumentException(
-                "Bad argument: -H " + deflateHint + " ? deflate hint should be either true, false or keep (default)");
+            throw new IllegalArgumentException("Bad argument: -H " + deflateHint + " ? deflate hint should be either true, false or keep (default)");
         }
         this.deflateHint = deflateHint;
     }
@@ -255,8 +247,7 @@ public class PackingOptions {
 
     public void setModificationTime(final String modificationTime) {
         if (!KEEP.equals(modificationTime) && !"latest".equals(modificationTime)) {
-            throw new IllegalArgumentException("Bad argument: -m " + modificationTime
-                + " ? transmit modtimes should be either latest or keep (default)");
+            throw new IllegalArgumentException("Bad argument: -m " + modificationTime + " ? transmit modtimes should be either latest or keep (default)");
         }
         this.modificationTime = modificationTime;
     }
@@ -266,7 +257,7 @@ public class PackingOptions {
     }
 
     /**
-     * Set the segment limit (equivalent to -S command line option)
+     * Sets the segment limit (equivalent to -S command line option)
      *
      * @param segmentLimit - the limit in bytes
      */
@@ -275,9 +266,9 @@ public class PackingOptions {
     }
 
     /**
-     * Set strip debug attributes. If true, all debug attributes (i.e. LineNumberTable, SourceFile, LocalVariableTable
-     * and LocalVariableTypeTable attributes) are stripped when reading the input class files and not included in the
-     * output archive.
+     * Sets strip debug attributes. If true, all debug attributes (i.e. LineNumberTable, SourceFile, LocalVariableTable and
+     * LocalVariableTypeTable attributes) are stripped when reading the input class files and not included in the output
+     * archive.
      *
      * @param stripDebug If true, all debug attributes.
      */
@@ -286,14 +277,13 @@ public class PackingOptions {
     }
 
     /**
-     * Tell the compressor what to do if an unknown attribute is encountered
+     * Sets the compressor behavior when an unknown attribute is encountered.
      *
      * @param unknownAttributeAction - the action to perform
      */
     public void setUnknownAttributeAction(final String unknownAttributeAction) {
         this.unknownAttributeAction = unknownAttributeAction;
-        if (!PASS.equals(unknownAttributeAction) && !ERROR.equals(unknownAttributeAction)
-            && !STRIP.equals(unknownAttributeAction)) {
+        if (!PASS.equals(unknownAttributeAction) && !ERROR.equals(unknownAttributeAction) && !STRIP.equals(unknownAttributeAction)) {
             throw new RuntimeException("Incorrect option for -U, " + unknownAttributeAction);
         }
     }

[commons-compress] 03/04: Sort members.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit 2e4b0d67233a1547d038edce374fdb3a2bb513e8
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 2 19:11:50 2021 -0500

    Sort members.
---
 .../compress/harmony/pack200/PackingOptions.java   | 318 ++++++++++-----------
 1 file changed, 159 insertions(+), 159 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/harmony/pack200/PackingOptions.java b/src/main/java/org/apache/commons/compress/harmony/pack200/PackingOptions.java
index fdb9df8..19b33f4 100644
--- a/src/main/java/org/apache/commons/compress/harmony/pack200/PackingOptions.java
+++ b/src/main/java/org/apache/commons/compress/harmony/pack200/PackingOptions.java
@@ -53,89 +53,144 @@ public class PackingOptions {
 
     private Attribute[] unknownAttributeTypes;
 
-    public boolean isGzip() {
-        return gzip;
+    public void addClassAttributeAction(final String attributeName, final String action) {
+        classAttributeActions.put(attributeName, action);
     }
 
-    public void setGzip(final boolean gzip) {
-        this.gzip = gzip;
+    public void addCodeAttributeAction(final String attributeName, final String action) {
+        codeAttributeActions.put(attributeName, action);
     }
 
-    public boolean isStripDebug() {
-        return stripDebug;
+    public void addFieldAttributeAction(final String attributeName, final String action) {
+        fieldAttributeActions.put(attributeName, action);
+    }
+
+    public void addMethodAttributeAction(final String attributeName, final String action) {
+        methodAttributeActions.put(attributeName, action);
+    }
+
+    private void addOrUpdateAttributeActions(final List<Attribute> prototypes, final Map<String, String> attributeActions, final int tag) {
+        if ((attributeActions != null) && (attributeActions.size() > 0)) {
+            NewAttribute newAttribute;
+            for (String name : attributeActions.keySet()) {
+                String action = attributeActions.get(name);
+                boolean prototypeExists = false;
+                for (Object prototype : prototypes) {
+                    newAttribute = (NewAttribute) prototype;
+                    if (newAttribute.type.equals(name)) {
+                        // if the attribute exists, update its context
+                        newAttribute.addContext(tag);
+                        prototypeExists = true;
+                        break;
+                    }
+                }
+                // if no attribute is found, add a new attribute
+                if (!prototypeExists) {
+                    if (ERROR.equals(action)) {
+                        newAttribute = new NewAttribute.ErrorAttribute(name, tag);
+                    } else if (STRIP.equals(action)) {
+                        newAttribute = new NewAttribute.StripAttribute(name, tag);
+                    } else if (PASS.equals(action)) {
+                        newAttribute = new NewAttribute.PassAttribute(name, tag);
+                    } else {
+                        newAttribute = new NewAttribute(name, action, tag);
+                    }
+                    prototypes.add(newAttribute);
+                }
+            }
+        }
     }
 
     /**
-     * Set strip debug attributes. If true, all debug attributes (i.e. LineNumberTable, SourceFile, LocalVariableTable
-     * and LocalVariableTypeTable attributes) are stripped when reading the input class files and not included in the
-     * output archive.
+     * Tell the compressor to pass the file with the given name, or if the name is a directory name all files under that
+     * directory will be passed.
      *
-     * @param stripDebug If true, all debug attributes.
+     * @param passFileName the file name
      */
-    public void setStripDebug(final boolean stripDebug) {
-        this.stripDebug = stripDebug;
+    public void addPassFile(String passFileName) {
+        String fileSeparator = System.getProperty("file.separator");
+        if (fileSeparator.equals("\\")) {
+            // Need to escape backslashes for replaceAll(), which uses regex
+            fileSeparator += "\\";
+        }
+        passFileName = passFileName.replaceAll(fileSeparator, "/");
+        passFiles.add(passFileName);
     }
 
-    public boolean isKeepFileOrder() {
-        return keepFileOrder;
+    public String getDeflateHint() {
+        return deflateHint;
     }
 
-    public void setKeepFileOrder(final boolean keepFileOrder) {
-        this.keepFileOrder = keepFileOrder;
+    public int getEffort() {
+        return effort;
+    }
+
+    public String getLogFile() {
+        return logFile;
+    }
+
+    public String getModificationTime() {
+        return modificationTime;
     }
 
     public long getSegmentLimit() {
         return segmentLimit;
     }
 
-    /**
-     * Set the segment limit (equivalent to -S command line option)
-     *
-     * @param segmentLimit - the limit in bytes
-     */
-    public void setSegmentLimit(final long segmentLimit) {
-        this.segmentLimit = segmentLimit;
+    public String getUnknownAttributeAction() {
+        return unknownAttributeAction;
     }
 
-    public int getEffort() {
-        return effort;
+    public Attribute[] getUnknownAttributePrototypes() {
+        if (unknownAttributeTypes == null) {
+            final List<Attribute> prototypes = new ArrayList<>();
+            addOrUpdateAttributeActions(prototypes, classAttributeActions, AttributeDefinitionBands.CONTEXT_CLASS);
+            addOrUpdateAttributeActions(prototypes, methodAttributeActions, AttributeDefinitionBands.CONTEXT_METHOD);
+            addOrUpdateAttributeActions(prototypes, fieldAttributeActions, AttributeDefinitionBands.CONTEXT_FIELD);
+            addOrUpdateAttributeActions(prototypes, codeAttributeActions, AttributeDefinitionBands.CONTEXT_CODE);
+            unknownAttributeTypes = prototypes.toArray(new Attribute[0]);
+        }
+        return unknownAttributeTypes;
     }
 
-    /**
-     * Sets the compression effort level (0-9, equivalent to -E command line option)
-     *
-     * @param effort the compression effort level, 0-9.
-     */
-    public void setEffort(final int effort) {
-        this.effort = effort;
+    public String getUnknownClassAttributeAction(final String type) {
+        if (classAttributeActions == null) {
+            return unknownAttributeAction;
+        }
+        return classAttributeActions.getOrDefault(type, unknownAttributeAction);
     }
 
-    public String getDeflateHint() {
-        return deflateHint;
+    public String getUnknownCodeAttributeAction(final String type) {
+        if (codeAttributeActions == null) {
+            return unknownAttributeAction;
+        }
+        return codeAttributeActions.getOrDefault(type, unknownAttributeAction);
     }
 
-    public boolean isKeepDeflateHint() {
-        return KEEP.equals(deflateHint);
+    public String getUnknownFieldAttributeAction(final String type) {
+        if (fieldAttributeActions == null) {
+            return unknownAttributeAction;
+        }
+        return fieldAttributeActions.getOrDefault(type, unknownAttributeAction);
     }
 
-    public void setDeflateHint(final String deflateHint) {
-        if (!KEEP.equals(deflateHint) && !"true".equals(deflateHint) && !"false".equals(deflateHint)) {
-            throw new IllegalArgumentException(
-                "Bad argument: -H " + deflateHint + " ? deflate hint should be either true, false or keep (default)");
+    public String getUnknownMethodAttributeAction(final String type) {
+        if (methodAttributeActions == null) {
+            return unknownAttributeAction;
         }
-        this.deflateHint = deflateHint;
+        return methodAttributeActions.getOrDefault(type, unknownAttributeAction);
     }
 
-    public String getModificationTime() {
-        return modificationTime;
+    public boolean isGzip() {
+        return gzip;
     }
 
-    public void setModificationTime(final String modificationTime) {
-        if (!KEEP.equals(modificationTime) && !"latest".equals(modificationTime)) {
-            throw new IllegalArgumentException("Bad argument: -m " + modificationTime
-                + " ? transmit modtimes should be either latest or keep (default)");
-        }
-        this.modificationTime = modificationTime;
+    public boolean isKeepDeflateHint() {
+        return KEEP.equals(deflateHint);
+    }
+
+    public boolean isKeepFileOrder() {
+        return keepFileOrder;
     }
 
     public boolean isPassFile(final String passFileName) {
@@ -157,149 +212,94 @@ public class PackingOptions {
         return false;
     }
 
-    /**
-     * Tell the compressor to pass the file with the given name, or if the name is a directory name all files under that
-     * directory will be passed.
-     *
-     * @param passFileName the file name
-     */
-    public void addPassFile(String passFileName) {
-        String fileSeparator = System.getProperty("file.separator");
-        if (fileSeparator.equals("\\")) {
-            // Need to escape backslashes for replaceAll(), which uses regex
-            fileSeparator += "\\";
-        }
-        passFileName = passFileName.replaceAll(fileSeparator, "/");
-        passFiles.add(passFileName);
+    public boolean isStripDebug() {
+        return stripDebug;
+    }
+
+    public boolean isVerbose() {
+        return verbose;
     }
 
     public void removePassFile(final String passFileName) {
         passFiles.remove(passFileName);
     }
 
-    public String getUnknownAttributeAction() {
-        return unknownAttributeAction;
+    public void setDeflateHint(final String deflateHint) {
+        if (!KEEP.equals(deflateHint) && !"true".equals(deflateHint) && !"false".equals(deflateHint)) {
+            throw new IllegalArgumentException(
+                "Bad argument: -H " + deflateHint + " ? deflate hint should be either true, false or keep (default)");
+        }
+        this.deflateHint = deflateHint;
     }
 
     /**
-     * Tell the compressor what to do if an unknown attribute is encountered
+     * Sets the compression effort level (0-9, equivalent to -E command line option)
      *
-     * @param unknownAttributeAction - the action to perform
+     * @param effort the compression effort level, 0-9.
      */
-    public void setUnknownAttributeAction(final String unknownAttributeAction) {
-        this.unknownAttributeAction = unknownAttributeAction;
-        if (!PASS.equals(unknownAttributeAction) && !ERROR.equals(unknownAttributeAction)
-            && !STRIP.equals(unknownAttributeAction)) {
-            throw new RuntimeException("Incorrect option for -U, " + unknownAttributeAction);
-        }
-    }
-
-    public void addClassAttributeAction(final String attributeName, final String action) {
-        classAttributeActions.put(attributeName, action);
-    }
-
-    public void addFieldAttributeAction(final String attributeName, final String action) {
-        fieldAttributeActions.put(attributeName, action);
-    }
-
-    public void addMethodAttributeAction(final String attributeName, final String action) {
-        methodAttributeActions.put(attributeName, action);
-    }
-
-    public void addCodeAttributeAction(final String attributeName, final String action) {
-        codeAttributeActions.put(attributeName, action);
-    }
-
-    public boolean isVerbose() {
-        return verbose;
-    }
-
-    public void setVerbose(final boolean verbose) {
-        this.verbose = verbose;
+    public void setEffort(final int effort) {
+        this.effort = effort;
     }
 
-    public void setQuiet(final boolean quiet) {
-        this.verbose = !quiet;
+    public void setGzip(final boolean gzip) {
+        this.gzip = gzip;
     }
 
-    public String getLogFile() {
-        return logFile;
+    public void setKeepFileOrder(final boolean keepFileOrder) {
+        this.keepFileOrder = keepFileOrder;
     }
 
     public void setLogFile(final String logFile) {
         this.logFile = logFile;
     }
 
-    private void addOrUpdateAttributeActions(final List<Attribute> prototypes, final Map<String, String> attributeActions, final int tag) {
-        if ((attributeActions != null) && (attributeActions.size() > 0)) {
-            NewAttribute newAttribute;
-            for (String name : attributeActions.keySet()) {
-                String action = attributeActions.get(name);
-                boolean prototypeExists = false;
-                for (Object prototype : prototypes) {
-                    newAttribute = (NewAttribute) prototype;
-                    if (newAttribute.type.equals(name)) {
-                        // if the attribute exists, update its context
-                        newAttribute.addContext(tag);
-                        prototypeExists = true;
-                        break;
-                    }
-                }
-                // if no attribute is found, add a new attribute
-                if (!prototypeExists) {
-                    if (ERROR.equals(action)) {
-                        newAttribute = new NewAttribute.ErrorAttribute(name, tag);
-                    } else if (STRIP.equals(action)) {
-                        newAttribute = new NewAttribute.StripAttribute(name, tag);
-                    } else if (PASS.equals(action)) {
-                        newAttribute = new NewAttribute.PassAttribute(name, tag);
-                    } else {
-                        newAttribute = new NewAttribute(name, action, tag);
-                    }
-                    prototypes.add(newAttribute);
-                }
-            }
+    public void setModificationTime(final String modificationTime) {
+        if (!KEEP.equals(modificationTime) && !"latest".equals(modificationTime)) {
+            throw new IllegalArgumentException("Bad argument: -m " + modificationTime
+                + " ? transmit modtimes should be either latest or keep (default)");
         }
+        this.modificationTime = modificationTime;
     }
 
-    public Attribute[] getUnknownAttributePrototypes() {
-        if (unknownAttributeTypes == null) {
-            final List<Attribute> prototypes = new ArrayList<>();
-            addOrUpdateAttributeActions(prototypes, classAttributeActions, AttributeDefinitionBands.CONTEXT_CLASS);
-            addOrUpdateAttributeActions(prototypes, methodAttributeActions, AttributeDefinitionBands.CONTEXT_METHOD);
-            addOrUpdateAttributeActions(prototypes, fieldAttributeActions, AttributeDefinitionBands.CONTEXT_FIELD);
-            addOrUpdateAttributeActions(prototypes, codeAttributeActions, AttributeDefinitionBands.CONTEXT_CODE);
-            unknownAttributeTypes = prototypes.toArray(new Attribute[0]);
-        }
-        return unknownAttributeTypes;
+    public void setQuiet(final boolean quiet) {
+        this.verbose = !quiet;
     }
 
-    public String getUnknownClassAttributeAction(final String type) {
-        if (classAttributeActions == null) {
-            return unknownAttributeAction;
-        }
-        return classAttributeActions.getOrDefault(type, unknownAttributeAction);
+    /**
+     * Set the segment limit (equivalent to -S command line option)
+     *
+     * @param segmentLimit - the limit in bytes
+     */
+    public void setSegmentLimit(final long segmentLimit) {
+        this.segmentLimit = segmentLimit;
     }
 
-    public String getUnknownMethodAttributeAction(final String type) {
-        if (methodAttributeActions == null) {
-            return unknownAttributeAction;
-        }
-        return methodAttributeActions.getOrDefault(type, unknownAttributeAction);
+    /**
+     * Set strip debug attributes. If true, all debug attributes (i.e. LineNumberTable, SourceFile, LocalVariableTable
+     * and LocalVariableTypeTable attributes) are stripped when reading the input class files and not included in the
+     * output archive.
+     *
+     * @param stripDebug If true, all debug attributes.
+     */
+    public void setStripDebug(final boolean stripDebug) {
+        this.stripDebug = stripDebug;
     }
 
-    public String getUnknownFieldAttributeAction(final String type) {
-        if (fieldAttributeActions == null) {
-            return unknownAttributeAction;
+    /**
+     * Tell the compressor what to do if an unknown attribute is encountered
+     *
+     * @param unknownAttributeAction - the action to perform
+     */
+    public void setUnknownAttributeAction(final String unknownAttributeAction) {
+        this.unknownAttributeAction = unknownAttributeAction;
+        if (!PASS.equals(unknownAttributeAction) && !ERROR.equals(unknownAttributeAction)
+            && !STRIP.equals(unknownAttributeAction)) {
+            throw new RuntimeException("Incorrect option for -U, " + unknownAttributeAction);
         }
-        return fieldAttributeActions.getOrDefault(type, unknownAttributeAction);
     }
 
-    public String getUnknownCodeAttributeAction(final String type) {
-        if (codeAttributeActions == null) {
-            return unknownAttributeAction;
-        }
-        return codeAttributeActions.getOrDefault(type, unknownAttributeAction);
+    public void setVerbose(final boolean verbose) {
+        this.verbose = verbose;
     }
 
 }