[slf4j-dev] svn commit: r887 - slf4j/trunk/slf4j-converter/src/main/java/org/slf4j/converter
ceki at slf4j.org
ceki at slf4j.org
Thu Aug 30 00:37:38 CEST 2007
Author: ceki
Date: Thu Aug 30 00:37:37 2007
New Revision: 887
Modified:
slf4j/trunk/slf4j-converter/src/main/java/org/slf4j/converter/JCLMatcher.java
Log:
Exactly the same logic.
I just reorganized code so that related logic is kept together.
Modified: slf4j/trunk/slf4j-converter/src/main/java/org/slf4j/converter/JCLMatcher.java
==============================================================================
--- slf4j/trunk/slf4j-converter/src/main/java/org/slf4j/converter/JCLMatcher.java (original)
+++ slf4j/trunk/slf4j-converter/src/main/java/org/slf4j/converter/JCLMatcher.java Thu Aug 30 00:37:37 2007
@@ -14,69 +14,79 @@
// matching : import org.apache.commons.logging.LogFactory;
PatternWrapper p0 = new PatternWrapper(Pattern
.compile("import\\s*+org.apache.commons.logging.LogFactory;"));
+ p0.addReplacement(Constant.INDEX_0, "import org.slf4j.LoggerFactory;");
+
// matching : import org.apache.commons.logging.Log;
PatternWrapper p1 = new PatternWrapper(Pattern
.compile("import\\s*+org.apache.commons.logging.Log;"));
+ p1.addReplacement(Constant.INDEX_0, "import org.slf4j.Logger;");
+
// matching declaration and instanciation : protected Log myLog =
// LogFactory.getFactory().getInstance(MyClass.class); //comment or other
// instruction
PatternWrapper p2 = new PatternWrapper(
Pattern
.compile("((\\w*+\\W*+\\.*)*;*+)(Log)(\\s+\\w+\\s*+=\\s*+)(LogFactory.getFactory\\(\\).getInstance\\()(\\w+)(.class\\);)((\\w*+\\W*+\\.*)*;*+)"));
+ p2.addReplacement(Constant.INDEX_3, "Logger");
+ p2.addReplacement(Constant.INDEX_2, "");
+ p2.addReplacement(Constant.INDEX_5, "LoggerFactory.getLogger(");
+
// matching declaration and instanciation : protected static Log myLog =
// LogFactory.getLog(MyClass.class); //comment or other instruction
PatternWrapper p3 = new PatternWrapper(
Pattern
.compile("((\\w*+\\W*+\\.*)*;*+)(Log)(\\s+\\w+\\s*+=\\s*+)(LogFactory.getLog\\()(\\w+)(.class\\);)((\\w*+\\W*+\\.*)*;*+)"));
+ p3.addReplacement(Constant.INDEX_3, "Logger");
+ p3.addReplacement(Constant.INDEX_2, "");
+ p3.addReplacement(Constant.INDEX_5, "LoggerFactory.getLogger(");
+
// matching instanciation without declaration : myLog =
// LogFactory.getFactory().getInstance(MyClass.class); //comment or other
// instruction
PatternWrapper p4 = new PatternWrapper(
Pattern
.compile("((\\w*+\\W*+\\.*)*;*+)(\\w+\\s*+=\\s*+)(LogFactory.getFactory\\(\\).getInstance\\()(\\w+)(.class\\);)((\\w*+\\W*+\\.*)*;*+)"));
+ p4.addReplacement(Constant.INDEX_4, "LoggerFactory.getLogger(");
+ p4.addReplacement(Constant.INDEX_2, "");
+
// matching instanciation without declaration : myLog =
// LogFactory.getLog(MyClass.class); //comment or other instruction
PatternWrapper p5 = new PatternWrapper(
Pattern
.compile("((\\w*+\\W*+\\.*)*;*+)(\\w+\\s*+=\\s*+)(LogFactory.getLog\\()(\\w+)(.class\\);)((\\w*+\\W*+\\.*)*;*+)"));
+ p5.addReplacement(Constant.INDEX_4, "LoggerFactory.getLogger(");
+ p5.addReplacement(Constant.INDEX_2, "");
+
// matching declaration without instanciation : public static final Log
// myLog //comment or other instruction
PatternWrapper p6 = new PatternWrapper(
Pattern
.compile("((\\w*+\\W*+\\.*)*;*+)(Log)(\\s*+\\w+\\s*+;)((\\w*+\\W*+\\.*)*;*+)"));
+ p6.addReplacement(Constant.INDEX_3, "Logger");
+ p6.addReplacement(Constant.INDEX_2, "");
+
+
// matching incomplete instanciation : protected Log log =
PatternWrapper p7 = new PatternWrapper(Pattern
.compile("((\\w*+\\W*+\\.*)*;*+)(Log)(\\s+\\w+\\s*+=*\\s*+)"));
+ p7.addReplacement(Constant.INDEX_3, "Logger");
+ p7.addReplacement(Constant.INDEX_2, "");
+
// matching incomlete instanciation : LogFactory.getLog(MyComponent.class);
PatternWrapper p8 = new PatternWrapper(
Pattern
.compile("((\\w*+\\W*+\\.*)*;*+)(LogFactory.getLog\\()(\\w+)(.class\\);)((\\w*+\\W*+\\.*)*;*+)"));
+ p8.addReplacement(Constant.INDEX_3, "LoggerFactory.getLogger(");
+ p8.addReplacement(Constant.INDEX_1, "");
+
// matching incomlete instanciation :
// LogFactory.getFactory().getInstance(MyComponent.class);
PatternWrapper p9 = new PatternWrapper(
Pattern
.compile("((\\w*+\\W*+\\.*)*;*+)(LogFactory.getFactory\\(\\).getInstance\\()(\\w+)(.class\\);)((\\w*+\\W*+\\.*)*;*+)"));
-
- p0.addReplacement(Constant.INDEX_0, "import org.slf4j.LoggerFactory;");
- p1.addReplacement(Constant.INDEX_0, "import org.slf4j.Logger;");
- p2.addReplacement(Constant.INDEX_3, "Logger");
- p2.addReplacement(Constant.INDEX_2, "");
- p2.addReplacement(Constant.INDEX_5, "LoggerFactory.getLogger(");
- p3.addReplacement(Constant.INDEX_3, "Logger");
- p3.addReplacement(Constant.INDEX_2, "");
- p3.addReplacement(Constant.INDEX_5, "LoggerFactory.getLogger(");
- p4.addReplacement(Constant.INDEX_4, "LoggerFactory.getLogger(");
- p4.addReplacement(Constant.INDEX_2, "");
- p5.addReplacement(Constant.INDEX_4, "LoggerFactory.getLogger(");
- p5.addReplacement(Constant.INDEX_2, "");
- p6.addReplacement(Constant.INDEX_3, "Logger");
- p6.addReplacement(Constant.INDEX_2, "");
- p7.addReplacement(Constant.INDEX_3, "Logger");
- p7.addReplacement(Constant.INDEX_2, "");
- p8.addReplacement(Constant.INDEX_3, "LoggerFactory.getLogger(");
- p8.addReplacement(Constant.INDEX_1, "");
p9.addReplacement(Constant.INDEX_3, "LoggerFactory.getLogger(");
p9.addReplacement(Constant.INDEX_1, "");
+
rules = new ArrayList<PatternWrapper>();
rules.add(p0);
More information about the slf4j-dev
mailing list