/* Author: Jeff Dalton * Updated: Wed Nov 21 18:14:35 2001 by Jeff Dalton * Copyright: (c) 2001, AIAI, University of Edinburgh */ package ix.icore; import java.util.Map; import java.util.HashMap; import java.io.Serializable; import ix.icore.process.StatusValues; import ix.util.Debug; import ix.util.Util; /** * A report sent from another agent. */ public class Report implements Serializable, StatusValues { protected String text; protected int priority = PRIORITY_NONE; protected Map properties = new HashMap(5); public Report(String text) { this.text = text; } public String getText() { return text; } public int getPriority() { return priority; } public void setPriority(int priority) { this.priority = priority; } public Map getProperties() { return properties; } public void setProperties(Map properties) { this.properties = properties; } public String getSenderId() { return (String)properties.get("sender-id"); } public void setSenderId(String id) { properties.put("sender-id", id); } public String getRef() { return (String)properties.get("ref"); } public void setRef(String ref) { properties.put("ref", ref); } public String getReportType() { String type = (String)properties.get("report-type"); if (type != null) return type; String text = getText().trim().toLowerCase(); Debug.noteln("Setting report-type from report text", Util.quote(text)); if (!text.startsWith("done")) type = "progress"; else if (text.indexOf("no solutions") > -1) type = "failure"; else if (text.indexOf("failure") > -1) // is this used? /\/ type = "failure"; else type = "success"; setReportType(type); return type; } public void setReportType(String type) { properties.put("report-type", type); } public boolean isCompletion() { // It's not clear what the rules really are. /\/ // return !getReportType().equals("progress"); return getReportType().equals("success") || getReportType().equals("failure"); } public boolean isSuccess() { return getReportType().equals("success"); } public String toString() { return "report[" + text + "]"; } }