Skip to content

Commit 1535600

Browse files
committed
Task 3: Connect your new classes to the filter parser
1 parent 947d1fb commit 1535600

File tree

10 files changed

+377
-13
lines changed

10 files changed

+377
-13
lines changed
3.96 KB
Binary file not shown.
310 Bytes
Binary file not shown.
3.95 KB
Binary file not shown.
308 Bytes
Binary file not shown.
110 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

SoftwareConstruction_ObjectOrientedDesign/finalProject/final-project-starter/TwitterMapperStarter/src/filters/AndFilter.java

Lines changed: 186 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package filters;
22

3-
import twitter4j.Status;
3+
import twitter4j.*;
44

55
import java.util.ArrayList;
6+
import java.util.Date;
67
import java.util.List;
78

89
/**
@@ -25,7 +26,7 @@ public AndFilter(Filter child, Filter child1) {
2526
* @return 2 status are matches
2627
*/
2728
public boolean matches(Status s0, Status s1) {
28-
return child0.matches(s0) && child1.matches(s1) || child0.matches(s1) && child1.matches(s0);
29+
return (child0.matches(s0) && child1.matches(s1)) || (child0.matches(s1) && child1.matches(s0));
2930
}
3031

3132
@Override
@@ -35,17 +36,197 @@ public boolean matches(Status s) {
3536

3637
@Override
3738
public List<String> terms() {
38-
return child0.terms();
39+
// return child0.terms();
40+
return andTerms();
3941
}
4042

4143
public List<String> andTerms() {
42-
ArrayList<String> terms = new ArrayList<>();
44+
List<String> terms = new ArrayList<>();
4345
terms.add(String.valueOf(child0.terms()));
4446
terms.add(String.valueOf(child1.terms()));
4547
return terms;
4648
}
4749

4850
public String toString() {
49-
return child1.toString() + " and " + child0.toString();
51+
return "(" + child1.toString() + " and " + child0.toString() + ")";
52+
}
53+
54+
private Status makeStatus(String text) {
55+
return new Status() {
56+
@Override
57+
public Date getCreatedAt() {
58+
return null;
59+
}
60+
61+
@Override
62+
public long getId() {
63+
return 0;
64+
}
65+
66+
@Override
67+
public String getText() {
68+
return text;
69+
}
70+
71+
@Override
72+
public String getSource() {
73+
return null;
74+
}
75+
76+
@Override
77+
public boolean isTruncated() {
78+
return false;
79+
}
80+
81+
@Override
82+
public long getInReplyToStatusId() {
83+
return 0;
84+
}
85+
86+
@Override
87+
public long getInReplyToUserId() {
88+
return 0;
89+
}
90+
91+
@Override
92+
public String getInReplyToScreenName() {
93+
return null;
94+
}
95+
96+
@Override
97+
public GeoLocation getGeoLocation() {
98+
return null;
99+
}
100+
101+
@Override
102+
public Place getPlace() {
103+
return null;
104+
}
105+
106+
@Override
107+
public boolean isFavorited() {
108+
return false;
109+
}
110+
111+
@Override
112+
public boolean isRetweeted() {
113+
return false;
114+
}
115+
116+
@Override
117+
public int getFavoriteCount() {
118+
return 0;
119+
}
120+
121+
@Override
122+
public User getUser() {
123+
return null;
124+
}
125+
126+
@Override
127+
public boolean isRetweet() {
128+
return false;
129+
}
130+
131+
@Override
132+
public Status getRetweetedStatus() {
133+
return null;
134+
}
135+
136+
@Override
137+
public long[] getContributors() {
138+
return new long[0];
139+
}
140+
141+
@Override
142+
public int getRetweetCount() {
143+
return 0;
144+
}
145+
146+
@Override
147+
public boolean isRetweetedByMe() {
148+
return false;
149+
}
150+
151+
@Override
152+
public long getCurrentUserRetweetId() {
153+
return 0;
154+
}
155+
156+
@Override
157+
public boolean isPossiblySensitive() {
158+
return false;
159+
}
160+
161+
@Override
162+
public String getLang() {
163+
return null;
164+
}
165+
166+
@Override
167+
public Scopes getScopes() {
168+
return null;
169+
}
170+
171+
@Override
172+
public String[] getWithheldInCountries() {
173+
return new String[0];
174+
}
175+
176+
@Override
177+
public long getQuotedStatusId() {
178+
return 0;
179+
}
180+
181+
@Override
182+
public Status getQuotedStatus() {
183+
return null;
184+
}
185+
186+
@Override
187+
public int compareTo(Status o) {
188+
return 0;
189+
}
190+
191+
@Override
192+
public UserMentionEntity[] getUserMentionEntities() {
193+
return new UserMentionEntity[0];
194+
}
195+
196+
@Override
197+
public URLEntity[] getURLEntities() {
198+
return new URLEntity[0];
199+
}
200+
201+
@Override
202+
public HashtagEntity[] getHashtagEntities() {
203+
return new HashtagEntity[0];
204+
}
205+
206+
@Override
207+
public MediaEntity[] getMediaEntities() {
208+
return new MediaEntity[0];
209+
}
210+
211+
@Override
212+
public ExtendedMediaEntity[] getExtendedMediaEntities() {
213+
return new ExtendedMediaEntity[0];
214+
}
215+
216+
@Override
217+
public SymbolEntity[] getSymbolEntities() {
218+
return new SymbolEntity[0];
219+
}
220+
221+
@Override
222+
public RateLimitStatus getRateLimitStatus() {
223+
return null;
224+
}
225+
226+
@Override
227+
public int getAccessLevel() {
228+
return 0;
229+
}
230+
};
50231
}
51232
}

0 commit comments

Comments
 (0)