Skip to content

Commit

Permalink
TFJ-755 add support for language attribute in public stream
Browse files Browse the repository at this point in the history
  • Loading branch information
mpenet committed Feb 18, 2013
1 parent 7415661 commit 0204325
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions twitter4j-stream/src/main/java/twitter4j/FilterQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public FilterQuery() {
this.follow = null;
this.track = null;
this.locations = null;
this.language = null;
}

/**
Expand Down Expand Up @@ -95,6 +96,22 @@ public FilterQuery(int count, long[] follow, String[] track, double[][] location
this.locations = locations;
}

/**
* 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
*
Expand Down Expand Up @@ -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>();

Expand All @@ -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);
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}

Expand All @@ -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.