Rev 3208 | Blame | Compare with Previous | Last modification | View Log | RSS feed
package in.shop2020.datalogger.event;import in.shop2020.datalogger.EventType;import java.util.ArrayList;import java.util.List;import java.util.StringTokenizer;import org.json.JSONArray;import org.json.JSONException;import org.json.JSONObject;public class PaymentFailure extends Event{private long paymentId;private List<Long> itemIds;public PaymentFailure(String[] eventFileds) {super(eventFileds);paymentId = Long.parseLong(eventFileds[5].trim());itemIds = new ArrayList<Long>();if (eventFileds.length > 6) {StringTokenizer tokenizer = new StringTokenizer(eventFileds[5].trim(), "_");while (tokenizer.hasMoreTokens()) {itemIds.add(Long.parseLong(tokenizer.nextToken().trim()));}}}public PaymentFailure(EventType eType, String sessionId, long userId, String email, String[] logData) {super(eType, sessionId, userId, email);paymentId = Long.parseLong(logData[0].trim());itemIds = new ArrayList<Long>();if (logData.length > 1) {StringTokenizer tokenizer = new StringTokenizer(logData[1].trim(), "_");while (tokenizer.hasMoreTokens()) {itemIds.add(Long.parseLong(tokenizer.nextToken().trim()));}}}public String toString() {StringBuilder sb = new StringBuilder();sb.append(eventType.name() + ", ");sb.append("userEmail : " + userEmail);sb.append(" paymentId : " + paymentId);sb.append(" itemIds : " + itemIds);sb.append(" time : " + time);sb.append(" session : " + sessionId);return sb.toString();}@Overridepublic JSONObject getLogDataInJson() {JSONObject logDataInJson = new JSONObject();try {logDataInJson.put("paymentId_long", paymentId);JSONArray itemIdsJson = new JSONArray(itemIds);logDataInJson.put("itemIds_long_list", itemIdsJson);} catch (JSONException e) {e.printStackTrace();}return logDataInJson;}public long getPaymentId() {return paymentId;}public void setPaymentId(long paymentId) {this.paymentId = paymentId;}public List<Long> getItemIds() {return itemIds;}public void setItemIds(List<Long> itemIds) {this.itemIds = itemIds;}}