aboutsummaryrefslogtreecommitdiff
path: root/slf4j-migrator/src/main/java/org/slf4j/migrator
diff options
context:
space:
mode:
Diffstat (limited to 'slf4j-migrator/src/main/java/org/slf4j/migrator')
-rw-r--r--slf4j-migrator/src/main/java/org/slf4j/migrator/FileSelector.java6
-rw-r--r--slf4j-migrator/src/main/java/org/slf4j/migrator/InplaceFileConverter.java4
-rw-r--r--slf4j-migrator/src/main/java/org/slf4j/migrator/Main.java10
-rw-r--r--slf4j-migrator/src/main/java/org/slf4j/migrator/ProjectConverter.java27
-rw-r--r--slf4j-migrator/src/main/java/org/slf4j/migrator/helper/Abbreviator.java4
-rw-r--r--slf4j-migrator/src/main/java/org/slf4j/migrator/internal/MigratorFrame.java28
-rw-r--r--slf4j-migrator/src/main/java/org/slf4j/migrator/line/EmptyRuleSet.java2
-rw-r--r--slf4j-migrator/src/main/java/org/slf4j/migrator/line/JCLRuleSet.java4
-rw-r--r--slf4j-migrator/src/main/java/org/slf4j/migrator/line/JULRuleSet.java4
-rwxr-xr-xslf4j-migrator/src/main/java/org/slf4j/migrator/line/Log4jRuleSet.java4
-rw-r--r--slf4j-migrator/src/main/java/org/slf4j/migrator/line/MultiGroupConversionRule.java4
11 files changed, 39 insertions, 58 deletions
diff --git a/slf4j-migrator/src/main/java/org/slf4j/migrator/FileSelector.java b/slf4j-migrator/src/main/java/org/slf4j/migrator/FileSelector.java
index 71af29bd..0e8d13c8 100644
--- a/slf4j-migrator/src/main/java/org/slf4j/migrator/FileSelector.java
+++ b/slf4j-migrator/src/main/java/org/slf4j/migrator/FileSelector.java
@@ -32,7 +32,7 @@ import org.slf4j.migrator.internal.ProgressListener;
public class FileSelector {
- private List<File> javaFileList = new ArrayList<File>();
+ private final List<File> javaFileList = new ArrayList<>();
ProgressListener pl;
@@ -54,8 +54,8 @@ public class FileSelector {
pl.onDirectory(file);
File[] files = file.listFiles();
if (files != null) {
- for (int i = 0; i < files.length; i++) {
- selectFiles(files[i]);
+ for (File value : files) {
+ selectFiles(value);
}
}
} else {
diff --git a/slf4j-migrator/src/main/java/org/slf4j/migrator/InplaceFileConverter.java b/slf4j-migrator/src/main/java/org/slf4j/migrator/InplaceFileConverter.java
index d4bf3e63..cecb1be8 100644
--- a/slf4j-migrator/src/main/java/org/slf4j/migrator/InplaceFileConverter.java
+++ b/slf4j-migrator/src/main/java/org/slf4j/migrator/InplaceFileConverter.java
@@ -102,8 +102,8 @@ public class InplaceFileConverter {
}
private void writeReplacement(OutputStream os, String[] replacement) throws IOException {
- for (int i = 0; i < replacement.length; i++) {
- os.write(replacement[i].getBytes());
+ for (String s : replacement) {
+ os.write(s.getBytes());
os.write(lineTerminator.getBytes());
}
}
diff --git a/slf4j-migrator/src/main/java/org/slf4j/migrator/Main.java b/slf4j-migrator/src/main/java/org/slf4j/migrator/Main.java
index 5a94a41d..bbb1b9cc 100644
--- a/slf4j-migrator/src/main/java/org/slf4j/migrator/Main.java
+++ b/slf4j-migrator/src/main/java/org/slf4j/migrator/Main.java
@@ -38,12 +38,10 @@ public class Main {
public static void main(String[] args) {
System.out.println("Starting SLF4J Migrator");
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- MigratorFrame inst = new MigratorFrame();
- inst.setLocationRelativeTo(null);
- inst.setVisible(true);
- }
+ SwingUtilities.invokeLater(() -> {
+ MigratorFrame inst = new MigratorFrame();
+ inst.setLocationRelativeTo(null);
+ inst.setVisible(true);
});
}
diff --git a/slf4j-migrator/src/main/java/org/slf4j/migrator/ProjectConverter.java b/slf4j-migrator/src/main/java/org/slf4j/migrator/ProjectConverter.java
index 99f1a194..f7947577 100644
--- a/slf4j-migrator/src/main/java/org/slf4j/migrator/ProjectConverter.java
+++ b/slf4j-migrator/src/main/java/org/slf4j/migrator/ProjectConverter.java
@@ -27,7 +27,6 @@ package org.slf4j.migrator;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import javax.swing.SwingUtilities;
@@ -38,25 +37,23 @@ import org.slf4j.migrator.line.RuleSet;
public class ProjectConverter {
- private RuleSet ruleSet;
+ private final RuleSet ruleSet;
private List<ConversionException> exception;
ProgressListener progressListener;
- public static void main(String[] args) throws IOException {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- MigratorFrame inst = new MigratorFrame();
- inst.setLocationRelativeTo(null);
- inst.setVisible(true);
- }
+ public static void main(String[] args) {
+ SwingUtilities.invokeLater(() -> {
+ MigratorFrame inst = new MigratorFrame();
+ inst.setLocationRelativeTo(null);
+ inst.setVisible(true);
});
}
/**
* Ask for concrete matcher implementation depending on the conversion mode
* Ask for user confirmation to convert the selected source directory if valid
- * Ask for user confirmation in case of number of files to convert > 1000
+ * Ask for user confirmation in case of number of files to convert &gt; 1000
*
* @param conversionType
* @param progressListener
@@ -83,9 +80,7 @@ public class ProjectConverter {
*/
private void scanFileList(List<File> lstFiles) {
progressListener.onFileScanBegin();
- Iterator<File> itFile = lstFiles.iterator();
- while (itFile.hasNext()) {
- File currentFile = itFile.next();
+ for (File currentFile : lstFiles) {
progressListener.onFileScan(currentFile);
scanFile(currentFile);
}
@@ -108,16 +103,14 @@ public class ProjectConverter {
public void addException(ConversionException exc) {
if (exception == null) {
- exception = new ArrayList<ConversionException>();
+ exception = new ArrayList<>();
}
exception.add(exc);
}
public void printException() {
if (exception != null) {
- Iterator<ConversionException> iterator = exception.iterator();
- while (iterator.hasNext()) {
- ConversionException exc = (ConversionException) iterator.next();
+ for (ConversionException exc : exception) {
exc.print();
}
exception = null;
diff --git a/slf4j-migrator/src/main/java/org/slf4j/migrator/helper/Abbreviator.java b/slf4j-migrator/src/main/java/org/slf4j/migrator/helper/Abbreviator.java
index f2f9b35d..519a3f04 100644
--- a/slf4j-migrator/src/main/java/org/slf4j/migrator/helper/Abbreviator.java
+++ b/slf4j-migrator/src/main/java/org/slf4j/migrator/helper/Abbreviator.java
@@ -44,11 +44,11 @@ public class Abbreviator {
int firstIndex = filename.indexOf(folderSeparator, invariantPrefixLength);
if (firstIndex == -1) {
- // we cant't process this string
+ // we can't process this string
return filename;
}
StringBuilder buf = new StringBuilder(desiredLength);
- buf.append(filename.substring(0, firstIndex + 1));
+ buf.append(filename, 0, firstIndex + 1);
buf.append(FILLER);
int nextIndex = computeNextIndex(filename, firstIndex);
if (nextIndex != -1) {
diff --git a/slf4j-migrator/src/main/java/org/slf4j/migrator/internal/MigratorFrame.java b/slf4j-migrator/src/main/java/org/slf4j/migrator/internal/MigratorFrame.java
index 377ac6e5..3ab15c60 100644
--- a/slf4j-migrator/src/main/java/org/slf4j/migrator/internal/MigratorFrame.java
+++ b/slf4j-migrator/src/main/java/org/slf4j/migrator/internal/MigratorFrame.java
@@ -46,16 +46,6 @@ import javax.swing.WindowConstants;
import org.slf4j.migrator.Constant;
import org.slf4j.migrator.helper.SpringLayoutHelper;
-/**
- * This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
- * Builder, which is free for non-commercial use. If Jigloo is being used
- * commercially (ie, by a corporation, company or business for any purpose
- * whatever) then you should purchase a license for each developer using Jigloo.
- * Please visit www.cloudgarden.com for details. Use of Jigloo implies
- * acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN
- * PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR
- * ANY CORPORATE OR COMMERCIAL PURPOSE.
- */
public class MigratorFrame extends JFrame implements ActionListener {
private static final long serialVersionUID = 1L;
@@ -68,8 +58,8 @@ public class MigratorFrame extends JFrame implements ActionListener {
static final int X_SIZE = 700;
static final int Y_SIZE = 400;
- private SpringLayout layoutManager = new SpringLayout();
- private SpringLayoutHelper slh = new SpringLayoutHelper(layoutManager, BASIC_PADDING);
+ private final SpringLayout layoutManager = new SpringLayout();
+ private final SpringLayoutHelper slh = new SpringLayoutHelper(layoutManager, BASIC_PADDING);
private JLabel migrationLabel;
@@ -138,7 +128,7 @@ public class MigratorFrame extends JFrame implements ActionListener {
*/
private void constrainAll() {
- // contrain migration label
+ // constraints migration label
layoutManager.putConstraint(SpringLayout.WEST, migrationLabel, BASIC_PADDING, SpringLayout.EAST, this);
layoutManager.putConstraint(SpringLayout.NORTH, migrationLabel, BASIC_PADDING, SpringLayout.NORTH, this);
@@ -239,14 +229,14 @@ public class MigratorFrame extends JFrame implements ActionListener {
private void createAwareLabel() {
awareLabel = new JLabel();
- awareLabel.setText("<html>" + "<p>I am aware that this tool will directly modify all Java source files</p>"
- + "<p>in the selected folder without creating backup files.</p>" + "</html>");
+ awareLabel.setText("<html>" + "<p>I am aware that this tool will directly modify all Java source files"
+ + "<p>in the selected folder without creating backup files." + "</html>");
}
private void createWarningLabel() {
warningLabel = new JLabel();
- warningLabel.setText("<html>" + "<p><span color=\"red\">WARNING:</span> This SLF4J migration tool will directly modify all Java source files</p>"
- + "<p>in the selected project folder without creating a backup of the original files.</p>" + "</html>");
+ warningLabel.setText("<html>" + "<p><span color=\"red\">WARNING:</span> This SLF4J migration tool will directly modify all Java source files"
+ + "<p>in the selected project folder without creating a backup of the original files." + "</html>");
}
private void createMigrateButton() {
@@ -323,7 +313,7 @@ public class MigratorFrame extends JFrame implements ActionListener {
List<String> doSanityAnalysis() {
- List<String> errorList = new ArrayList<String>();
+ List<String> errorList = new ArrayList<>();
if (!radioJCL.isSelected() && !radioLog4j.isSelected() && !radioJUL.isSelected()) {
errorList.add("Please select the migration type: JCL, log4j, or JUL to SLF4J.");
}
@@ -351,7 +341,7 @@ public class MigratorFrame extends JFrame implements ActionListener {
buf.append(i);
buf.append(". ");
buf.append(msg);
- buf.append("</p>");
+ buf.append("");
i++;
}
buf.append("</html>");
diff --git a/slf4j-migrator/src/main/java/org/slf4j/migrator/line/EmptyRuleSet.java b/slf4j-migrator/src/main/java/org/slf4j/migrator/line/EmptyRuleSet.java
index a0393265..3533d0e3 100644
--- a/slf4j-migrator/src/main/java/org/slf4j/migrator/line/EmptyRuleSet.java
+++ b/slf4j-migrator/src/main/java/org/slf4j/migrator/line/EmptyRuleSet.java
@@ -30,7 +30,7 @@ import java.util.List;
public class EmptyRuleSet implements RuleSet {
- List<ConversionRule> list = new ArrayList<ConversionRule>();
+ List<ConversionRule> list = new ArrayList<>();
public Iterator<ConversionRule> iterator() {
return list.iterator();
diff --git a/slf4j-migrator/src/main/java/org/slf4j/migrator/line/JCLRuleSet.java b/slf4j-migrator/src/main/java/org/slf4j/migrator/line/JCLRuleSet.java
index f463e46d..8367d508 100644
--- a/slf4j-migrator/src/main/java/org/slf4j/migrator/line/JCLRuleSet.java
+++ b/slf4j-migrator/src/main/java/org/slf4j/migrator/line/JCLRuleSet.java
@@ -36,7 +36,7 @@ import java.util.regex.Pattern;
*/
public class JCLRuleSet implements RuleSet {
- private ArrayList<ConversionRule> conversionRuleList;
+ private final ArrayList<ConversionRule> conversionRuleList;
public JCLRuleSet() {
// matching : import org.apache.commons.logging.LogFactory;
@@ -54,7 +54,7 @@ public class JCLRuleSet implements RuleSet {
SingleConversionRule cr5 = new SingleConversionRule(Pattern.compile("LogFactory.getLog\\("), "LoggerFactory.getLogger(");
- conversionRuleList = new ArrayList<ConversionRule>();
+ conversionRuleList = new ArrayList<>();
conversionRuleList.add(cr0);
conversionRuleList.add(cr1);
conversionRuleList.add(cr2);
diff --git a/slf4j-migrator/src/main/java/org/slf4j/migrator/line/JULRuleSet.java b/slf4j-migrator/src/main/java/org/slf4j/migrator/line/JULRuleSet.java
index b296b70a..da5f3378 100644
--- a/slf4j-migrator/src/main/java/org/slf4j/migrator/line/JULRuleSet.java
+++ b/slf4j-migrator/src/main/java/org/slf4j/migrator/line/JULRuleSet.java
@@ -36,7 +36,7 @@ import java.util.regex.Pattern;
*/
public class JULRuleSet implements RuleSet {
- private ArrayList<ConversionRule> conversionRuleList;
+ private final ArrayList<ConversionRule> conversionRuleList;
public JULRuleSet() {
@@ -55,7 +55,7 @@ public class JULRuleSet implements RuleSet {
SingleConversionRule crWarning = new SingleConversionRule(Pattern.compile("\\.warning\\("), ".warn(");
SingleConversionRule crSevere = new SingleConversionRule(Pattern.compile("\\.severe\\("), ".error(");
- conversionRuleList = new ArrayList<ConversionRule>();
+ conversionRuleList = new ArrayList<>();
conversionRuleList.add(crImport0);
conversionRuleList.add(crImport1);
conversionRuleList.add(crImport2);
diff --git a/slf4j-migrator/src/main/java/org/slf4j/migrator/line/Log4jRuleSet.java b/slf4j-migrator/src/main/java/org/slf4j/migrator/line/Log4jRuleSet.java
index c760496c..e07aa73a 100755
--- a/slf4j-migrator/src/main/java/org/slf4j/migrator/line/Log4jRuleSet.java
+++ b/slf4j-migrator/src/main/java/org/slf4j/migrator/line/Log4jRuleSet.java
@@ -30,7 +30,7 @@ import java.util.regex.Pattern;
public class Log4jRuleSet implements RuleSet {
- private ArrayList<ConversionRule> conversionRuleList;
+ private final ArrayList<ConversionRule> conversionRuleList;
public Log4jRuleSet() {
@@ -57,7 +57,7 @@ public class Log4jRuleSet implements RuleSet {
SingleConversionRule variable1 = new SingleConversionRule(Pattern.compile("(^Category\\b)"), "Logger");
- conversionRuleList = new ArrayList<ConversionRule>();
+ conversionRuleList = new ArrayList<>();
conversionRuleList.add(crImport0);
conversionRuleList.add(catImport);
conversionRuleList.add(crImport1);
diff --git a/slf4j-migrator/src/main/java/org/slf4j/migrator/line/MultiGroupConversionRule.java b/slf4j-migrator/src/main/java/org/slf4j/migrator/line/MultiGroupConversionRule.java
index ce1ee520..f0769406 100644
--- a/slf4j-migrator/src/main/java/org/slf4j/migrator/line/MultiGroupConversionRule.java
+++ b/slf4j-migrator/src/main/java/org/slf4j/migrator/line/MultiGroupConversionRule.java
@@ -40,8 +40,8 @@ public class MultiGroupConversionRule implements ConversionRule {
// our conversion reg-expressions
final private static int MAX_GROUPS = 10;
- private Pattern pattern;
- private String[] replacementTable = new String[MAX_GROUPS];
+ private final Pattern pattern;
+ private final String[] replacementTable = new String[MAX_GROUPS];
public MultiGroupConversionRule(Pattern pattern) {
this.pattern = pattern;