Fixed CS

Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/93f76929
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/93f76929
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/93f76929

Branch: refs/heads/master
Commit: 93f76929e5515d0777729a7e8839aaaa747c111b
Parents: 04971dc
Author: Claus Ibsen <[email protected]>
Authored: Sat May 30 09:23:22 2015 +0200
Committer: Claus Ibsen <[email protected]>
Committed: Sat May 30 09:23:22 2015 +0200

----------------------------------------------------------------------
 .../component/twitter/TwitterConfiguration.java | 56 +++++++++++---------
 .../twitter/consumer/search/SearchConsumer.java | 49 +++++++++--------
 2 files changed, 55 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/93f76929/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterConfiguration.java
----------------------------------------------------------------------
diff --git 
a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterConfiguration.java
 
b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterConfiguration.java
index 9a47954..e8735ae 100644
--- 
a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterConfiguration.java
+++ 
b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterConfiguration.java
@@ -75,10 +75,9 @@ public class TwitterConfiguration {
     private Double longitude;
     @UriParam
     private Double radius;
-    @UriParam(defaultValue = "km")
+    @UriParam(defaultValue = "km", enums = "mi,km")
     private String distanceMetric;
-    
-    
+
     /**
      * Singleton, on demand instances of Twitter4J's Twitter & TwitterStream.
      * This should not be created by an endpoint's doStart(), etc., since
@@ -363,50 +362,57 @@ public class TwitterConfiguration {
     }
 
     public Double getLongitude() {
-       return longitude;
+        return longitude;
     }
 
     /**
-     * Used by the non-stream geography search.
-     * @param longitude
+     * Used by the non-stream geography search to search by longitude.
+     * <p/>
+     * You need to configure all the following options: longitude, latitude, 
radius, and distanceMetric.
      */
     public void setLongitude(Double longitude) {
-       this.longitude = longitude;
+        this.longitude = longitude;
     }
 
-    public Double getRadius() {
-       return radius;
+    public Double getLatitude() {
+        return latitude;
     }
 
     /**
-     * Used by the non-stream geography search.
-     * @param radius
+     * Used by the non-stream geography search to search by lattitude.
+     * <p/>
+     * You need to configure all the following options: longitude, latitude, 
radius, and distanceMetric.
      */
-    public void setRadius(Double radius) {
-       this.radius = radius;
+    public void setLatitude(Double latitude) {
+        this.latitude = latitude;
     }
 
-    public String getDistanceMetric() {
-       return distanceMetric;
+    public Double getRadius() {
+        return radius;
     }
 
     /**
-     * Used by the non-stream geography search, defaults to km.
-     * @param distanceMetric
+     * Used by the non-stream geography search to search by radius.
+     * <p/>
+     * You need to configure all the following options: longitude, latitude, 
radius, and distanceMetric.
      */
-    public void setDistanceMetric(String distanceMetric) {
-       this.distanceMetric = distanceMetric;
+    public void setRadius(Double radius) {
+        this.radius = radius;
     }
 
-    public Double getLatitude() {
-       return latitude;
+    public String getDistanceMetric() {
+        return distanceMetric;
     }
 
     /**
-     * Used by the non-stream geography search.
-     * @param latitude
+     * Used by the non-stream geography search, to search by radius using the 
configured metrics.
+     * <p/>
+     * The unit can either be mi for miles, or km for kilometers.
+     * <p/>
+     * You need to configure all the following options: longitude, latitude, 
radius, and distanceMetric.
      */
-    public void setLatitude(Double latitude) {
-       this.latitude = latitude;
+    public void setDistanceMetric(String distanceMetric) {
+        this.distanceMetric = distanceMetric;
     }
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/93f76929/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/search/SearchConsumer.java
----------------------------------------------------------------------
diff --git 
a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/search/SearchConsumer.java
 
b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/search/SearchConsumer.java
index d42c914..4b2cdf1 100644
--- 
a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/search/SearchConsumer.java
+++ 
b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/search/SearchConsumer.java
@@ -24,7 +24,6 @@ import 
org.apache.camel.component.twitter.consumer.Twitter4JConsumer;
 import org.apache.camel.util.ObjectHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
 import twitter4j.GeoLocation;
 import twitter4j.Query;
 import twitter4j.Query.Unit;
@@ -45,23 +44,23 @@ public class SearchConsumer extends Twitter4JConsumer {
     }
 
     public List<Status> pollConsume() throws TwitterException {
-       String keywords = te.getProperties().getKeywords();
+        String keywords = te.getProperties().getKeywords();
 
-       Query query;
+        Query query;
 
-       if(keywords!=null && keywords.trim().length() > 0) {
-               query = new Query(keywords);
-               LOG.debug("Searching twitter with keywords: {}", keywords);
-       } else {
-               query = new Query();
-               LOG.debug("Searching twitter without keywords.");
-       }
+        if (keywords != null && keywords.trim().length() > 0) {
+            query = new Query(keywords);
+            LOG.debug("Searching twitter with keywords: {}", keywords);
+        } else {
+            query = new Query();
+            LOG.debug("Searching twitter without keywords.");
+        }
 
-       if (te.getProperties().isFilterOld()) {
-               query.setSinceId(lastId);
-       }
+        if (te.getProperties().isFilterOld()) {
+            query.setSinceId(lastId);
+        }
 
-       return search(query);
+        return search(query);
     }
 
     public List<Status> directConsume() throws TwitterException {
@@ -70,14 +69,14 @@ public class SearchConsumer extends Twitter4JConsumer {
             return Collections.emptyList();
         }
         Query query = new Query(keywords);
-        
+
         LOG.debug("Searching twitter with keywords: {}", keywords);
         return search(query);
     }
 
     private List<Status> search(Query query) throws TwitterException {
         Integer numberOfPages = 1;
-        
+
         if (ObjectHelper.isNotEmpty(te.getProperties().getLang())) {
             query.setLang(te.getProperties().getLang());
         }
@@ -89,16 +88,16 @@ public class SearchConsumer extends Twitter4JConsumer {
         if (ObjectHelper.isNotEmpty(te.getProperties().getNumberOfPages())) {
             numberOfPages = te.getProperties().getNumberOfPages();
         }
-        
-        if (ObjectHelper.isNotEmpty(te.getProperties().getLatitude()) &&
-                       
ObjectHelper.isNotEmpty(te.getProperties().getLongitude()) &&
-                       
ObjectHelper.isNotEmpty(te.getProperties().getRadius())) {
-               GeoLocation location = new 
GeoLocation(te.getProperties().getLatitude(), 
te.getProperties().getLongitude());
-               query.setGeoCode(location, te.getProperties().getRadius(), 
Unit.valueOf(te.getProperties().getDistanceMetric()));
-
-               LOG.debug("Searching with additional geolocation parameters.");
+
+        if (ObjectHelper.isNotEmpty(te.getProperties().getLatitude())
+                && ObjectHelper.isNotEmpty(te.getProperties().getLongitude())
+                && ObjectHelper.isNotEmpty(te.getProperties().getRadius())) {
+            GeoLocation location = new 
GeoLocation(te.getProperties().getLatitude(), 
te.getProperties().getLongitude());
+            query.setGeoCode(location, te.getProperties().getRadius(), 
Unit.valueOf(te.getProperties().getDistanceMetric()));
+
+            LOG.debug("Searching with additional geolocation parameters.");
         }
-        
+
         LOG.debug("Searching with {} pages.", numberOfPages);
 
         Twitter twitter = te.getProperties().getTwitter();

Reply via email to