Author: ltheussl
Date: Sat Mar 28 21:04:49 2009
New Revision: 759591

URL: http://svn.apache.org/viewvc?rev=759591&view=rev
Log:
Add a method to override default configuration parameters

Modified:
    
maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoConfiguration.java

Modified: 
maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoConfiguration.java
URL: 
http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoConfiguration.java?rev=759591&r1=759590&r2=759591&view=diff
==============================================================================
--- 
maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoConfiguration.java
 (original)
+++ 
maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoConfiguration.java
 Sat Mar 28 21:04:49 2009
@@ -19,6 +19,9 @@
  * under the License.
  */
 
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
 import java.util.List;
 
 import javax.swing.text.MutableAttributeSet;
@@ -45,9 +48,7 @@
     private final XMLConfiguration config;
 
     /** The list of attribute sets. */
-    private final List sets;
-
-    // TODO: add constructor to override default configuration
+    private List sets;
 
     /**
      * Constructor.
@@ -74,6 +75,33 @@
     }
 
     /**
+     * Load configuration parameters from a File.
+     *
+     * @param configFile the configuration file.
+     *
+     * @throws java.io.IOException if the File cannot be read
+     *  or some error occurs when initializing the configuration parameters.
+     *
+     * @since 1.1.1
+     */
+    public void load( File configFile )
+            throws IOException
+    {
+        // this overloads default values with custom config
+        try
+        {
+            config.load( new FileReader( configFile ) );
+        }
+        catch ( ConfigurationException cex )
+        {
+            throw new IOException( cex );
+        }
+
+        this.sets = config.getList( "xsl:attribute-s...@name]" );
+        reset();
+    }
+
+    /**
      * Builds a list of attributes.
      *
      * @param attributeId A unique id to identify the set of attributes.


Reply via email to