Package org.slf4j.migrator.line

Examples of org.slf4j.migrator.line.MultiGroupConversionRule


   * In this test we see that we cans use more simple Pattern to do the
   * conversion
   *
   */
  public void test() {
    MultiGroupConversionRule cr2 = new MultiGroupConversionRule(Pattern
        .compile("(.*)(Log)"));
    cr2.addReplacement(2, "LOGGER");

    String s = "abcd Log";
    Pattern pat = cr2.getPattern();
    Matcher m = pat.matcher(s);

    assertTrue(m.matches());
    String r = cr2.replace(m);
    assertEquals("abcd LOGGER", r);

    System.out.println(r);
  }
View Full Code Here


    //simple rule no capturing group is defined, we use default capturing group which is group zero
    SingleConversionRule cr = new SingleConversionRule(Pattern.compile("import org.slf4j.converter"),
        "simple replacement with an unique capturing group");
   
    //we define 4 differents capturing groups
    MultiGroupConversionRule cr1 = new MultiGroupConversionRule(Pattern.compile("(first group)( second group)( third group)( 4th group)"));
    //group zero is ignored during treatment
    //replacement for the first
    cr1.addReplacement(1, "1st group");
    //no replacement for the second group it will remains the same
    //empty string for the third group it will be deleted
    cr1.addReplacement(3, "");
    //no replacement for the third group it will remains the same
   
    conversionRuleList = new ArrayList<ConversionRule>();
    conversionRuleList.add(cr);
    conversionRuleList.add(cr1);
View Full Code Here

TOP

Related Classes of org.slf4j.migrator.line.MultiGroupConversionRule

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.