/************************************************************************************ * Copyright (C) 2008 by Politehnica University of Bucharest and Rutgers University * All rights reserved. * Refer to LICENSE for terms and conditions of use. ***********************************************************************************/ package vnsim.applications.vitp.utils; import java.util.*; import vnsim.map.object.*; public class VITPRequest extends VITPMessage { /** serialVersionUID */ private static final long serialVersionUID = -5883719321862303634L; private String method; //can be GET or POST private String uri; //the URI, as described in the VITP specification public VITPRequest( short road1IdxDst, short fromDst, short toDst, short road1IdxSrc, short fromSrc, short toSrc, Date initialTime, Date expirationTime, String cacheControl, int msgId, String msgBody, String method, String uri){ super(road1IdxDst, fromDst, toDst, road1IdxSrc, fromSrc, toSrc, initialTime, expirationTime, cacheControl, msgId, msgBody); this.uri=uri; this.method=method; this.type=VITP_REQ; } public boolean isPost(){ if(method!=null && method.equals("POST")) return true; return false; } public boolean isGet(){ if(method!=null && method.equals("GET")) return true; return false; } public String getMethod(){ return method; } public String getURI(){ return uri; } public void setURI(String uri){ this.uri=uri; } public String toString(){ String ret=super.toString(); ret=ret+";URI="+uri+";METHOD="+method+"--"; return ret; } public String getUserFriendlyText() { String ret=""; if(this.isPost()) { ret+="ATTENTION!\n"; } ret+="Message came from:\n"; Road r=(Road)Globals.map.roads.get(this.source.roadIndex); ret+="Road : "+r.getName(); Point ptmid=(Point)r.points.get((this.source.pt1+this.source.pt2)/2); Point pt1=(Point)r.points.get(this.source.pt1); Point pt2=(Point)r.points.get(this.source.pt2); ret+="\nSegment length: "+Math.abs(pt1.getDistance()-pt2.getDistance()); for(int i=0;i