01: package org.slf4j.migrator.line;
02:
03: import java.util.ArrayList;
04: import java.util.Iterator;
05: import java.util.regex.Pattern;
06:
07: public class Log4jRuleSet implements RuleSet {
08:
09: private ArrayList<ConversionRule> conversionRuleList;
10:
11: public Log4jRuleSet() {
12:
13: SingleConversionRule crImport0 = new SingleConversionRule(
14: Pattern.compile("import\\s*+org.apache.log4j.Logger;"),
15: "import org.slf4j.Logger;",
16: "import org.slf4j.LoggerFactory;");
17:
18: SingleConversionRule crImport1 = new SingleConversionRule(
19: Pattern
20: .compile("import\\s*+org.apache.log4j.LogManager;"),
21: "import org.slf4j.LoggerFactory;");
22:
23: SingleConversionRule crImport2 = new SingleConversionRule(
24: Pattern.compile("import\\s*+org.apache.log4j.*;"),
25: "import org.slf4j.Logger;",
26: "import org.slf4j.LoggerFactory;");
27:
28: SingleConversionRule crImportMDC = new SingleConversionRule(
29: Pattern.compile("import\\s*+org.apache.log4j.MDC;"),
30: "import org.slf4j.MDC;");
31:
32: SingleConversionRule crFactory0 = new SingleConversionRule(
33: Pattern.compile("Logger.getLogger\\("),
34: "LoggerFactory.getLogger(");
35:
36: SingleConversionRule crFactory1 = new SingleConversionRule(
37: Pattern.compile("LogManager.getLogger\\("),
38: "LoggerFactory.getLogger(");
39:
40: conversionRuleList = new ArrayList<ConversionRule>();
41: conversionRuleList.add(crImport0);
42: conversionRuleList.add(crImport1);
43: conversionRuleList.add(crImport2);
44: conversionRuleList.add(crImportMDC);
45: conversionRuleList.add(crFactory0);
46: conversionRuleList.add(crFactory1);
47: }
48:
49: public Iterator<ConversionRule> iterator() {
50: return conversionRuleList.iterator();
51: }
52:
53: }
|