Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2777 varun.gupt 1
package in.shop2020.datalogger.socialevent;
2
 
3
import in.shop2020.datalogger.SocialEventType;
4
 
5
import java.text.ParseException;
6
import java.text.SimpleDateFormat;
7
import java.util.Date;
8
 
9
import org.json.JSONObject;
10
 
11
public class SocialEvent {
12
	private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd/HH:mm:ss.SSS/zzz");
13
    protected Date time;
14
    protected String userId;
15
    protected SocialEventType eventType;
16
 
17
    public SocialEvent(String[] eventFileds) {
18
        try {
19
            time = sdf.parse(eventFileds[0].trim());
20
        } catch (ParseException e) {
21
            e.printStackTrace();
22
        }
23
        try {
24
            eventType = SocialEventType.valueOf(eventFileds[1].trim());
25
            userId = eventFileds[2].trim();
26
 
27
        } catch (ArrayIndexOutOfBoundsException e) {
28
            e.printStackTrace();
29
        }
30
    }
31
 
32
    public SocialEvent(SocialEventType eType, String aUserId) {
33
        eventType = eType;
34
        userId = aUserId;
35
    }
36
 
37
    public static SocialEvent createEvent(SocialEventType eType, String userId, String[] logData) {
38
 
39
        return new SocialEvent(eType, userId);
40
    }
41
 
42
    public static SocialEvent createEvent(String[] eventFileds) {
43
        return new SocialEvent(eventFileds);
44
    }
45
 
46
    public String toString() {
47
        StringBuilder sb = new StringBuilder();
48
        sb.append(eventType.name() + ", ");
49
        sb.append(" user : " + userId);
50
        sb.append(" time : " + time);
51
 
52
        return sb.toString();
53
    }
54
 
55
    public JSONObject getLogDataInJson() {
56
        return null;
57
    }
58
 
59
    public Date getTime() {
60
        return time;
61
    }
62
 
63
    public void setTime(Date time) {
64
        this.time = time;
65
    }
66
 
67
    public String getUserId() {
68
        return userId;
69
    }
70
 
71
    public void setUserId(String userId) {
72
        this.userId = userId;
73
    }
74
 
75
    public SocialEventType getEventType() {
76
        return eventType;
77
    }
78
 
79
    public void setEventType(SocialEventType eventType) {
80
        this.eventType = eventType;
81
    }
82
}