jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1700116 - in /jmeter/trunk/src: core/org/apache/jmeter/ core/org/apache/jmeter/gui/util/ jorphan/org/apache/jorphan/gui/ jorphan/org/apache/jorphan/reflect/ jorphan/org/apache/jorphan/util/
Date Sun, 30 Aug 2015 13:12:17 GMT
Author: fschumacher
Date: Sun Aug 30 13:12:16 2015
New Revision: 1700116

URL: http://svn.apache.org/r1700116
Log:
Convert to for-loop. Based on Patch part 2 from Graham Russell.
It contains one renaming of a local variable from laf to a menuItem and a bit of white space
policeing.

Bugzilla Id: 57981

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/JMeter.java
    jmeter/trunk/src/core/org/apache/jmeter/gui/util/FileListPanel.java
    jmeter/trunk/src/core/org/apache/jmeter/gui/util/JLabeledRadioI18N.java
    jmeter/trunk/src/core/org/apache/jmeter/gui/util/JMeterMenuBar.java
    jmeter/trunk/src/core/org/apache/jmeter/gui/util/JMeterToolBar.java
    jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuFactory.java
    jmeter/trunk/src/jorphan/org/apache/jorphan/gui/JLabeledChoice.java
    jmeter/trunk/src/jorphan/org/apache/jorphan/gui/JLabeledTextArea.java
    jmeter/trunk/src/jorphan/org/apache/jorphan/gui/JLabeledTextField.java
    jmeter/trunk/src/jorphan/org/apache/jorphan/reflect/ClassFinder.java
    jmeter/trunk/src/jorphan/org/apache/jorphan/reflect/Functor.java
    jmeter/trunk/src/jorphan/org/apache/jorphan/util/JOrphanUtils.java

Modified: jmeter/trunk/src/core/org/apache/jmeter/JMeter.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/JMeter.java?rev=1700116&r1=1700115&r2=1700116&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/JMeter.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/JMeter.java Sun Aug 30 13:12:16 2015
@@ -34,7 +34,6 @@ import java.text.SimpleDateFormat;
 import java.util.Collection;
 import java.util.Date;
 import java.util.Enumeration;
-import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Locale;
@@ -593,10 +592,7 @@ public class JMeter implements JMeterPlu
         // These can potentially occur multiple times
 
         List<CLOption> clOptions = parser.getArguments();
-        int size = clOptions.size();
-
-        for (int i = 0; i < size; i++) {
-            CLOption option = clOptions.get(i);
+        for (CLOption option : clOptions) {
             String name = option.getArgument(0);
             String value = option.getArgument(1);
             FileInputStream fis = null;
@@ -760,8 +756,7 @@ public class JMeter implements JMeterPlu
                     new SearchByClass<>(ReplaceableController.class);
             tree.traverse(replaceableControllers);
             Collection<ReplaceableController> replaceableControllersRes = replaceableControllers.getSearchResults();
-            for (Iterator<ReplaceableController> iter = replaceableControllersRes.iterator();
iter.hasNext();) {
-                ReplaceableController replaceableController = iter.next();
+            for (ReplaceableController replaceableController : replaceableControllersRes)
{
                 replaceableController.resolveReplacementSubTree(root);
             }
 

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/util/FileListPanel.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/util/FileListPanel.java?rev=1700116&r1=1700115&r2=1700116&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/util/FileListPanel.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/util/FileListPanel.java Sun Aug 30 13:12:16
2015
@@ -207,8 +207,8 @@ public class FileListPanel extends JPane
             chooser.showOpenDialog(GuiPackage.getInstance().getMainFrame());
             File[] cfiles = chooser.getSelectedFiles();
             if (cfiles != null) {
-                for (int idx=0; idx < cfiles.length; idx++) {
-                    this.addFilename(cfiles[idx].getPath());
+                for (File cfile : cfiles) {
+                    this.addFilename(cfile.getPath());
                 }
                 fireFileChanged();
             }

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/util/JLabeledRadioI18N.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/util/JLabeledRadioI18N.java?rev=1700116&r1=1700115&r2=1700116&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/util/JLabeledRadioI18N.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/util/JLabeledRadioI18N.java Sun Aug 30 13:12:16
2015
@@ -101,15 +101,15 @@ public class JLabeledRadioI18N extends J
      *
      */
     private void initButtonGroup(String[] resouces, String selected) {
-        for (int idx = 0; idx < resouces.length; idx++) {
-            JRadioButton btn = new JRadioButton(JMeterUtils.getResString(resouces[idx]));
-            btn.setActionCommand(resouces[idx]);
+        for (String resource : resouces) {
+            JRadioButton btn = new JRadioButton(JMeterUtils.getResString(resource));
+            btn.setActionCommand(resource);
             btn.addActionListener(this);
             // add the button to the button group
             this.bGroup.add(btn);
             // add the button
             this.add(btn);
-            if (selected != null && selected.equals(resouces[idx])) {
+            if (selected != null && selected.equals(resource)) {
                 btn.setSelected(true);
             }
         }
@@ -195,8 +195,8 @@ public class JLabeledRadioI18N extends J
      */
     private void notifyChangeListeners() {
         ChangeEvent ce = new ChangeEvent(this);
-        for (int index = 0; index < mChangeListeners.size(); index++) {
-            mChangeListeners.get(index).stateChanged(ce);
+        for (ChangeListener mChangeListener : mChangeListeners) {
+            mChangeListener.stateChanged(ce);
         }
     }
 

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/util/JMeterMenuBar.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/util/JMeterMenuBar.java?rev=1700116&r1=1700115&r2=1700116&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/util/JMeterMenuBar.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/util/JMeterMenuBar.java Sun Aug 30 13:12:16
2015
@@ -213,8 +213,8 @@ public class JMeterMenuBar extends JMenu
         if (menu != null) {
             editMenu.removeAll();
             Component[] comps = menu.getComponents();
-            for (int i = 0; i < comps.length; i++) {
-                editMenu.add(comps[i]);
+            for (Component comp : comps) {
+                editMenu.add(comp);
             }
             editMenu.setEnabled(true);
         } else {
@@ -275,8 +275,7 @@ public class JMeterMenuBar extends JMenu
         this.add(searchMenu);
         this.add(runMenu);
         this.add(optionsMenu);
-        for (Iterator<MenuCreator> iterator = menuCreators.iterator(); iterator.hasNext();)
{
-            MenuCreator menuCreator = iterator.next();
+        for (MenuCreator menuCreator : menuCreators) {
             JMenu[] topLevelMenus = menuCreator.getTopLevelMenus();
             for (JMenu topLevelMenu : topLevelMenus) {
                 this.add(topLevelMenu);                
@@ -320,13 +319,12 @@ public class JMeterMenuBar extends JMenu
         JMenuItem functionHelper = makeMenuItemRes("function_dialog_menu_item", 'F', ActionNames.FUNCTIONS,
KeyStrokes.FUNCTIONS); //$NON-NLS-1$
 
         lafMenu = makeMenuRes("appearance",'L'); //$NON-NLS-1$
-        UIManager.LookAndFeelInfo lafs[] = getAllLAFs();
-        for (int i = 0; i < lafs.length; ++i) {
-            JMenuItem laf = new JMenuItem(lafs[i].getName());
-            laf.addActionListener(ActionRouter.getInstance());
-            laf.setActionCommand(ActionNames.LAF_PREFIX + lafs[i].getClassName());
-            laf.setToolTipText(lafs[i].getClassName()); // show the classname to the user
-            lafMenu.add(laf);
+        for (LookAndFeelInfo laf : getAllLAFs()) {
+            JMenuItem menuItem = new JMenuItem(laf.getName());
+            menuItem.addActionListener(ActionRouter.getInstance());
+            menuItem.setActionCommand(ActionNames.LAF_PREFIX + laf.getClassName());
+            menuItem.setToolTipText(laf.getClassName()); // show the classname to the user
+            lafMenu.add(menuItem);
         }
         optionsMenu.add(functionHelper);
         optionsMenu.add(lafMenu);
@@ -724,10 +722,8 @@ public class JMeterMenuBar extends JMenu
             }
         }
 
-        MenuElement[] subelements = menu.getSubElements();
-
-        for (int i = 0; i < subelements.length; i++) {
-            updateMenuElement(subelements[i]);
+        for (MenuElement subElement : menu.getSubElements()) {
+            updateMenuElement(subElement);
         }
     }
 

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/util/JMeterToolBar.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/util/JMeterToolBar.java?rev=1700116&r1=1700115&r2=1700116&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/util/JMeterToolBar.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/util/JMeterToolBar.java Sun Aug 30 13:12:16
2015
@@ -205,9 +205,9 @@ public class JMeterToolBar extends JTool
     private Map<String, Boolean> getCurrentButtonsStates() {
         Component[] components = getComponents();
         Map<String, Boolean> buttonStates = new HashMap<>(components.length);
-        for (int i = 0; i < components.length; i++) {
-            if (components[i] instanceof JButton) {
-                JButton button = (JButton) components[i];
+        for (Component component : components) {
+            if (component instanceof JButton) {
+                JButton button = (JButton) component;
                 buttonStates.put(button.getActionCommand(), Boolean.valueOf(button.isEnabled()));
             }
         }
@@ -286,10 +286,9 @@ public class JMeterToolBar extends JTool
      *            {@link Map} of button names and their states
      */
     private void updateButtons(Map<String, Boolean> buttonStates) {
-        Component[] components = getComponents();
-        for (int i = 0; i < components.length; i++) {
-            if (components[i] instanceof JButton) {
-                JButton button = (JButton) components[i];
+        for (Component component : getComponents()) {
+            if (component instanceof JButton) {
+                JButton button = (JButton) component;
                 Boolean enabled = buttonStates.get(button.getActionCommand());
                 if (enabled != null) {
                     button.setEnabled(enabled.booleanValue());

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuFactory.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuFactory.java?rev=1700116&r1=1700115&r2=1700116&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuFactory.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuFactory.java Sun Aug 30 13:12:16
2015
@@ -152,8 +152,8 @@ public final class MenuFactory {
         try {
             String[] classesToSkip =
                 JOrphanUtils.split(JMeterUtils.getPropDefault("not_in_menu", ""), ","); //$NON-NLS-1$
-            for (int i = 0; i < classesToSkip.length; i++) {
-                elementsToSkip.add(classesToSkip[i].trim());
+            for (String aClassesToSkip : classesToSkip) {
+                elementsToSkip.add(aClassesToSkip.trim());
             }
 
             initializeMenus();
@@ -269,8 +269,8 @@ public final class MenuFactory {
 
     public static JMenu makeMenus(String[] categories, String label, String actionCommand)
{
         JMenu addMenu = new JMenu(label);
-        for (int i = 0; i < categories.length; i++) {
-            addMenu.add(makeMenu(categories[i], actionCommand));
+        for (String category : categories) {
+            addMenu.add(makeMenu(category, actionCommand));
         }
         GuiUtils.makeScrollableMenu(addMenu);
         return addMenu;
@@ -648,10 +648,9 @@ public final class MenuFactory {
 
     // Is any node an instance of one of the classes?
     private static boolean foundClass(JMeterTreeNode nodes[],Class<?> classes[]){
-        for (int i = 0; i < nodes.length; i++) {
-            JMeterTreeNode node = nodes[i];
-            for (int j=0; j < classes.length; j++) {
-                if (classes[j].isInstance(node.getUserObject())){
+        for (JMeterTreeNode node : nodes) {
+            for (Class<?> aClass : classes) {
+                if (aClass.isInstance(node.getUserObject())) {
                     return true;
                 }
             }
@@ -661,12 +660,11 @@ public final class MenuFactory {
 
     // Is any node an instance of one of the classes, but not an exception?
     private static boolean foundClass(JMeterTreeNode nodes[],Class<?> classes[], Class<?>
except){
-        for (int i = 0; i < nodes.length; i++) {
-            JMeterTreeNode node = nodes[i];
+        for (JMeterTreeNode node : nodes) {
             Object userObject = node.getUserObject();
             if (!except.isInstance(userObject)) {
-                for (int j=0; j < classes.length; j++) {
-                    if (classes[j].isInstance(userObject)){
+                for (Class<?> aClass : classes) {
+                    if (aClass.isInstance(userObject)) {
                         return true;
                     }
                 }

Modified: jmeter/trunk/src/jorphan/org/apache/jorphan/gui/JLabeledChoice.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/jorphan/org/apache/jorphan/gui/JLabeledChoice.java?rev=1700116&r1=1700115&r2=1700116&view=diff
==============================================================================
--- jmeter/trunk/src/jorphan/org/apache/jorphan/gui/JLabeledChoice.java (original)
+++ jmeter/trunk/src/jorphan/org/apache/jorphan/gui/JLabeledChoice.java Sun Aug 30 13:12:16
2015
@@ -111,8 +111,8 @@ public class JLabeledChoice extends JPan
 
     public void setValues(String[] items) {
         choiceList.removeAllItems();
-        for (int i = 0; i < items.length; i++) {
-            choiceList.addItem(items[i]);
+        for (String item : items) {
+            choiceList.addItem(item);
         }
     }
 
@@ -277,8 +277,8 @@ public String getToolTipText() {
      */
     private void notifyChangeListeners() {
         ChangeEvent ce = new ChangeEvent(this);
-        for (int index = 0; index < mChangeListeners.size(); index++) {
-            mChangeListeners.get(index).stateChanged(ce);
+        for (ChangeListener mChangeListener : mChangeListeners) {
+            mChangeListener.stateChanged(ce);
         }
     }
 

Modified: jmeter/trunk/src/jorphan/org/apache/jorphan/gui/JLabeledTextArea.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/jorphan/org/apache/jorphan/gui/JLabeledTextArea.java?rev=1700116&r1=1700115&r2=1700116&view=diff
==============================================================================
--- jmeter/trunk/src/jorphan/org/apache/jorphan/gui/JLabeledTextArea.java (original)
+++ jmeter/trunk/src/jorphan/org/apache/jorphan/gui/JLabeledTextArea.java Sun Aug 30 13:12:16
2015
@@ -243,8 +243,8 @@ public class JLabeledTextArea extends JP
      */
     private void notifyChangeListeners() {
         ChangeEvent ce = new ChangeEvent(this);
-        for (int index = 0; index < mChangeListeners.size(); index++) {
-            mChangeListeners.get(index).stateChanged(ce);
+        for (ChangeListener mChangeListener : mChangeListeners) {
+            mChangeListener.stateChanged(ce);
         }
     }
     

Modified: jmeter/trunk/src/jorphan/org/apache/jorphan/gui/JLabeledTextField.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/jorphan/org/apache/jorphan/gui/JLabeledTextField.java?rev=1700116&r1=1700115&r2=1700116&view=diff
==============================================================================
--- jmeter/trunk/src/jorphan/org/apache/jorphan/gui/JLabeledTextField.java (original)
+++ jmeter/trunk/src/jorphan/org/apache/jorphan/gui/JLabeledTextField.java Sun Aug 30 13:12:16
2015
@@ -243,8 +243,8 @@ public class JLabeledTextField extends J
      */
     protected void notifyChangeListeners() {
         ChangeEvent ce = new ChangeEvent(this);
-        for (int index = 0; index < mChangeListeners.size(); index++) {
-            mChangeListeners.get(index).stateChanged(ce);
+        for (ChangeListener mChangeListener : mChangeListeners) {
+            mChangeListener.stateChanged(ce);
         }
     }
 }

Modified: jmeter/trunk/src/jorphan/org/apache/jorphan/reflect/ClassFinder.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/jorphan/org/apache/jorphan/reflect/ClassFinder.java?rev=1700116&r1=1700115&r2=1700116&view=diff
==============================================================================
--- jmeter/trunk/src/jorphan/org/apache/jorphan/reflect/ClassFinder.java (original)
+++ jmeter/trunk/src/jorphan/org/apache/jorphan/reflect/ClassFinder.java Sun Aug 30 13:12:16
2015
@@ -168,8 +168,7 @@ public final class ClassFinder {
     // For each directory in the search path, add all the jars found there
     private static String[] addJarsInPath(String[] paths) {
         Set<String> fullList = new HashSet<>();
-        for (int i = 0; i < paths.length; i++) {
-            final String path = paths[i];
+        for (final String path : paths) {
             fullList.add(path); // Keep the unexpanded path
             // TODO - allow directories to end with .jar by removing this check?
             if (!path.endsWith(DOT_JAR)) {
@@ -475,8 +474,8 @@ public final class ClassFinder {
                 Class<?> c = Class.forName(strClassName, false, contextClassLoader);
 
                 if (!c.isInterface() && !Modifier.isAbstract(c.getModifiers())) {
-                    for (int i=0; i< parentClasses.length; i++) {
-                        if(parentClasses[i].isAssignableFrom(c)){
+                    for (Class<?> parentClass : parentClasses) {
+                        if (parentClass.isAssignableFrom(c)) {
                             return true;
                         }
                     }
@@ -561,12 +560,12 @@ public final class ClassFinder {
 
     private static void findClassesInPathsDir(String strPathElement, File dir, Set<String>
listClasses) throws IOException {
         String[] list = dir.list();
-        for (int i = 0; i < list.length; i++) {
-            File file = new File(dir, list[i]);
+        for (String aList : list) {
+            File file = new File(dir, aList);
             if (file.isDirectory()) {
                 // Recursive call
                 findClassesInPathsDir(strPathElement, file, listClasses);
-            } else if (list[i].endsWith(DOT_CLASS) && file.exists() && (file.length()
!= 0)) {
+            } else if (aList.endsWith(DOT_CLASS) && file.exists() && (file.length()
!= 0)) {
                 final String path = file.getPath();
                 listClasses.add(path.substring(strPathElement.length() + 1,
                         path.lastIndexOf('.')) // $NON-NLS-1$

Modified: jmeter/trunk/src/jorphan/org/apache/jorphan/reflect/Functor.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/jorphan/org/apache/jorphan/reflect/Functor.java?rev=1700116&r1=1700115&r2=1700116&view=diff
==============================================================================
--- jmeter/trunk/src/jorphan/org/apache/jorphan/reflect/Functor.java (original)
+++ jmeter/trunk/src/jorphan/org/apache/jorphan/reflect/Functor.java Sun Aug 30 13:12:16 2015
@@ -349,8 +349,8 @@ public class Functor {
                         }
                     }
                     Class<?>[] interfaces = p_types[i].getInterfaces();
-                    for (int j = 0; j < interfaces.length; j++) {
-                        methodToInvoke = doCreateMethod(p_class,getNewArray(i, interfaces[j],
p_types));
+                    for (Class<?> anInterface : interfaces) {
+                        methodToInvoke = doCreateMethod(p_class, getNewArray(i, anInterface,
p_types));
                         if (methodToInvoke != null) {
                             return methodToInvoke;
                         }

Modified: jmeter/trunk/src/jorphan/org/apache/jorphan/util/JOrphanUtils.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/jorphan/org/apache/jorphan/util/JOrphanUtils.java?rev=1700116&r1=1700115&r2=1700116&view=diff
==============================================================================
--- jmeter/trunk/src/jorphan/org/apache/jorphan/util/JOrphanUtils.java (original)
+++ jmeter/trunk/src/jorphan/org/apache/jorphan/util/JOrphanUtils.java Sun Aug 30 13:12:16
2015
@@ -416,8 +416,8 @@ public final class JOrphanUtils {
      */
     public static String baToHexString(byte ba[]) {
         StringBuilder sb = new StringBuilder(ba.length*2);
-        for (int i = 0; i < ba.length; i++) {
-            int j = ba[i] & 0xff;
+        for (byte b : ba) {
+            int j = b & 0xff;
             if (j < 16) {
                 sb.append("0"); // $NON-NLS-1$ add zero padding
             }



Mime
View raw message