incubator-droids-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject svn commit: r1445241 - in /incubator/droids/branches/0.2.x-cleanup/droids-core/src: main/java/org/apache/droids/handle/SysoutHandler.java test/java/org/apache/droids/core/SimpleTask.java
Date Tue, 12 Feb 2013 16:30:15 GMT
Author: tobr
Date: Tue Feb 12 16:30:15 2013
New Revision: 1445241

URL: http://svn.apache.org/r1445241
Log:
updated to support new ParserData API

Modified:
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/handle/SysoutHandler.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/test/java/org/apache/droids/core/SimpleTask.java

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/handle/SysoutHandler.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/handle/SysoutHandler.java?rev=1445241&r1=1445240&r2=1445241&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/handle/SysoutHandler.java
(original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/handle/SysoutHandler.java
Tue Feb 12 16:30:15 2013
@@ -16,9 +16,7 @@
  */
 package org.apache.droids.handle;
 
-import org.apache.droids.core.DroidsException;
-import org.apache.droids.core.Handler;
-import org.apache.droids.core.Task;
+import org.apache.droids.core.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -36,6 +34,10 @@ public class SysoutHandler extends Write
     private Set<String> attributes;
     private static final Logger logger = LoggerFactory.getLogger(SysoutHandler.class);
 
+    public static final String CONTENT = "CONTENT";
+    public static final String PARSERDATA = "PARSERDATA";
+    public static final String HEADERS = "HEADERS";
+
     public SysoutHandler() {
         this(new HashSet<String>());
     }
@@ -53,18 +55,30 @@ public class SysoutHandler extends Write
 
     @Override
     public void handle(Task task) throws IOException, DroidsException {
-        for (String key : task.getContentEntity().getData().keySet()) {
-            if (attributes.contains(key) || attributes.isEmpty()) {
-                if (task.getContentEntity().getValue(key) instanceof InputStream) {
-                    InputStream instream = (InputStream) task.getContentEntity().getValue(key);
-                    try {
-                        logger.info(key + ": ");
-                        writeOutput(instream);
-                    } finally {
-                        instream.close();
-                    }
-                } else {
-                    logger.info(key + ": " + task.getContentEntity().getValue(key).toString());
+        if (attributes.isEmpty() || attributes.contains(CONTENT)) {
+            InputStream instream = task.getContentEntity().getContent();
+            try {
+                logger.info("########## " + CONTENT + " ##########");
+                writeOutput(instream);
+            } finally {
+                instream.close();
+            }
+        }
+        if (attributes.isEmpty() || attributes.contains(HEADERS)) {
+            ContentEntity contentEntity = task.getContentEntity();
+            if (contentEntity != null) {
+                logger.info("########## " + HEADERS + " ##########");
+                for (String key : contentEntity.names()) {
+                    logger.info(key + ": " + contentEntity.get(key));
+                }
+            }
+        }
+        if (attributes.isEmpty() || attributes.contains(PARSERDATA)) {
+            ParserData parserData = task.getParserData();
+            if (parserData != null) {
+                logger.info("########## " + PARSERDATA + " ##########");
+                for (String key : parserData.names()) {
+                    logger.info(key + ": " + parserData.get(key));
                 }
             }
         }

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/test/java/org/apache/droids/core/SimpleTask.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/test/java/org/apache/droids/core/SimpleTask.java?rev=1445241&r1=1445240&r2=1445241&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/test/java/org/apache/droids/core/SimpleTask.java
(original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/test/java/org/apache/droids/core/SimpleTask.java
Tue Feb 12 16:30:15 2013
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.droids.core;
 
 import java.net.URI;
@@ -8,6 +24,7 @@ public class SimpleTask implements Task 
     private int depth;
     private boolean aborted;
     private ContentEntity contentEntity;
+    private ParserData parserData;
 
     private static final long serialVersionUID = 2506491803180939447L;
 
@@ -16,6 +33,7 @@ public class SimpleTask implements Task 
         this.depth = depth;
         this.aborted = false;
         this.contentEntity = new ContentEntity();
+        this.parserData = new ParserData();
     }
 
     @Override
@@ -24,6 +42,11 @@ public class SimpleTask implements Task 
     }
 
     @Override
+    public ParserData getParserData() {
+        return parserData;
+    }
+
+    @Override
     public URI getURI() {
         return uri;
     }



Mime
View raw message