prefixed FormattingInfo and PatternParser with Extras prefix to avoid classloading conflict

git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/companions/extras/trunk@1483233 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 7bd82da..5dba7b7 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -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>
diff --git a/src/main/java/org/apache/log4j/pattern/FormattingInfo.java b/src/main/java/org/apache/log4j/pattern/ExtrasFormattingInfo.java
similarity index 88%
rename from src/main/java/org/apache/log4j/pattern/FormattingInfo.java
rename to src/main/java/org/apache/log4j/pattern/ExtrasFormattingInfo.java
index 3fb127e..16183d3 100644
--- a/src/main/java/org/apache/log4j/pattern/FormattingInfo.java
+++ b/src/main/java/org/apache/log4j/pattern/ExtrasFormattingInfo.java
@@ -28,7 +28,7 @@
  *  @author Curt Arnold
  *
  */
-public final class FormattingInfo {
+public final class ExtrasFormattingInfo {
   /**
    *  Array of spaces.
    */
@@ -38,8 +38,8 @@
   /**
    * 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 @@
    * @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 @@
    * @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 @@
    * Gets default instance.
    * @return default instance.
    */
-  public static FormattingInfo getDefault() {
+  public static ExtrasFormattingInfo getDefault() {
     return DEFAULT;
   }
 
diff --git a/src/main/java/org/apache/log4j/pattern/PatternParser.java b/src/main/java/org/apache/log4j/pattern/ExtrasPatternParser.java
similarity index 94%
rename from src/main/java/org/apache/log4j/pattern/PatternParser.java
rename to src/main/java/org/apache/log4j/pattern/ExtrasPatternParser.java
index 901b0fe..da03273 100644
--- a/src/main/java/org/apache/log4j/pattern/PatternParser.java
+++ b/src/main/java/org/apache/log4j/pattern/ExtrasPatternParser.java
@@ -34,7 +34,7 @@
 
 /**
  * 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 @@
  * @author Curt Arnold
  *
 */
-public final class PatternParser {
+public final class ExtrasPatternParser {
   /**
    * Escape character for format specifier.
    */
@@ -87,7 +87,7 @@
   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 @@
   /**
    * Private constructor.
    */
-  private PatternParser() {
+  private ExtrasPatternParser() {
   }
 
   /**
@@ -254,7 +254,7 @@
     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 @@
             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 @@
         switch (c) {
         case '-':
           formattingInfo =
-            new FormattingInfo(
+            new ExtrasFormattingInfo(
               true, 
               formattingInfo.isRightTruncated(),
               formattingInfo.getMinLength(),
@@ -312,7 +312,7 @@
 
         case '!':
           formattingInfo =
-            new FormattingInfo(
+            new ExtrasFormattingInfo(
               formattingInfo.isLeftAligned(), 
               true,
               formattingInfo.getMinLength(),
@@ -329,7 +329,7 @@
 
           if ((c >= '0') && (c <= '9')) {
             formattingInfo =
-              new FormattingInfo(
+              new ExtrasFormattingInfo(
                 formattingInfo.isLeftAligned(), 
                 formattingInfo.isRightTruncated(),
                 c - '0',
@@ -342,7 +342,7 @@
 
             // 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 @@
 
         if ((c >= '0') && (c <= '9')) {
           formattingInfo =
-            new FormattingInfo(
+            new ExtrasFormattingInfo(
               formattingInfo.isLeftAligned(),
               formattingInfo.isRightTruncated(),
               (formattingInfo.getMinLength() * 10) + (c - '0'),
@@ -366,7 +366,7 @@
               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 @@
 
         if ((c >= '0') && (c <= '9')) {
           formattingInfo =
-            new FormattingInfo(
+            new ExtrasFormattingInfo(
               formattingInfo.isLeftAligned(), 
               formattingInfo.isRightTruncated(),
               formattingInfo.getMinLength(),
@@ -398,7 +398,7 @@
 
         if ((c >= '0') && (c <= '9')) {
           formattingInfo =
-            new FormattingInfo(
+            new ExtrasFormattingInfo(
               formattingInfo.isLeftAligned(), 
               formattingInfo.isRightTruncated(),
               formattingInfo.getMinLength(),
@@ -408,7 +408,7 @@
               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 @@
     if (currentLiteral.length() != 0) {
       patternConverters.add(
         new LiteralPatternConverter(currentLiteral.toString()));
-      formattingInfos.add(FormattingInfo.getDefault());
+      formattingInfos.add(ExtrasFormattingInfo.getDefault());
     }
   }
 
@@ -461,7 +461,7 @@
       return null;
     }
 
-    Class converterClass = null;
+    Class converterClass;
 
     if (converterObj instanceof Class) {
       converterClass = (Class) converterObj;
@@ -546,7 +546,7 @@
    */
   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 @@
 
       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 @@
       if (currentLiteral.length() > 0) {
         patternConverters.add(
           new LiteralPatternConverter(currentLiteral.toString()));
-        formattingInfos.add(FormattingInfo.getDefault());
+        formattingInfos.add(ExtrasFormattingInfo.getDefault());
       }
     }
 
diff --git a/src/main/java/org/apache/log4j/rolling/RollingPolicyBase.java b/src/main/java/org/apache/log4j/rolling/RollingPolicyBase.java
index 3b417f8..1c04e1d 100644
--- a/src/main/java/org/apache/log4j/rolling/RollingPolicyBase.java
+++ b/src/main/java/org/apache/log4j/rolling/RollingPolicyBase.java
@@ -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 @@
   /**
    * File name field specifiers.
    */
-  private FormattingInfo[] patternFields;
+  private ExtrasFormattingInfo[] patternFields;
 
   /**
    * File name pattern.
@@ -128,14 +128,14 @@
     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);
   }
 
   /**
diff --git a/src/test/java/org/apache/log4j/pattern/FormattingInfoTest.java b/src/test/java/org/apache/log4j/pattern/FormattingInfoTest.java
index 64917b5..5dc36c8 100644
--- a/src/test/java/org/apache/log4j/pattern/FormattingInfoTest.java
+++ b/src/test/java/org/apache/log4j/pattern/FormattingInfoTest.java
@@ -21,7 +21,7 @@
 
 
 /**
- * Tests for FormattingInfo.
+ * Tests for ExtrasFormattingInfo.
  *
  * @author Curt Arnold
  *
@@ -41,7 +41,7 @@
    *
    */
   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 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 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 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 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 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());
     }
diff --git a/src/test/java/org/apache/log4j/pattern/PatternParserTest.java b/src/test/java/org/apache/log4j/pattern/PatternParserTest.java
index 8ccc0a3..d106ff8 100644
--- a/src/test/java/org/apache/log4j/pattern/PatternParserTest.java
+++ b/src/test/java/org/apache/log4j/pattern/PatternParserTest.java
@@ -21,7 +21,6 @@
 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 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 @@
                  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 @@
     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 void testPatternLayoutFactories() throws Exception {
-      assertFactories(PatternParser.getPatternLayoutRules());
+      assertFactories(ExtrasPatternParser.getPatternLayoutRules());
   }
 
   public void testFileNamePatternFactories() throws Exception {
-        assertFactories(PatternParser.getFileNamePatternRules());
+        assertFactories(ExtrasPatternParser.getFileNamePatternRules());
   }
 
 }