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: /**
08: * This class represents JCL to SLF4J conversion rules
09: *
10: * @author jean-noelcharpin
11: *
12: */
13: public class JCLRuleSet implements RuleSet {
14:
15: private ArrayList<ConversionRule> conversionRuleList;
16:
17: public JCLRuleSet() {
18: // matching : import org.apache.commons.logging.LogFactory;
19: SingleConversionRule cr0 = new SingleConversionRule(
20: Pattern
21: .compile("import\\s*+org.apache.commons.logging.LogFactory;"),
22: "import org.slf4j.LoggerFactory;");
23:
24: // matching : import org.apache.commons.logging.Log;
25: SingleConversionRule cr1 = new SingleConversionRule(Pattern
26: .compile("import\\s*+org.apache.commons.logging.Log;"),
27: "import org.slf4j.Logger;");
28:
29: SingleConversionRule cr2 = new SingleConversionRule(Pattern
30: .compile("(\\sLog\\b)"), " Logger");
31:
32: SingleConversionRule cr3 = new SingleConversionRule(Pattern
33: .compile("(^Log\\b)"), "Logger");
34:
35: SingleConversionRule cr4 = new SingleConversionRule(Pattern
36: .compile("LogFactory.getFactory\\(\\).getInstance\\("),
37: "LoggerFactory.getLogger(");
38:
39: SingleConversionRule cr5 = new SingleConversionRule(Pattern
40: .compile("LogFactory.getLog\\("),
41: "LoggerFactory.getLogger(");
42:
43: conversionRuleList = new ArrayList<ConversionRule>();
44: conversionRuleList.add(cr0);
45: conversionRuleList.add(cr1);
46: conversionRuleList.add(cr2);
47: conversionRuleList.add(cr3);
48: conversionRuleList.add(cr4);
49: conversionRuleList.add(cr5);
50: }
51:
52: public Iterator<ConversionRule> iterator() {
53: return conversionRuleList.iterator();
54: }
55: }
|