abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r429577 - in /incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol: client/Response.java client/ResponseBase.java util/DataSourceRequestEntity.java
Date Tue, 08 Aug 2006 05:01:33 GMT
Author: jmsnell
Date: Mon Aug  7 22:01:32 2006
New Revision: 429577

URL: http://svn.apache.org/viewvc?rev=429577&view=rev
Log:
Adding methods to client so we can get a parsed Document instance from the Response

Modified:
    incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/Response.java
    incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/ResponseBase.java
    incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/util/DataSourceRequestEntity.java

Modified: incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/Response.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/Response.java?rev=429577&r1=429576&r2=429577&view=diff
==============================================================================
--- incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/Response.java
(original)
+++ incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/Response.java
Mon Aug  7 22:01:32 2006
@@ -23,6 +23,12 @@
 
 import javax.activation.MimeType;
 
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.parser.ParseException;
+import org.apache.abdera.parser.Parser;
+import org.apache.abdera.parser.ParserOptions;
+
 public interface Response {
 
   public static enum ResponseType {
@@ -64,6 +70,14 @@
   InputStream getInputStream() throws IOException;
   
   void setInputStream(InputStream in);
+  
+  <T extends Element>Document<T> getDocument() throws ParseException;
+  
+  <T extends Element>Document<T> getDocument(ParserOptions options) throws ParseException;
+
+  <T extends Element>Document<T> getDocument(Parser parser) throws ParseException;
+  
+  <T extends Element>Document<T> getDocument(Parser parser, ParserOptions options)
throws ParseException;
   
   boolean isPrivate();
   

Modified: incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/ResponseBase.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/ResponseBase.java?rev=429577&r1=429576&r2=429577&view=diff
==============================================================================
--- incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/ResponseBase.java
(original)
+++ incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/ResponseBase.java
Mon Aug  7 22:01:32 2006
@@ -23,6 +23,11 @@
 
 import javax.activation.MimeType;
 
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.parser.ParseException;
+import org.apache.abdera.parser.Parser;
+import org.apache.abdera.parser.ParserOptions;
 import org.apache.abdera.protocol.util.CacheControlUtil;
 import org.apache.commons.httpclient.util.DateParseException;
 import org.apache.commons.httpclient.util.DateUtil;
@@ -42,6 +47,34 @@
   protected InputStream in = null;
   protected Date response_date = null;
   protected Date now = new Date(); 
+  
+  public <T extends Element>Document<T> getDocument() 
+    throws ParseException {
+      return getDocument(Parser.INSTANCE);
+  }
+  
+  public <T extends Element>Document<T> getDocument(
+    ParserOptions options) 
+      throws ParseException {
+    return getDocument(Parser.INSTANCE, options);
+  }
+
+  public <T extends Element>Document<T> getDocument(
+    Parser parser) 
+      throws ParseException {
+    return getDocument(parser, parser.getDefaultParserOptions());
+  }
+  
+  public <T extends Element>Document<T> getDocument(
+    Parser parser, 
+    ParserOptions options) 
+      throws ParseException {
+    try {
+      return parser.parse(getInputStream(), getUri(), options);
+    } catch (Exception e) {
+      throw new ParseException(e);
+    }
+  }
   
   public InputStream getInputStream() throws IOException {
     return in;

Modified: incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/util/DataSourceRequestEntity.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/util/DataSourceRequestEntity.java?rev=429577&r1=429576&r2=429577&view=diff
==============================================================================
--- incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/util/DataSourceRequestEntity.java
(original)
+++ incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/util/DataSourceRequestEntity.java
Mon Aug  7 22:01:32 2006
@@ -21,6 +21,7 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 
+import javax.activation.DataHandler;
 import javax.activation.DataSource;
 
 import org.apache.commons.httpclient.methods.RequestEntity;
@@ -29,6 +30,10 @@
   implements RequestEntity {
 
   private DataSource dataSource = null;
+  
+  public DataSourceRequestEntity(DataHandler dataHandler) {
+    this(dataHandler.getDataSource());
+  }
   
   public DataSourceRequestEntity(DataSource dataSource) {
     this.dataSource = dataSource;



Mime
View raw message