1 package cz.cuni.amis.pogamut.usar2004.agent.module.response; 2 3 import cz.cuni.amis.pogamut.usar2004.agent.module.datatypes.ResponseType; 4 import cz.cuni.amis.pogamut.usar2004.communication.messages.usarinfomessages.ResponseMessage; 5 6 /** 7 * Parent class for all possible response messages. It covers the basic and 8 * common properties for all the response subjects. 9 * 10 * @author vejmanm 11 */ 12 public abstract class SuperResponse 13 { 14 protected ResponseMessage lastMessage; 15 protected ResponseType type; 16 17 /** 18 * Ctor. 19 * 20 * @param type Response type describes particular subject about which we 21 * want to know about. It is used to distinguish incoming message from the 22 * server. 23 */ 24 public SuperResponse(ResponseType type) 25 { 26 this.type = type; 27 } 28 29 /** 30 * Used to make sure the object is filled. 31 * 32 * @return Returns true if the object is filled with Resp. message. 33 */ 34 public Boolean isReady() 35 { 36 return (lastMessage != null); 37 } 38 39 /** 40 * Timestamp form the UT since server start in seconds. 41 * 42 * @return Returns seconds elapsed from the start of the server. 43 */ 44 public double getTime() 45 { 46 return lastMessage.getTime(); 47 } 48 49 /** 50 * Type of the response will be one of the following: "ViewPorts”, “Camera”, 51 * or some type of sensor or effecter. 52 * 53 * @return Returns Type of the response. 54 */ 55 public String getType() 56 { 57 return lastMessage.getType(); 58 } 59 60 /** 61 * ResponseType is a descriptor used for creating particular instance and 62 * for getting type information about particular response message. 63 * 64 * @return Returns ResponseType. 65 */ 66 public ResponseType getResponseType() 67 { 68 return this.type; 69 } 70 71 /** 72 * Method used for updating the message object that provides particular 73 * properties for given type. Note that this object is created by yylex 74 * parser and contains properties for all configuration subject types. But 75 * only relevat to individual Response Subject are filled. 76 * 77 * @param message Response message from server. 78 */ 79 public void updateMessage(ResponseMessage message) 80 { 81 this.lastMessage = message; 82 } 83 }