TrustGrapher  r52
A playabale simulator for modelling trust between agents
D:/src/cu/trustGrapher/eventplayer/TrustLogEvent.java
Go to the documentation of this file.
00001 
00002 package cu.trustGrapher.eventplayer;
00003 
00004 import aohara.utilities.ChatterBox;
00005 
00011 public class TrustLogEvent {
00012     private int assessor;
00013     private int assessee;
00014     private double feedback;
00015     private String string;
00016 
00018 
00021     public TrustLogEvent(String str) {
00022         //Line format: assessor,assessee,feedback
00023         try{
00024             string = str;
00025             str.trim();
00026             String [] words = str.split(",");          
00027             assessor = Integer.parseInt(words[0]);
00028             assessee = Integer.parseInt(words[1]);
00029             feedback = (double) Double.parseDouble(words[2]);
00030             if (feedback < 0.0 || feedback > 1.0) {
00031                 ChatterBox.error("trustGrapher.visualizer.eventPlayer.LogEvent", "LogEvent()", "The feedback (" + feedback + ") was not in the specified range of [0,1].  I am setting the feedback to 0.5");
00032                 feedback = 0.5;
00033             }
00034         }catch (Exception ex){
00035             ChatterBox.error("TrustLogEvent", "TrustLogEvent()", "The log format is incorrect.");
00036             ex.printStackTrace();
00037         }
00038     }
00039 
00041 
00042     public double getFeedback() {
00043         return feedback;
00044     }
00045 
00046     public int getAssessor() {
00047         return assessor;
00048     }
00049 
00050     public int getAssessee() {
00051         return assessee;
00052     }
00053 
00054     public Object[] toArray() {
00055         Object[] array = {(new Integer(assessor)), (new Integer(assessee)), feedback};
00056         return array;
00057     }
00058 
00059     @Override
00060     public String toString() {
00061         return string;
00062     }
00063 }
00065