Permalink
Browse files

TFJ-755 add support for language attribute in public stream

  • Loading branch information...
1 parent 7415661 commit 02043253906022c2c9c5e8b04943ca6313c7aedd @mpenet mpenet committed Feb 18, 2013
Showing with 36 additions and 0 deletions.
  1. +36 −0 twitter4j-stream/src/main/java/twitter4j/FilterQuery.java
@@ -41,6 +41,7 @@ public FilterQuery() {
this.follow = null;
this.track = null;
this.locations = null;
+ this.language = null;
}
/**
@@ -96,6 +97,22 @@ public FilterQuery(int count, long[] follow, String[] track, double[][] location
}
/**
+ * Creates a new FilterQuery
+ *
+ * @param count Indicates the number of previous statuses to stream before transitioning to the live stream.
+ * @param follow Specifies the users, by ID, to receive public tweets from.
+ * @param track Specifies keywords to track.
+ * @param locations Specifies the locations to track. 2D array
+ * @param language Specifies the tweets language of the stream
+ */
+ public FilterQuery(int count, long[] follow, String[] track, double[][] locations, String[] language) {
+ this.count = count;
+ this.follow = follow;
+ this.track = track;
+ this.language = language;
+ }
+
+ /**
* Sets count
*
* @param count Indicates the number of previous statuses to stream before transitioning to the live stream.
@@ -139,6 +156,18 @@ public FilterQuery locations(double[][] locations) {
return this;
}
+ /**
+ * Sets language
+ *
+ * @param language Specifies languages to track.
+ * @return this instance
+ */
+ public FilterQuery language(String[] language) {
+ this.language = language;
+ return this;
+ }
+
+
/*package*/ HttpParameter[] asHttpParameterArray(HttpParameter stallWarningsParam) {
ArrayList<HttpParameter> params = new ArrayList<HttpParameter>();
@@ -155,6 +184,10 @@ public FilterQuery locations(double[][] locations) {
params.add(new HttpParameter("locations"
, toLocationsString(locations)));
}
+ if (language != null && language.length > 0) {
+ params.add(new HttpParameter("language"
+ , z_T4JInternalStringUtil.join(language)));
+ }
params.add(stallWarningsParam);
HttpParameter[] paramArray = new HttpParameter[params.size()];
return params.toArray(paramArray);
@@ -183,6 +216,7 @@ public boolean equals(Object o) {
if (count != that.count) return false;
if (!Arrays.equals(follow, that.follow)) return false;
if (!Arrays.equals(track, that.track)) return false;
+ if (!Arrays.equals(language, that.language)) return false;
return true;
}
@@ -192,6 +226,7 @@ public int hashCode() {
int result = count;
result = 31 * result + (follow != null ? Arrays.hashCode(follow) : 0);
result = 31 * result + (track != null ? Arrays.hashCode(track) : 0);
+ result = 31 * result + (language != null ? Arrays.hashCode(language) : 0);
return result;
}
@@ -202,6 +237,7 @@ public String toString() {
", follow=" + Arrays.toString(follow) +
", track=" + (track == null ? null : Arrays.asList(track)) +
", locations=" + (locations == null ? null : Arrays.asList(locations)) +
+ ", language=" + (language == null ? null : Arrays.asList(language)) +
'}';
}
}

0 comments on commit 0204325

Please sign in to comment.