-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStatusUtils.java
More file actions
53 lines (46 loc) · 1.05 KB
/
StatusUtils.java
File metadata and controls
53 lines (46 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import twitter4j.*;
/**
* @author Aashish Jain
* @version September 20, 2015
*/
public class StatusUtils
{
private static Status status;
public StatusUtils(Status s)
{
status = s;
}
public static boolean checkToFollow()
{
String statusText = status.getText().toLowerCase();
return statusText.contains("follow");
}
public static boolean checkToRetweet()
{
String statusText = status.getText().toLowerCase();
return (statusText.contains("rt") || statusText.contains("retweet"));
}
public static String getPersonToFollow()
{
String[] words = breakString();
for (int currentWord = 0; currentWord < words.length - 1; currentWord++)
{
String thisWord = words[currentWord];
if (thisWord.equals("rt") || thisWord.equals("follow"))
{
return (words[currentWord + 1]);
}
}
return null;
}
public static String[] breakString()
{
String s = status.getText().toLowerCase();
String[] words = s.split("\\s+");
for (int i = 0; i < words.length; i++)
{
words[i] = words[i].replaceAll("[^\\w]", "");
}
return words;
}
}