Subversion Repositories SmartDukaan

Rev

Blame | Last modification | View Log | RSS feed

package in.shop2020.datalogger.socialevent;

import in.shop2020.datalogger.SocialEventType;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.json.JSONObject;

public class SocialEvent {
        private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd/HH:mm:ss.SSS/zzz");
    protected Date time;
    protected String userId;
    protected SocialEventType eventType;
    
    public SocialEvent(String[] eventFileds) {
        try {
            time = sdf.parse(eventFileds[0].trim());
        } catch (ParseException e) {
            e.printStackTrace();
        }
        try {
            eventType = SocialEventType.valueOf(eventFileds[1].trim());
            userId = eventFileds[2].trim();
            
        } catch (ArrayIndexOutOfBoundsException e) {
            e.printStackTrace();
        }
    }
    
    public SocialEvent(SocialEventType eType, String aUserId) {
        eventType = eType;
        userId = aUserId;
    }

    public static SocialEvent createEvent(SocialEventType eType, String userId, String[] logData) {
        
        return new SocialEvent(eType, userId);
    }
    
    public static SocialEvent createEvent(String[] eventFileds) {
        return new SocialEvent(eventFileds);
    }
    
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(eventType.name() + ", ");
        sb.append(" user : " + userId);
        sb.append(" time : " + time);
        
        return sb.toString();
    }

    public JSONObject getLogDataInJson() {
        return null;
    }
    
    public Date getTime() {
        return time;
    }

    public void setTime(Date time) {
        this.time = time;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public SocialEventType getEventType() {
        return eventType;
    }
    
    public void setEventType(SocialEventType eventType) {
        this.eventType = eventType;
    }
}