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/02 16:13:35 UTC

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

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 7df3689  Use NIO in test.
     new 2269789  Minor formatting.
     new 3a70bdf  Fix generics compiler warnings.
     new ee8ef33  Use Java 8 Map API.
     new f3c9448  Make some private instance variables final.

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   | 72 ++++++----------------
 1 file changed, 18 insertions(+), 54 deletions(-)

[commons-compress] 01/04: Minor formatting.

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 226978931752b58d505f81e36f7c0889ece34b6d
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Dec 1 18:22:55 2021 -0500

    Minor formatting.
---
 .../org/apache/commons/compress/harmony/pack200/PackingOptions.java     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 3495d70..69a884c 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
@@ -37,7 +37,7 @@ public class PackingOptions {
     private boolean gzip = true;
     private boolean stripDebug = false;
     private boolean keepFileOrder = true;
-    private long segmentLimit = 1000000L;
+    private long segmentLimit = 1_000_000L;
     private int effort = 5;
     private String deflateHint = KEEP;
     private String modificationTime = KEEP;

[commons-compress] 02/04: Fix generics compiler warnings.

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 3a70bdfab0e3b624d0e6910aaa7322ab56cfe763
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 2 10:53:52 2021 -0500

    Fix generics compiler warnings.
---
 .../compress/harmony/pack200/PackingOptions.java   | 50 +++++++++-------------
 1 file changed, 21 insertions(+), 29 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 69a884c..ccbc4ee 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
@@ -41,12 +41,12 @@ public class PackingOptions {
     private int effort = 5;
     private String deflateHint = KEEP;
     private String modificationTime = KEEP;
-    private List passFiles;
+    private List<String> passFiles;
     private String unknownAttributeAction = PASS;
-    private Map classAttributeActions;
-    private Map fieldAttributeActions;
-    private Map methodAttributeActions;
-    private Map codeAttributeActions;
+    private Map<String, String> classAttributeActions;
+    private Map<String, String> fieldAttributeActions;
+    private Map<String, String> methodAttributeActions;
+    private Map<String, String> codeAttributeActions;
     private boolean verbose = false;
     private String logFile;
 
@@ -139,8 +139,7 @@ public class PackingOptions {
 
     public boolean isPassFile(final String passFileName) {
         if (passFiles != null) {
-            for (Object passFile : passFiles) {
-                String pass = (String) passFile;
+            for (String pass : passFiles) {
                 if (passFileName.equals(pass)) {
                     return true;
                 }
@@ -167,7 +166,7 @@ public class PackingOptions {
      */
     public void addPassFile(String passFileName) {
         if (passFiles == null) {
-            passFiles = new ArrayList();
+            passFiles = new ArrayList<>();
         }
         String fileSeparator = System.getProperty("file.separator");
         if (fileSeparator.equals("\\")) {
@@ -201,28 +200,28 @@ public class PackingOptions {
 
     public void addClassAttributeAction(final String attributeName, final String action) {
         if (classAttributeActions == null) {
-            classAttributeActions = new HashMap();
+            classAttributeActions = new HashMap<>();
         }
         classAttributeActions.put(attributeName, action);
     }
 
     public void addFieldAttributeAction(final String attributeName, final String action) {
         if (fieldAttributeActions == null) {
-            fieldAttributeActions = new HashMap();
+            fieldAttributeActions = new HashMap<>();
         }
         fieldAttributeActions.put(attributeName, action);
     }
 
     public void addMethodAttributeAction(final String attributeName, final String action) {
         if (methodAttributeActions == null) {
-            methodAttributeActions = new HashMap();
+            methodAttributeActions = new HashMap<>();
         }
         methodAttributeActions.put(attributeName, action);
     }
 
     public void addCodeAttributeAction(final String attributeName, final String action) {
         if (codeAttributeActions == null) {
-            codeAttributeActions = new HashMap();
+            codeAttributeActions = new HashMap<>();
         }
         codeAttributeActions.put(attributeName, action);
     }
@@ -247,15 +246,12 @@ public class PackingOptions {
         this.logFile = logFile;
     }
 
-    private void addOrUpdateAttributeActions(final List prototypes, final Map attributeActions, final int tag) {
+    private void addOrUpdateAttributeActions(final List<Attribute> prototypes, final Map<String, String> attributeActions, final int tag) {
         if ((attributeActions != null) && (attributeActions.size() > 0)) {
-            String name, action;
-            boolean prototypeExists;
             NewAttribute newAttribute;
-            for (Object element : attributeActions.keySet()) {
-                name = (String) element;
-                action = (String) attributeActions.get(name);
-                prototypeExists = false;
+            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)) {
@@ -284,16 +280,12 @@ public class PackingOptions {
 
     public Attribute[] getUnknownAttributePrototypes() {
         if (unknownAttributeTypes == null) {
-            final List prototypes = new ArrayList();
+            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 = (Attribute[]) prototypes.toArray(new Attribute[0]);
+            unknownAttributeTypes = prototypes.toArray(new Attribute[0]);
         }
         return unknownAttributeTypes;
     }
@@ -302,7 +294,7 @@ public class PackingOptions {
         if (classAttributeActions == null) {
             return unknownAttributeAction;
         }
-        String action = (String) classAttributeActions.get(type);
+        String action = classAttributeActions.get(type);
         if (action == null) {
             action = unknownAttributeAction;
         }
@@ -313,7 +305,7 @@ public class PackingOptions {
         if (methodAttributeActions == null) {
             return unknownAttributeAction;
         }
-        String action = (String) methodAttributeActions.get(type);
+        String action = methodAttributeActions.get(type);
         if (action == null) {
             action = unknownAttributeAction;
         }
@@ -324,7 +316,7 @@ public class PackingOptions {
         if (fieldAttributeActions == null) {
             return unknownAttributeAction;
         }
-        String action = (String) fieldAttributeActions.get(type);
+        String action = fieldAttributeActions.get(type);
         if (action == null) {
             action = unknownAttributeAction;
         }
@@ -335,7 +327,7 @@ public class PackingOptions {
         if (codeAttributeActions == null) {
             return unknownAttributeAction;
         }
-        String action = (String) codeAttributeActions.get(type);
+        String action = codeAttributeActions.get(type);
         if (action == null) {
             action = unknownAttributeAction;
         }

[commons-compress] 03/04: Use Java 8 Map API.

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 ee8ef3345d5f62bee7c5fcb0651591fc7ecb9e75
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 2 11:00:02 2021 -0500

    Use Java 8 Map API.
---
 .../compress/harmony/pack200/PackingOptions.java   | 24 ++++------------------
 1 file changed, 4 insertions(+), 20 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 ccbc4ee..4c38702 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
@@ -294,44 +294,28 @@ public class PackingOptions {
         if (classAttributeActions == null) {
             return unknownAttributeAction;
         }
-        String action = classAttributeActions.get(type);
-        if (action == null) {
-            action = unknownAttributeAction;
-        }
-        return action;
+        return classAttributeActions.getOrDefault(type, unknownAttributeAction);
     }
 
     public String getUnknownMethodAttributeAction(final String type) {
         if (methodAttributeActions == null) {
             return unknownAttributeAction;
         }
-        String action = methodAttributeActions.get(type);
-        if (action == null) {
-            action = unknownAttributeAction;
-        }
-        return action;
+        return methodAttributeActions.getOrDefault(type, unknownAttributeAction);
     }
 
     public String getUnknownFieldAttributeAction(final String type) {
         if (fieldAttributeActions == null) {
             return unknownAttributeAction;
         }
-        String action = fieldAttributeActions.get(type);
-        if (action == null) {
-            action = unknownAttributeAction;
-        }
-        return action;
+        return fieldAttributeActions.getOrDefault(type, unknownAttributeAction);
     }
 
     public String getUnknownCodeAttributeAction(final String type) {
         if (codeAttributeActions == null) {
             return unknownAttributeAction;
         }
-        String action = codeAttributeActions.get(type);
-        if (action == null) {
-            action = unknownAttributeAction;
-        }
-        return action;
+        return codeAttributeActions.getOrDefault(type, unknownAttributeAction);
     }
 
 }

[commons-compress] 04/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 f3c944811f1e48dad48ad758199797caf24920a2
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 2 11:13:32 2021 -0500

    Make some private instance variables final.
---
 .../compress/harmony/pack200/PackingOptions.java     | 20 ++++----------------
 1 file changed, 4 insertions(+), 16 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 4c38702..0a46e68 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
@@ -43,10 +43,10 @@ public class PackingOptions {
     private String modificationTime = KEEP;
     private List<String> passFiles;
     private String unknownAttributeAction = PASS;
-    private Map<String, String> classAttributeActions;
-    private Map<String, String> fieldAttributeActions;
-    private Map<String, String> methodAttributeActions;
-    private Map<String, String> codeAttributeActions;
+    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 = false;
     private String logFile;
 
@@ -199,30 +199,18 @@ public class PackingOptions {
     }
 
     public void addClassAttributeAction(final String attributeName, final String action) {
-        if (classAttributeActions == null) {
-            classAttributeActions = new HashMap<>();
-        }
         classAttributeActions.put(attributeName, action);
     }
 
     public void addFieldAttributeAction(final String attributeName, final String action) {
-        if (fieldAttributeActions == null) {
-            fieldAttributeActions = new HashMap<>();
-        }
         fieldAttributeActions.put(attributeName, action);
     }
 
     public void addMethodAttributeAction(final String attributeName, final String action) {
-        if (methodAttributeActions == null) {
-            methodAttributeActions = new HashMap<>();
-        }
         methodAttributeActions.put(attributeName, action);
     }
 
     public void addCodeAttributeAction(final String attributeName, final String action) {
-        if (codeAttributeActions == null) {
-            codeAttributeActions = new HashMap<>();
-        }
         codeAttributeActions.put(attributeName, action);
     }