abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r611915 - in /incubator/abdera/java/trunk: core/src/main/java/org/apache/abdera/util/ parser/src/main/java/org/apache/abdera/parser/stax/
Date Mon, 14 Jan 2008 20:17:13 GMT
Author: jmsnell
Date: Mon Jan 14 12:17:00 2008
New Revision: 611915

URL: http://svn.apache.org/viewvc?rev=611915&view=rev
Log:
Ewww... bugs!  The code would enter an infinite loop when attempting to use a named parser

Modified:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbderaConfiguration.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractNamedParser.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractParser.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMParserFactory.java

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbderaConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbderaConfiguration.java?rev=611915&r1=611914&r2=611915&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbderaConfiguration.java
(original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbderaConfiguration.java
Mon Jan 14 12:17:00 2008
@@ -240,8 +240,7 @@
    */
   private Map<String,NamedParser> initNamedParsers() {
     Map<String,NamedParser> parsers = null;
-    List<NamedParser> _parsers = 
-      ServiceUtil._loadimpls(NAMED_PARSER);
+    List<NamedParser> _parsers = ServiceUtil._loadimpls(NAMED_PARSER);
     parsers = Collections.synchronizedMap(new HashMap<String,NamedParser>());
     for (NamedParser parser : _parsers) {
       parsers.put(parser.getName().toLowerCase(), parser);

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractNamedParser.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractNamedParser.java?rev=611915&r1=611914&r2=611915&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractNamedParser.java
(original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractNamedParser.java
Mon Jan 14 12:17:00 2008
@@ -17,6 +17,7 @@
 */
 package org.apache.abdera.util;
 
+import org.apache.abdera.Abdera;
 import org.apache.abdera.parser.NamedParser;
 
 /**
@@ -29,9 +30,13 @@
   protected final String name;
   protected final String[] formats;
   
-  protected AbstractNamedParser(String name, String... formats) {
-    this.name = name;
-    this.formats = formats;
+  protected AbstractNamedParser(
+    Abdera abdera, 
+    String name, 
+    String... formats) {
+      super(abdera);
+      this.name = name;
+      this.formats = formats;
   }
   
   public String getName() {

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractParser.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractParser.java?rev=611915&r1=611914&r2=611915&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractParser.java
(original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractParser.java
Mon Jan 14 12:17:00 2008
@@ -18,6 +18,7 @@
 package org.apache.abdera.util;
 
 import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.io.Reader;
 import java.nio.channels.Channels;
 import java.nio.channels.ReadableByteChannel;
@@ -36,7 +37,7 @@
 public abstract class AbstractParser 
   implements Parser {
 
-  protected final Abdera abdera;
+  protected Abdera abdera;
   protected ParserOptions options;
   
   protected AbstractParser() {
@@ -51,6 +52,10 @@
     return abdera;
   }
   
+  public void setAbdera(Abdera abdera) {
+    this.abdera = abdera;
+  }
+  
   public Factory getFactory() {
     return getAbdera().getFactory();
   }
@@ -80,7 +85,7 @@
     String base, 
     ParserOptions options) 
       throws ParseException{
-    return parse(in, base, options);
+    return parse(new InputStreamReader(in), base, options);
   }
   
   public <T extends Element>Document<T> parse(

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMParserFactory.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMParserFactory.java?rev=611915&r1=611914&r2=611915&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMParserFactory.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMParserFactory.java
Mon Jan 14 12:17:00 2008
@@ -24,6 +24,7 @@
 import org.apache.abdera.parser.NamedParser;
 import org.apache.abdera.parser.Parser;
 import org.apache.abdera.parser.ParserFactory;
+import org.apache.abdera.util.AbstractParser;
 
 @SuppressWarnings("unchecked")
 public class FOMParserFactory 
@@ -51,8 +52,12 @@
   }
 
   public <T extends Parser>T getParser(String name) {
-    return (T)((name != null) ? 
+    Parser parser = (T)((name != null) ? 
       getParsers().get(name.toLowerCase()) : getParser());
+    if (parser instanceof AbstractParser) {
+      ((AbstractParser)parser).setAbdera(abdera);
+    }
+    return (T) parser;
   }
 
   private Map<String,NamedParser> getParsers() {



Mime
View raw message