abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From calav...@apache.org
Subject svn commit: r936036 - in /abdera/java/trunk: core/ core/src/main/java/org/apache/abdera/parser/ core/src/main/java/org/apache/abdera/util/ extensions/html/src/main/java/org/apache/abdera/ext/html/ parser/src/main/java/org/apache/abdera/parser/stax/
Date Tue, 20 Apr 2010 19:20:42 GMT
Author: calavera
Date: Tue Apr 20 19:20:42 2010
New Revision: 936036

URL: http://svn.apache.org/viewvc?rev=936036&view=rev
Log:
Allowing to use a custom XMLReader to parse documents. Thanks to Dan Beaulieu.

Modified:
    abdera/java/trunk/core/pom.xml
    abdera/java/trunk/core/src/main/java/org/apache/abdera/parser/Parser.java
    abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractParser.java
    abdera/java/trunk/extensions/html/src/main/java/org/apache/abdera/ext/html/HtmlParser.java
    abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMParser.java

Modified: abdera/java/trunk/core/pom.xml
URL: http://svn.apache.org/viewvc/abdera/java/trunk/core/pom.xml?rev=936036&r1=936035&r2=936036&view=diff
==============================================================================
--- abdera/java/trunk/core/pom.xml (original)
+++ abdera/java/trunk/core/pom.xml Tue Apr 20 19:20:42 2010
@@ -66,6 +66,11 @@
   		<groupId>org.apache.geronimo.specs</groupId>
   		<artifactId>geronimo-activation_1.0.2_spec</artifactId>
   	</dependency>
+	<dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-stax-api_1.0_spec</artifactId>
+      <version>1.0.1</version>
+    </dependency>
   	<dependency>
   		<groupId>commons-codec</groupId>
   		<artifactId>commons-codec</artifactId>
@@ -74,7 +79,7 @@
   		<groupId>commons-logging</groupId>
   		<artifactId>commons-logging</artifactId>
   	</dependency>
-  	<dependency>
+	<dependency>
         <groupId>org.easymock</groupId>
         <artifactId>easymock</artifactId>
         <version>2.3</version>

Modified: abdera/java/trunk/core/src/main/java/org/apache/abdera/parser/Parser.java
URL: http://svn.apache.org/viewvc/abdera/java/trunk/core/src/main/java/org/apache/abdera/parser/Parser.java?rev=936036&r1=936035&r2=936036&view=diff
==============================================================================
--- abdera/java/trunk/core/src/main/java/org/apache/abdera/parser/Parser.java (original)
+++ abdera/java/trunk/core/src/main/java/org/apache/abdera/parser/Parser.java Tue Apr 20 19:20:42
2010
@@ -21,6 +21,8 @@ import java.io.InputStream;
 import java.io.Reader;
 import java.nio.channels.ReadableByteChannel;
 
+import javax.xml.stream.XMLStreamReader;
+
 import org.apache.abdera.model.Document;
 import org.apache.abdera.model.Element;
 
@@ -37,6 +39,16 @@ public interface Parser {
       throws ParseException;
   
   /**
+   * Parse the input stream using the default character set encoding (UTF-8)
+   * @param reader The XMLStreamReader to use to parse
+   * @return The parsed Abdera Document
+   * @throws ParseException if the parse failed
+   */
+  <T extends Element>Document<T> parse(
+    XMLStreamReader reader) 
+      throws ParseException;
+	  
+  /**
    * Parse the input stream using the default character set encoding (UTF-8).
    * The specified Base URI is used to resolve relative references contained
    * in the document
@@ -179,6 +191,20 @@ public interface Parser {
    * process such as the character set encoding to use and whether certain
    * elements should be ignored.  The specified Base URI is used to resolve
    * relative references contained in the document.
+   * @param reader the XMLStreamReader parser to use to parse
+   * @param base The Base URI of the document
+   * @param options The Parse Options
+   * @return The parsed Abdera Document
+   * @throws ParseException if the parse failed
+   */
+  <T extends Element>Document<T> parse(XMLStreamReader reader, String base, ParserOptions
options) throws ParseException;
+  
+  /**
+   * Parse the channel using using the specified Parse options.  The 
+   * parse options can be used to control various aspects of the parsing
+   * process such as the character set encoding to use and whether certain
+   * elements should be ignored.  The specified Base URI is used to resolve
+   * relative references contained in the document.
    * @param in The ReadableByteChannel to parse
    * @param options The Parse Options
    * @return The parsed Abdera Document

Modified: abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractParser.java
URL: http://svn.apache.org/viewvc/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractParser.java?rev=936036&r1=936035&r2=936036&view=diff
==============================================================================
--- abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractParser.java (original)
+++ abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractParser.java Tue Apr
20 19:20:42 2010
@@ -23,6 +23,8 @@ import java.io.Reader;
 import java.nio.channels.Channels;
 import java.nio.channels.ReadableByteChannel;
 
+import javax.xml.stream.XMLStreamReader;
+
 import org.apache.abdera.Abdera;
 import org.apache.abdera.factory.Factory;
 import org.apache.abdera.model.Document;
@@ -65,7 +67,13 @@ public abstract class AbstractParser 
       throws ParseException {
     return parse(in, null, getDefaultParserOptions());
   }
-
+  
+  public <T extends Element>Document<T> parse(
+    XMLStreamReader reader) 
+      throws ParseException {
+    return parse(reader, null, getDefaultParserOptions());
+  }
+  
   public <T extends Element>Document<T> parse(
     InputStream in, 
     String base) 

Modified: abdera/java/trunk/extensions/html/src/main/java/org/apache/abdera/ext/html/HtmlParser.java
URL: http://svn.apache.org/viewvc/abdera/java/trunk/extensions/html/src/main/java/org/apache/abdera/ext/html/HtmlParser.java?rev=936036&r1=936035&r2=936036&view=diff
==============================================================================
--- abdera/java/trunk/extensions/html/src/main/java/org/apache/abdera/ext/html/HtmlParser.java
(original)
+++ abdera/java/trunk/extensions/html/src/main/java/org/apache/abdera/ext/html/HtmlParser.java
Tue Apr 20 19:20:42 2010
@@ -19,6 +19,8 @@ package org.apache.abdera.ext.html;
 
 import java.io.Reader;
 
+import javax.xml.stream.XMLStreamReader;
+
 import org.apache.abdera.Abdera;
 import org.apache.abdera.model.Div;
 import org.apache.abdera.model.Document;
@@ -64,5 +66,14 @@ public class HtmlParser 
     if (base != null) doc.setBaseUri(base);
     return doc;
   }
+
+    public <T extends Element>Document<T> parse(
+        XMLStreamReader reader) throws ParseException {
+        return null;
+    }
+
+    public <T extends Element>Document<T> parse(XMLStreamReader reader, String
base, ParserOptions options) throws ParseException {
+        return null;
+    }
  
 }

Modified: abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMParser.java
URL: http://svn.apache.org/viewvc/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMParser.java?rev=936036&r1=936035&r2=936036&view=diff
==============================================================================
--- abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMParser.java (original)
+++ abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMParser.java Tue
Apr 20 19:20:42 2010
@@ -193,7 +193,7 @@ public class FOMParser 
     }    
   }
   
-  private <T extends Element> Document<T> parse(
+  public <T extends Element> Document<T> parse(
     XMLStreamReader reader, 
     String base,
     ParserOptions options)



Mime
View raw message