avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ne...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/i18n/test DefaultBundleLoaderTestCase.xtest XmlBundleTestCase.java XmlBundleTestCase.xtest
Date Wed, 02 Jan 2002 19:48:52 GMT
neeme       02/01/02 11:48:52

  Modified:    src/scratchpad/org/apache/avalon/excalibur/i18n
                        XmlBundle.java
               src/scratchpad/org/apache/avalon/excalibur/i18n/test
                        DefaultBundleLoaderTestCase.xtest
                        XmlBundleTestCase.java XmlBundleTestCase.xtest
  Log:
  Abstracted the Parser implementation in XmlBundle
  
  Revision  Changes    Path
  1.6       +8 -23     jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/i18n/XmlBundle.java
  
  Index: XmlBundle.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/i18n/XmlBundle.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XmlBundle.java	2 Jan 2002 19:04:56 -0000	1.5
  +++ XmlBundle.java	2 Jan 2002 19:48:51 -0000	1.6
  @@ -17,20 +17,15 @@
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.excalibur.xml.xpath.XPathProcessor;
  +import org.apache.avalon.excalibur.xml.Parser;
   import org.apache.avalon.excalibur.source.Source;
   import org.apache.avalon.excalibur.source.SourceResolver;
   import org.w3c.dom.Document;
  -import org.w3c.dom.NamedNodeMap;
   import org.w3c.dom.Node;
   import org.w3c.dom.NodeList;
  -import org.xml.sax.SAXException;
  +import org.w3c.dom.NamedNodeMap;
  +import org.xml.sax.InputSource;
   
  -import javax.xml.parsers.DocumentBuilder;
  -import javax.xml.parsers.DocumentBuilderFactory;
  -import javax.xml.parsers.ParserConfigurationException;
  -import java.io.File;
  -import java.io.IOException;
  -import java.io.InputStream;
   import java.util.HashMap;
   import java.util.Locale;
   import java.util.Map;
  @@ -40,7 +35,7 @@
    * @author <a href="mailto:mengelhart@earthtrip.com">Mike Engelhart</a>
    * @author <a href="mailto:neeme@apache.org">Neeme Praks</a>
    * @author <a href="mailto:oleg@one.lv">Oleg Podolsky</a>
  - * @version $Id: XmlBundle.java,v 1.5 2002/01/02 19:04:56 neeme Exp $
  + * @version $Id: XmlBundle.java,v 1.6 2002/01/02 19:48:51 neeme Exp $
    */
   public class XmlBundle extends AbstractBundle implements Configurable, Initializable, Disposable,
Composable {
   
  @@ -127,7 +122,7 @@
        * @exception SAXException  if an error occurs while parsing the file
        */
       public void initialize(Source source) throws Exception {
  -        initialize(source.getInputStream());
  +        initialize(source.getInputSource());
       }
   
       /**
  @@ -138,8 +133,9 @@
        * @exception ParserConfigurationException if no parser is configured
        * @exception SAXException  if an error occurs while parsing the file
        */
  -    public void initialize(InputStream inStream) throws Exception {
  -        this.doc = getDocumentBuilder().parse(inStream);
  +    public void initialize(InputSource inSource) throws Exception {
  +        Parser parser = (Parser) this.manager.lookup(Parser.ROLE);
  +        this.doc = parser.parseDocument(inSource);
           load();
       }
   
  @@ -152,17 +148,6 @@
           if (this.loadOnInit) {
               cacheAll(doc.getDocumentElement(), useRootElement ? '/' + doc.getDocumentElement().getTagName()
: "");
           }
  -    }
  -
  -    /**
  -     * Return document builder used to parse the XML document.
  -     *
  -     * @return the document builder
  -     * @exception ParserConfigurationException if no parser is configured
  -     */
  -    protected DocumentBuilder getDocumentBuilder() throws ParserConfigurationException
{
  -        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  -        return factory.newDocumentBuilder();
       }
   
       /**
  
  
  
  1.6       +3 -1      jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/i18n/test/DefaultBundleLoaderTestCase.xtest
  
  Index: DefaultBundleLoaderTestCase.xtest
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/i18n/test/DefaultBundleLoaderTestCase.xtest,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultBundleLoaderTestCase.xtest	2 Jan 2002 19:04:56 -0000	1.5
  +++ DefaultBundleLoaderTestCase.xtest	2 Jan 2002 19:48:51 -0000	1.6
  @@ -8,6 +8,7 @@
          ]]></annotation>
       <roles>
           <role name="org.apache.avalon.excalibur.xml.xpath.XPathProcessor" shorthand="xpath-processor"
default-class="org.apache.avalon.excalibur.xml.xpath.XPathProcessorImpl"/>
  +        <role name="org.apache.avalon.excalibur.xml.Parser" shorthand="parser" default-class="org.apache.avalon.excalibur.xml.XercesParser"/>
           <role
                   shorthand="bundles"
                   name="org.apache.avalon.excalibur.i18n.BundleSelector"
  @@ -46,6 +47,8 @@
       <context/>
       <logkit/>
       <components>
  +        <xpath-processor/>
  +        <parser/>
           <bundle-mappers>
               <default name="test">
                   <prefix>file:///root/path/to/xml/files/</prefix>
  @@ -87,6 +90,5 @@
               <test3 matcher="test3"/>
               <xml matcher="test4"/>
           </bundles>
  -        <xpath-processor/>
       </components>
   </testcase>
  
  
  
  1.8       +4 -3      jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/i18n/test/XmlBundleTestCase.java
  
  Index: XmlBundleTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/i18n/test/XmlBundleTestCase.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- XmlBundleTestCase.java	2 Jan 2002 19:04:56 -0000	1.7
  +++ XmlBundleTestCase.java	2 Jan 2002 19:48:51 -0000	1.8
  @@ -17,10 +17,11 @@
   import org.apache.avalon.excalibur.i18n.BundleInfoMapper;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.DefaultConfiguration;
  +import org.xml.sax.InputSource;
   
   /**
    * @author <a href="mailto:neeme@apache.org">Neeme Praks</a>
  - * @version $Id: XmlBundleTestCase.java,v 1.7 2002/01/02 19:04:56 neeme Exp $
  + * @version $Id: XmlBundleTestCase.java,v 1.8 2002/01/02 19:48:51 neeme Exp $
    */
   public class XmlBundleTestCase extends ExcaliburTestCase {
   
  @@ -46,7 +47,7 @@
           conf.setAttribute(XmlBundle.ConfigurationKeys.LOAD_ON_INIT, "true");
           conf.setAttribute(XmlBundle.ConfigurationKeys.USE_ROOT, "false");
           this.bundle.configure(conf);
  -        this.bundle.initialize(this.getClass().getClassLoader().getResource(bundleFileName).openStream());
  +        this.bundle.initialize(new InputSource(this.getClass().getClassLoader().getResource(bundleFileName).openStream()));
   
           this.bundleWithRoot.setBundleInfo(new BundleInfo("test-with-root", null));
           this.bundleWithRoot.setMapper((BundleInfoMapper) this.manager.lookup(BundleInfoMapper.ROLE));
  @@ -56,7 +57,7 @@
           conf.setAttribute(XmlBundle.ConfigurationKeys.LOAD_ON_INIT, "true");
           conf.setAttribute(XmlBundle.ConfigurationKeys.USE_ROOT, "true");
           this.bundleWithRoot.configure(conf);
  -        this.bundleWithRoot.initialize(this.getClass().getClassLoader().getResource(bundleFileName).openStream());
  +        this.bundleWithRoot.initialize(new InputSource(this.getClass().getClassLoader().getResource(bundleFileName).openStream()));
       }
   
       public void testGetString() {
  
  
  
  1.6       +2 -0      jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/i18n/test/XmlBundleTestCase.xtest
  
  Index: XmlBundleTestCase.xtest
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/i18n/test/XmlBundleTestCase.xtest,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XmlBundleTestCase.xtest	2 Jan 2002 19:04:56 -0000	1.5
  +++ XmlBundleTestCase.xtest	2 Jan 2002 19:48:51 -0000	1.6
  @@ -8,6 +8,7 @@
          ]]></annotation>
       <roles>
           <role name="org.apache.avalon.excalibur.xml.xpath.XPathProcessor" shorthand="xpath-processor"
default-class="org.apache.avalon.excalibur.xml.xpath.XPathProcessorImpl"/>
  +        <role name="org.apache.avalon.excalibur.xml.Parser" shorthand="parser" default-class="org.apache.avalon.excalibur.xml.XercesParser"/>
           <role
                   shorthand="bundle-mapper"
                   name="org.apache.avalon.excalibur.i18n.BundleInfoMapper"
  @@ -18,6 +19,7 @@
       <logkit/>
       <components>
           <xpath-processor/>
  +        <parser/>
           <bundle-mapper>
               <prefix>file:///root/path/to/xml/files/</prefix>
               <suffix>.xml</suffix>
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message