package cc.events;

import java.net.DatagramPacket;

public class Event {
	private long timestamp = 0;
	private long timestampDiff = 0;
	private int label = 0;
	private int size = 0;
	private int delay = 0;
	private boolean pairPacket;

	public Event(Object obj) {
		DatagramPacket p = (DatagramPacket) obj;

		timestamp = System.currentTimeMillis();
		
		java.util.StringTokenizer st =
			new java.util.StringTokenizer(new String(p.getData()), ";");

		label = (new Integer(st.nextToken())).intValue();
		timestampDiff = timestamp - (new Long(st.nextToken())).longValue();
		size = (new Integer(st.nextToken())).intValue();
		delay = (new Integer(st.nextToken())).intValue();
		if (st.nextToken().equals("p")) 
			pairPacket = true;
		else
			pairPacket = false;
	}

	/**
	 * @return
	 */
	public int getDelay() {
		return delay;
	}

	/**
	 * @return
	 */
	public int getLabel() {
		return label;
	}

	/**
	 * @return
	 */
	public int getSize() {
		return size;
	}

	public boolean getIsPair() {
		return pairPacket;
	}

	/**
	 * @return
	 */
	public long getTimestamp() {
		return timestamp;
	}

	/**
	 * @return
	 */
	public long getTimestampDiff() {
		return timestampDiff;
	}

}
