logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grobme...@apache.org
Subject svn commit: r1483233 - in /logging/log4j/companions/extras/trunk/src: changes/ main/java/org/apache/log4j/pattern/ main/java/org/apache/log4j/rolling/ test/java/org/apache/log4j/pattern/
Date Thu, 16 May 2013 08:10:51 GMT
Author: grobmeier
Date: Thu May 16 08:10:51 2013
New Revision: 1483233

URL: http://svn.apache.org/r1483233
Log:
prefixed FormattingInfo and PatternParser with Extras prefix to avoid classloading conflict

Added:
    logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/pattern/ExtrasFormattingInfo.java
      - copied, changed from r1478948, logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/pattern/FormattingInfo.java
    logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/pattern/ExtrasPatternParser.java
      - copied, changed from r1478948, logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/pattern/PatternParser.java
Removed:
    logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/pattern/FormattingInfo.java
    logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/pattern/PatternParser.java
Modified:
    logging/log4j/companions/extras/trunk/src/changes/changes.xml
    logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rolling/RollingPolicyBase.java
    logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/pattern/FormattingInfoTest.java
    logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/pattern/PatternParserTest.java

Modified: logging/log4j/companions/extras/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/changes/changes.xml?rev=1483233&r1=1483232&r2=1483233&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/changes/changes.xml (original)
+++ logging/log4j/companions/extras/trunk/src/changes/changes.xml Thu May 16 08:10:51 2013
@@ -21,6 +21,7 @@
   </properties>
   <body>
     <release version="1.2" date="2013-05-04" description="Maintenance release">
+        <action action="update">Prefixed FormattingInfo and PatternParser with Extras
to avoid classloading conflict</action>
         <action action="update">Fixed product naming</action>
         <action action="update">Removed duplicated classes (thanks to Jess Holle for
spotting it)</action>
         <action action="update">Removed ant build</action>

Copied: logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/pattern/ExtrasFormattingInfo.java
(from r1478948, logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/pattern/FormattingInfo.java)
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/pattern/ExtrasFormattingInfo.java?p2=logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/pattern/ExtrasFormattingInfo.java&p1=logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/pattern/FormattingInfo.java&r1=1478948&r2=1483233&rev=1483233&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/pattern/FormattingInfo.java
(original)
+++ logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/pattern/ExtrasFormattingInfo.java
Thu May 16 08:10:51 2013
@@ -28,7 +28,7 @@ package org.apache.log4j.pattern;
  *  @author Curt Arnold
  *
  */
-public final class FormattingInfo {
+public final class ExtrasFormattingInfo {
   /**
    *  Array of spaces.
    */
@@ -38,8 +38,8 @@ public final class FormattingInfo {
   /**
    * Default instance.
    */
-  private static final FormattingInfo DEFAULT =
-    new FormattingInfo(false, 0, Integer.MAX_VALUE);
+  private static final ExtrasFormattingInfo DEFAULT =
+    new ExtrasFormattingInfo(false, 0, Integer.MAX_VALUE);
 
   /**
    * Minimum length.
@@ -69,10 +69,10 @@ public final class FormattingInfo {
    * @param maxLength maximum length.
    * @deprecated since 1.2.17
    */
-  public FormattingInfo(
-    final boolean leftAlign, 
-    final int minLength, 
-    final int maxLength) {
+  public ExtrasFormattingInfo(
+          final boolean leftAlign,
+          final int minLength,
+          final int maxLength) {
     this.leftAlign = leftAlign;
     this.minLength = minLength;
     this.maxLength = maxLength;
@@ -87,11 +87,11 @@ public final class FormattingInfo {
    * @param maxLength maximum length.
    * @since 1.2.17
    */
-  public FormattingInfo(
-    final boolean leftAlign, 
-    final boolean rightTruncate,
-    final int minLength, 
-    final int maxLength) {
+  public ExtrasFormattingInfo(
+          final boolean leftAlign,
+          final boolean rightTruncate,
+          final int minLength,
+          final int maxLength) {
     this.leftAlign = leftAlign;
     this.minLength = minLength;
     this.maxLength = maxLength;
@@ -102,7 +102,7 @@ public final class FormattingInfo {
    * Gets default instance.
    * @return default instance.
    */
-  public static FormattingInfo getDefault() {
+  public static ExtrasFormattingInfo getDefault() {
     return DEFAULT;
   }
 

Copied: logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/pattern/ExtrasPatternParser.java
(from r1478948, logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/pattern/PatternParser.java)
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/pattern/ExtrasPatternParser.java?p2=logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/pattern/ExtrasPatternParser.java&p1=logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/pattern/PatternParser.java&r1=1478948&r2=1483233&rev=1483233&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/pattern/PatternParser.java
(original)
+++ logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/pattern/ExtrasPatternParser.java
Thu May 16 08:10:51 2013
@@ -34,7 +34,7 @@ import java.util.Set;
 
 /**
  * Most of the work of the {@link org.apache.log4j.EnhancedPatternLayout} class
- * is delegated to the PatternParser class.
+ * is delegated to the ExtrasPatternParser class.
  * <p>It is this class that parses conversion patterns and creates
  * a chained list of {@link PatternConverter PatternConverters}.
  *
@@ -45,7 +45,7 @@ import java.util.Set;
  * @author Curt Arnold
  *
 */
-public final class PatternParser {
+public final class ExtrasPatternParser {
   /**
    * Escape character for format specifier.
    */
@@ -87,7 +87,7 @@ public final class PatternParser {
   private static final Map FILENAME_PATTERN_RULES;
 
   static {
-    // We set the global rules in the static initializer of PatternParser class
+    // We set the global rules in the static initializer of ExtrasPatternParser class
     Map rules = new HashMap(17);
     rules.put("c", LoggerPatternConverter.class);
     rules.put("logger", LoggerPatternConverter.class);
@@ -147,7 +147,7 @@ public final class PatternParser {
   /**
    * Private constructor.
    */
-  private PatternParser() {
+  private ExtrasPatternParser() {
   }
 
   /**
@@ -254,7 +254,7 @@ public final class PatternParser {
     int state = LITERAL_STATE;
     char c;
     int i = 0;
-    FormattingInfo formattingInfo = FormattingInfo.getDefault();
+    ExtrasFormattingInfo formattingInfo = ExtrasFormattingInfo.getDefault();
 
     while (i < patternLength) {
       c = pattern.charAt(i++);
@@ -283,13 +283,13 @@ public final class PatternParser {
             if (currentLiteral.length() != 0) {
               patternConverters.add(
                 new LiteralPatternConverter(currentLiteral.toString()));
-              formattingInfos.add(FormattingInfo.getDefault());
+              formattingInfos.add(ExtrasFormattingInfo.getDefault());
             }
 
             currentLiteral.setLength(0);
             currentLiteral.append(c); // append %
             state = CONVERTER_STATE;
-            formattingInfo = FormattingInfo.getDefault();
+            formattingInfo = ExtrasFormattingInfo.getDefault();
           }
         } else {
           currentLiteral.append(c);
@@ -303,7 +303,7 @@ public final class PatternParser {
         switch (c) {
         case '-':
           formattingInfo =
-            new FormattingInfo(
+            new ExtrasFormattingInfo(
               true, 
               formattingInfo.isRightTruncated(),
               formattingInfo.getMinLength(),
@@ -312,7 +312,7 @@ public final class PatternParser {
 
         case '!':
           formattingInfo =
-            new FormattingInfo(
+            new ExtrasFormattingInfo(
               formattingInfo.isLeftAligned(), 
               true,
               formattingInfo.getMinLength(),
@@ -329,7 +329,7 @@ public final class PatternParser {
 
           if ((c >= '0') && (c <= '9')) {
             formattingInfo =
-              new FormattingInfo(
+              new ExtrasFormattingInfo(
                 formattingInfo.isLeftAligned(), 
                 formattingInfo.isRightTruncated(),
                 c - '0',
@@ -342,7 +342,7 @@ public final class PatternParser {
 
             // Next pattern is assumed to be a literal.
             state = LITERAL_STATE;
-            formattingInfo = FormattingInfo.getDefault();
+            formattingInfo = ExtrasFormattingInfo.getDefault();
             currentLiteral.setLength(0);
           }
         } // switch
@@ -354,7 +354,7 @@ public final class PatternParser {
 
         if ((c >= '0') && (c <= '9')) {
           formattingInfo =
-            new FormattingInfo(
+            new ExtrasFormattingInfo(
               formattingInfo.isLeftAligned(),
               formattingInfo.isRightTruncated(),
               (formattingInfo.getMinLength() * 10) + (c - '0'),
@@ -366,7 +366,7 @@ public final class PatternParser {
               c, pattern, i, currentLiteral, formattingInfo,
               converterRegistry, rules, patternConverters, formattingInfos);
           state = LITERAL_STATE;
-          formattingInfo = FormattingInfo.getDefault();
+          formattingInfo = ExtrasFormattingInfo.getDefault();
           currentLiteral.setLength(0);
         }
 
@@ -377,7 +377,7 @@ public final class PatternParser {
 
         if ((c >= '0') && (c <= '9')) {
           formattingInfo =
-            new FormattingInfo(
+            new ExtrasFormattingInfo(
               formattingInfo.isLeftAligned(), 
               formattingInfo.isRightTruncated(),
               formattingInfo.getMinLength(),
@@ -398,7 +398,7 @@ public final class PatternParser {
 
         if ((c >= '0') && (c <= '9')) {
           formattingInfo =
-            new FormattingInfo(
+            new ExtrasFormattingInfo(
               formattingInfo.isLeftAligned(), 
               formattingInfo.isRightTruncated(),
               formattingInfo.getMinLength(),
@@ -408,7 +408,7 @@ public final class PatternParser {
               c, pattern, i, currentLiteral, formattingInfo,
               converterRegistry, rules, patternConverters, formattingInfos);
           state = LITERAL_STATE;
-          formattingInfo = FormattingInfo.getDefault();
+          formattingInfo = ExtrasFormattingInfo.getDefault();
           currentLiteral.setLength(0);
         }
 
@@ -420,7 +420,7 @@ public final class PatternParser {
     if (currentLiteral.length() != 0) {
       patternConverters.add(
         new LiteralPatternConverter(currentLiteral.toString()));
-      formattingInfos.add(FormattingInfo.getDefault());
+      formattingInfos.add(ExtrasFormattingInfo.getDefault());
     }
   }
 
@@ -461,7 +461,7 @@ public final class PatternParser {
       return null;
     }
 
-    Class converterClass = null;
+    Class converterClass;
 
     if (converterObj instanceof Class) {
       converterClass = (Class) converterObj;
@@ -546,7 +546,7 @@ public final class PatternParser {
    */
   private static int finalizeConverter(
     char c, String pattern, int i,
-    final StringBuffer currentLiteral, final FormattingInfo formattingInfo,
+    final StringBuffer currentLiteral, final ExtrasFormattingInfo formattingInfo,
     final Map converterRegistry, final Map rules, final List patternConverters,
     final List formattingInfos) {
     StringBuffer convBuf = new StringBuffer();
@@ -580,7 +580,7 @@ public final class PatternParser {
 
       patternConverters.add(
         new LiteralPatternConverter(currentLiteral.toString()));
-      formattingInfos.add(FormattingInfo.getDefault());
+      formattingInfos.add(ExtrasFormattingInfo.getDefault());
     } else {
       patternConverters.add(pc);
       formattingInfos.add(formattingInfo);
@@ -588,7 +588,7 @@ public final class PatternParser {
       if (currentLiteral.length() > 0) {
         patternConverters.add(
           new LiteralPatternConverter(currentLiteral.toString()));
-        formattingInfos.add(FormattingInfo.getDefault());
+        formattingInfos.add(ExtrasFormattingInfo.getDefault());
       }
     }
 

Modified: logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rolling/RollingPolicyBase.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rolling/RollingPolicyBase.java?rev=1483233&r1=1483232&r2=1483233&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rolling/RollingPolicyBase.java
(original)
+++ logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rolling/RollingPolicyBase.java
Thu May 16 08:10:51 2013
@@ -17,9 +17,9 @@
 
 package org.apache.log4j.rolling;
 
-import org.apache.log4j.pattern.FormattingInfo;
+import org.apache.log4j.pattern.ExtrasFormattingInfo;
+import org.apache.log4j.pattern.ExtrasPatternParser;
 import org.apache.log4j.pattern.PatternConverter;
-import org.apache.log4j.pattern.PatternParser;
 import org.apache.log4j.pattern.IntegerPatternConverter;
 import org.apache.log4j.pattern.DatePatternConverter;
 import org.apache.log4j.helpers.LogLog;
@@ -59,7 +59,7 @@ public abstract class RollingPolicyBase
   /**
    * File name field specifiers.
    */
-  private FormattingInfo[] patternFields;
+  private ExtrasFormattingInfo[] patternFields;
 
   /**
    * File name pattern.
@@ -128,14 +128,14 @@ public abstract class RollingPolicyBase
     List converters = new ArrayList();
     List fields = new ArrayList();
 
-    PatternParser.parse(
-      fileNamePatternStr, converters, fields, null,
-      PatternParser.getFileNamePatternRules());
+    ExtrasPatternParser.parse(
+            fileNamePatternStr, converters, fields, null,
+            ExtrasPatternParser.getFileNamePatternRules());
     patternConverters = new PatternConverter[converters.size()];
     patternConverters =
       (PatternConverter[]) converters.toArray(patternConverters);
-    patternFields = new FormattingInfo[converters.size()];
-    patternFields = (FormattingInfo[]) fields.toArray(patternFields);
+    patternFields = new ExtrasFormattingInfo[converters.size()];
+    patternFields = (ExtrasFormattingInfo[]) fields.toArray(patternFields);
   }
 
   /**

Modified: logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/pattern/FormattingInfoTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/pattern/FormattingInfoTest.java?rev=1483233&r1=1483232&r2=1483233&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/pattern/FormattingInfoTest.java
(original)
+++ logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/pattern/FormattingInfoTest.java
Thu May 16 08:10:51 2013
@@ -21,7 +21,7 @@ import junit.framework.TestCase;
 
 
 /**
- * Tests for FormattingInfo.
+ * Tests for ExtrasFormattingInfo.
  *
  * @author Curt Arnold
  *
@@ -41,7 +41,7 @@ public class FormattingInfoTest extends 
    *
    */
   public void testGetDefault() {
-    FormattingInfo field = FormattingInfo.getDefault();
+    ExtrasFormattingInfo field = ExtrasFormattingInfo.getDefault();
     assertNotNull(field);
     assertEquals(0, field.getMinLength());
     assertEquals(Integer.MAX_VALUE, field.getMaxLength());
@@ -53,7 +53,7 @@ public class FormattingInfoTest extends 
    *
    */
   public void testConstructor() {
-      FormattingInfo field = new FormattingInfo(true, false, 3, 6);
+      ExtrasFormattingInfo field = new ExtrasFormattingInfo(true, false, 3, 6);
       assertNotNull(field);
       assertEquals(3, field.getMinLength());
       assertEquals(6, field.getMaxLength());
@@ -65,7 +65,7 @@ public class FormattingInfoTest extends 
    */
   public void testTruncate() {
       StringBuffer buf = new StringBuffer("foobar");
-      FormattingInfo field = new FormattingInfo(true, false, 0, 3);
+      ExtrasFormattingInfo field = new ExtrasFormattingInfo(true, false, 0, 3);
       field.format(2, buf);
       assertEquals("fobar", buf.toString());
   }
@@ -75,7 +75,7 @@ public class FormattingInfoTest extends 
    */
   public void testRightTruncate() {
       StringBuffer buf = new StringBuffer("foobar");
-      FormattingInfo field = new FormattingInfo(true, true, 0, 3);
+      ExtrasFormattingInfo field = new ExtrasFormattingInfo(true, true, 0, 3);
       field.format(2, buf);
       assertEquals("fooba", buf.toString());
   }
@@ -85,7 +85,7 @@ public class FormattingInfoTest extends 
      */
     public void testPadLeft() {
         StringBuffer buf = new StringBuffer("foobar");
-        FormattingInfo field = new FormattingInfo(false, false, 5, 10);
+        ExtrasFormattingInfo field = new ExtrasFormattingInfo(false, false, 5, 10);
         field.format(2, buf);
         assertEquals("fo obar", buf.toString());
     }
@@ -95,7 +95,7 @@ public class FormattingInfoTest extends 
      */
     public void testPadRight() {
         StringBuffer buf = new StringBuffer("foobar");
-        FormattingInfo field = new FormattingInfo(true, false, 5, 10);
+        ExtrasFormattingInfo field = new ExtrasFormattingInfo(true, false, 5, 10);
         field.format(2, buf);
         assertEquals("foobar ", buf.toString());
     }

Modified: logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/pattern/PatternParserTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/pattern/PatternParserTest.java?rev=1483233&r1=1483232&r2=1483233&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/pattern/PatternParserTest.java
(original)
+++ logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/pattern/PatternParserTest.java
Thu May 16 08:10:51 2013
@@ -21,7 +21,6 @@ import java.lang.reflect.Method;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -31,16 +30,14 @@ import junit.framework.TestCase;
 
 import org.apache.log4j.Layout;
 import org.apache.log4j.Level;
-import org.apache.log4j.LogManager;
 import org.apache.log4j.Logger;
-import org.apache.log4j.spi.LoggerRepository;
 import org.apache.log4j.spi.LoggingEvent;
 
 
 /**
-   Test case for PatternParser.java. Tests the various
-   conversion patterns supported by PatternParser. This test
-   class tests PatternParser via the EnhancedPatternLayout class which
+   Test case for ExtrasPatternParser.java. Tests the various
+   conversion patterns supported by ExtrasPatternParser. This test
+   class tests ExtrasPatternParser via the EnhancedPatternLayout class which
    uses it.
  */
 public class PatternParserTest extends TestCase {
@@ -59,9 +56,9 @@ public class PatternParserTest extends T
                  LoggingEvent event) {
     List converters = new ArrayList();
     List fields = new ArrayList();
-    PatternParser.parse(pattern, converters, fields,
+    ExtrasPatternParser.parse(pattern, converters, fields,
             registry,
-            PatternParser.getPatternLayoutRules());
+            ExtrasPatternParser.getPatternLayoutRules());
     assertEquals(converters.size(), fields.size());
 
     StringBuffer buf = new StringBuffer();
@@ -70,28 +67,11 @@ public class PatternParserTest extends T
     while(converterIter.hasNext()) {
         int fieldStart = buf.length();
         ((PatternConverter) converterIter.next()).format(event, buf);
-        ((FormattingInfo) fieldIter.next()).format(fieldStart, buf);
+        ((ExtrasFormattingInfo) fieldIter.next()).format(fieldStart, buf);
     }
     return buf.toString();
   }
 
-  public void testNewWord() throws Exception {
-    HashMap ruleRegistry = new HashMap(5);
-    ruleRegistry.put("z343", Num343PatternConverter.class.getName());
-    String result = convert("%z343", ruleRegistry, event);
-    assertEquals("343", result);
-  }
-
-  /* Test whether words starting with the letter 'n' are treated differently,
-   * which was previously the case by mistake.
-   */
-  public void testNewWord2() throws Exception {
-    HashMap ruleRegistry = new HashMap(5);
-    ruleRegistry.put("n343", Num343PatternConverter.class.getName());
-    String result = convert("%n343", ruleRegistry, event);
-    assertEquals("343", result);
-  }
-
   public void testBogusWord1() throws Exception {
     String result = convert("%, foobar", null, event);
     assertEquals("%, foobar", result);
@@ -163,11 +143,11 @@ public class PatternParserTest extends T
   }
 
   public void testPatternLayoutFactories() throws Exception {
-      assertFactories(PatternParser.getPatternLayoutRules());
+      assertFactories(ExtrasPatternParser.getPatternLayoutRules());
   }
 
   public void testFileNamePatternFactories() throws Exception {
-        assertFactories(PatternParser.getFileNamePatternRules());
+        assertFactories(ExtrasPatternParser.getFileNamePatternRules());
   }
 
 }



Mime
View raw message