Skip to content

Commit 2f65662

Browse files
committed
2 parents afa699b + 0cc1770 commit 2f65662

File tree

6 files changed

+84
-77
lines changed

6 files changed

+84
-77
lines changed

api/src/main/java/edu/cmu/chimps/messageontap_api/DataUtils.java

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import java.util.Map;
1616

1717
public class DataUtils {
18-
public static String hashMapToString(HashMap<String,Object> map){
18+
public static String hashMapToString(HashMap<String, Object> map) {
1919
Gson gson = new Gson();
2020
String json = gson.toJson(map);
2121
return json;
@@ -24,7 +24,7 @@ public static String hashMapToString(HashMap<String,Object> map){
2424
public static HashMap<String, Object> jsonToMap(JSONObject json) throws JSONException {
2525
HashMap<String, Object> retMap = new HashMap<String, Object>();
2626

27-
if(json != JSONObject.NULL) {
27+
if (json != JSONObject.NULL) {
2828
retMap = toMap(json);
2929
}
3030
return retMap;
@@ -34,15 +34,13 @@ public static HashMap<String, Object> toMap(JSONObject object) throws JSONExcept
3434
HashMap<String, Object> map = new HashMap<String, Object>();
3535

3636
Iterator<String> keysItr = object.keys();
37-
while(keysItr.hasNext()) {
37+
while (keysItr.hasNext()) {
3838
String key = keysItr.next();
3939
Object value = object.get(key);
4040

41-
if(value instanceof JSONArray) {
41+
if (value instanceof JSONArray) {
4242
value = toList((JSONArray) value);
43-
}
44-
45-
else if(value instanceof JSONObject) {
43+
} else if (value instanceof JSONObject) {
4644
value = toMap((JSONObject) value);
4745
}
4846
map.put(key, value);
@@ -52,37 +50,37 @@ else if(value instanceof JSONObject) {
5250

5351
public static List<Object> toList(JSONArray array) throws JSONException {
5452
List<Object> list = new ArrayList<Object>();
55-
for(int i = 0; i < array.length(); i++) {
53+
for (int i = 0; i < array.length(); i++) {
5654
Object value = array.get(i);
57-
if(value instanceof JSONArray) {
55+
if (value instanceof JSONArray) {
5856
value = toList((JSONArray) value);
59-
}
60-
61-
else if(value instanceof JSONObject) {
57+
} else if (value instanceof JSONObject) {
6258
value = toMap((JSONObject) value);
6359
}
6460
list.add(value);
6561
}
6662
return list;
6763
}
6864

69-
public static String SimpleObjectToJson(Object object,String typeKey){
70-
Gson gson=new Gson();
71-
switch (typeKey){
65+
public static String SimpleObjectToJson(Object object, String typeKey) {
66+
Gson gson = new Gson();
67+
switch (typeKey) {
7268
case Globals.TYPE_TRIGGER:
73-
Type type = new TypeToken<List<Trigger>>() {}.getType();
74-
return gson.toJson(object,type);
69+
Type type = new TypeToken<List<Trigger>>() {
70+
}.getType();
71+
return gson.toJson(object, type);
7572
default:
7673
return "";
7774
}
7875
}
7976

80-
public static Object JsonToSimpleObject(String json,String typeKey){
81-
Gson gson=new Gson();
82-
switch (typeKey){
77+
public static Object JsonToSimpleObject(String json, String typeKey) {
78+
Gson gson = new Gson();
79+
switch (typeKey) {
8380
case Globals.TYPE_TRIGGER:
84-
Type type = new TypeToken<List<Trigger>>() {}.getType();
85-
return gson.fromJson(json,type);
81+
Type type = new TypeToken<List<Trigger>>() {
82+
}.getType();
83+
return gson.fromJson(json, type);
8684
default:
8785
return "";
8886
}

api/src/main/java/edu/cmu/chimps/messageontap_api/EntityAttributes.java

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
public class EntityAttributes {
55

6-
public static class Person{
6+
public static class Person {
77
public static final String TYPE_KEY = "person_type_key";
88
public static final String PERSON_NAME = "person_name";
99
public static final String PHONE_NUMBER = "phone_number";
@@ -25,53 +25,59 @@ public static class Place {
2525
public static final String TYPE_KEY = "place_type_key";
2626
public static final String PLACE_NAME = "place_name";
2727
public static final String GPS_COORDINATE = "place_gps_coordinate";
28-
public static final String STREET_ADDRESS = "place_street_address";
29-
public static final String PLACE_TYPE="place_type";
28+
public static final String STREET_ADDRESS = "place_street_address";
29+
public static final String PLACE_TYPE = "place_type";
3030
public static final String NODE_ID = "person_node_id";
3131

3232
}
33+
3334
public static class Event {
34-
public static final String TYPE_KEY ="event_type_key";
35-
public static final String EVENT_NAME="event_name";
36-
public static final String START_TIME="event_start_time";
37-
public static final String END_TIME="event_end_time";
38-
public static final String EVENT_TYPE="event_type_name";
39-
public static final String CALENDAR_ID="calendar_id";
40-
public static final String EVENT_TIME="event_time";
35+
public static final String TYPE_KEY = "event_type_key";
36+
public static final String EVENT_NAME = "event_name";
37+
public static final String START_TIME = "event_start_time";
38+
public static final String END_TIME = "event_end_time";
39+
public static final String EVENT_TYPE = "event_type_name";
40+
public static final String CALENDAR_ID = "calendar_id";
41+
public static final String EVENT_TIME = "event_time";
4142
public static final String NODE_ID = "person_node_id";
4243
}
43-
public static class BrowserSearch{
44-
public static final String TYPE_KEY ="browser_search_type_key";
45-
public static final String BROWSER_SEARCH_TITLE="browser_search_title";
44+
45+
public static class BrowserSearch {
46+
public static final String TYPE_KEY = "browser_search_type_key";
47+
public static final String BROWSER_SEARCH_TITLE = "browser_search_title";
4648
}
47-
public static class BrowserVisit{
48-
public static final String TYPE_KEY ="browser_visit_type_key";
49-
public static final String BROWSER_VISIT_TITLE="browser_visit_title";
50-
public static final String BROWSER_VISIT_URL="browser_visit_url";
49+
50+
public static class BrowserVisit {
51+
public static final String TYPE_KEY = "browser_visit_type_key";
52+
public static final String BROWSER_VISIT_TITLE = "browser_visit_title";
53+
public static final String BROWSER_VISIT_URL = "browser_visit_url";
5154
}
55+
5256
public static class Flight {
53-
public static final String TYPE_KEY="flight_type_key";
54-
public static final String ARRIVAL_AIRPORT="arrival_airport";
55-
public static final String ARRIVAL_TIME="arrival_time";
56-
public static final String DEPARTURE_AIRPORT="departure_airport";
57-
public static final String DEPARTURE_TIME="departure_time";
58-
public static final String FLIGHT_NUMBER="flight_number";
59-
public static final String FLIGHT_SELLER="flight_seller";
57+
public static final String TYPE_KEY = "flight_type_key";
58+
public static final String ARRIVAL_AIRPORT = "arrival_airport";
59+
public static final String ARRIVAL_TIME = "arrival_time";
60+
public static final String DEPARTURE_AIRPORT = "departure_airport";
61+
public static final String DEPARTURE_TIME = "departure_time";
62+
public static final String FLIGHT_NUMBER = "flight_number";
63+
public static final String FLIGHT_SELLER = "flight_seller";
6064
}
65+
6166
public static class Ticket {
62-
public static final String TYPE_KEY="ticket_type_key";
63-
public static final String TICKET_NUMBER="ticket_number";
64-
public static final String TICKET_SEAT="ticket_seat";
65-
public static final String TICKET_OWNER="ticket_owner";
66-
public static final String TICKET_DESCRIPTION="ticket_description";
67+
public static final String TYPE_KEY = "ticket_type_key";
68+
public static final String TICKET_NUMBER = "ticket_number";
69+
public static final String TICKET_SEAT = "ticket_seat";
70+
public static final String TICKET_OWNER = "ticket_owner";
71+
public static final String TICKET_DESCRIPTION = "ticket_description";
6772
}
73+
6874
public static class Order {
69-
public static final String TYPE_KEY="order_type_key";
70-
public static final String ORDER_NUMBER="order_number";
71-
public static final String ORDER_SELLER="order_seller";
75+
public static final String TYPE_KEY = "order_type_key";
76+
public static final String ORDER_NUMBER = "order_number";
77+
public static final String ORDER_SELLER = "order_seller";
7278
}
7379

74-
public static class Document{
80+
public static class Document {
7581
public static final String TYPE_KEY = "drive_document_type_key";
7682
public static final String DOCUMENT_ID = "document_id";
7783
public static final String DOCUMENT_TITLE = "document_title";

api/src/main/java/edu/cmu/chimps/messageontap_api/Globals.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
package edu.cmu.chimps.messageontap_api;
2+
23
//TODO Change the Globals which could be downloaded from online server from PKG
34
public class Globals {
45

@@ -22,21 +23,21 @@ public class Globals {
2223
public final static String KEY_ACTION_UPDATE_CONTACT = "action_update_contact";
2324
public final static String KEY_ACTION_CREATE_GRAPH_NODE = "action_create_graph_node";
2425
public final static String KEY_ACTION_UPDATE_GRAPH_NODE = "action_update_graph_node";
25-
public final static String KEY_ACTION_MESSAGE_PERCEPTION = "action_message_perception";
26-
public final static String KEY_ACTION_UI = "action_ui";
26+
public final static String KEY_ACTION_MESSAGE_PERCEPTION = "action_message_perception";
27+
public final static String KEY_ACTION_UI = "action_ui";
2728

2829
public final static String KEY_ACTION = "action";
2930
public final static String KEY_QUERY_SUBJECT = "query_subject";
3031
public final static String KEY_QUERY_INFO = "query_info";
3132
public final static String KEY_QUERY_ID = "query_id";
32-
public final static String KEY_ATTRIBUTE_LIST="attribute_list";
33+
public final static String KEY_ATTRIBUTE_LIST = "attribute_list";
3334
//An action Type for representing doing nothing
34-
public final static String ACTION_UPDATE= "update";
35-
public final static String ACTION_SHOW= "show";
36-
public final static String ACTION_RETRIEVE= "retrieve";
35+
public final static String ACTION_UPDATE = "update";
36+
public final static String ACTION_SHOW = "show";
37+
public final static String ACTION_RETRIEVE = "retrieve";
3738
public final static String ACTION_ADD_EXACT = "add_exact";
38-
public final static String ACTION_END= "end";
39-
public final static String ACTION_CREATE = "create";
39+
public final static String ACTION_END = "end";
40+
public final static String ACTION_CREATE = "create";
4041

4142
//Object Type
4243
public final static String TYPE_TRIGGER = "trigger";

api/src/main/java/edu/cmu/chimps/messageontap_api/MessageData.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public MessageData response(String response) {
7777
* Returns the method
7878
* Default null.
7979
*/
80-
public String method(){
80+
public String method() {
8181
return mMethod;
8282
}
8383

@@ -120,7 +120,7 @@ public Bundle toBundle() {
120120
data.putLong(KEY_QUERYID, mQueryid);
121121
data.putString(KEY_REQUEST, mRequest);
122122
data.putString(KEY_RESPONSE, mResponse);
123-
data.putString(KEY_METHOD,mMethod);
123+
data.putString(KEY_METHOD, mMethod);
124124
return data;
125125
}
126126

api/src/main/java/edu/cmu/chimps/messageontap_api/MessageOnTapPlugin.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public abstract class MessageOnTapPlugin extends Service {
1919

2020
protected IPluginManager mManager;
2121

22-
private IBinder mBinder = new IPlugin.Stub(){
22+
private IBinder mBinder = new IPlugin.Stub() {
2323

2424
@Override
2525
public void onMessageReceived(MessageData data) throws RemoteException {
@@ -36,7 +36,7 @@ public PluginData getPluginData() throws RemoteException {
3636
public void registerManager(IPluginManager manager) throws RemoteException {
3737
String packageName = null;
3838
String[] packages = getPackageManager().getPackagesForUid(Binder.getCallingUid());
39-
if(packages!=null && packages.length>0){
39+
if (packages != null && packages.length > 0) {
4040
packageName = packages[0];
4141
}
4242
Log.e("plugin", "registering manager " + packageName);
@@ -50,7 +50,7 @@ public void registerManager(IPluginManager manager) throws RemoteException {
5050
public void unregisterManager(IPluginManager manager) throws RemoteException {
5151
String packageName = null;
5252
String[] packages = getPackageManager().getPackagesForUid(Binder.getCallingUid());
53-
if(packages!=null && packages.length>0){
53+
if (packages != null && packages.length > 0) {
5454
packageName = packages[0];
5555
}
5656
mManager = null;
@@ -86,5 +86,6 @@ public IBinder onBind(Intent intent) {
8686
}
8787

8888
protected abstract PluginData iPluginData();
89+
8990
protected abstract void analyzeMessage(MessageData data);
9091
}

api/src/main/java/edu/cmu/chimps/messageontap_api/Trigger.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,37 @@
1313
public class Trigger {
1414
private ArrayList<String> mTriggerKeyList;
1515
private String mPackageName;
16-
public Trigger(){
16+
17+
public Trigger() {
1718
mTriggerKeyList = new ArrayList<>();
1819
}
1920

20-
public Trigger(ArrayList<String> keyList){
21+
public Trigger(ArrayList<String> keyList) {
2122
mTriggerKeyList = keyList;
2223
}
2324

24-
public boolean activateTrigger(Set<String> set){
25-
for (String mKey : mTriggerKeyList){
26-
if(!set.contains(mKey)){
25+
public boolean activateTrigger(Set<String> set) {
26+
for (String mKey : mTriggerKeyList) {
27+
if (!set.contains(mKey)) {
2728
return false;
2829
}
2930
}
3031
return true;
3132
}
3233

33-
public String getPackageName(){
34+
public String getPackageName() {
3435
return mPackageName;
3536
}
3637

3738
public void setPackageName(String packageName) {
3839
mPackageName = packageName;
3940
}
4041

41-
public String getJson(){
42-
return DataUtils.SimpleObjectToJson(this,Globals.TYPE_TRIGGER);
42+
public String getJson() {
43+
return DataUtils.SimpleObjectToJson(this, Globals.TYPE_TRIGGER);
4344
}
4445

45-
public String getTypeKey(){
46+
public String getTypeKey() {
4647
return Globals.TYPE_TRIGGER;
4748
}
4849
}

0 commit comments

Comments
 (0)