/* ************************************************************************
#
#  DivConq
#
#  http://divconq.com/
#
#  Copyright:
#    Copyright 2012 eTimeline, LLC. All rights reserved.
#
#  License:
#    See the license.txt file in the project's top-level directory for details.
#
#  Authors:
#    * Andy White
#
************************************************************************ */
package divconq.bus;

import divconq.struct.RecordStruct;

/*
 * Service, Attachments, Extension are all reserved headers - Feature and Op semi-reserved.  All other headers are fine as long as the don't start with _.
 */

public class Message extends RecordStruct {
	//private HashMap<String, String> headers = new HashMap<String, String>();
    //private List<Memory> attachments = new ArrayList<Memory>();
	private boolean delivered = false;
    
	public Message() { }
	
	public Message(String service) {
		this.setField("Service", service);
	}
	
	public Message(String service, String feature, String op, Object body) {
		this.setField("Service", service);
		this.setField("Feature", feature);
		this.setField("Op", op);
		
		if (body != null)
			this.setField("Body", body);
	}

	public void setDelivered(boolean b) {
		this.delivered = b;
	}
	
	public boolean getDelivered() {
		return this.delivered;
	}

	public boolean hasError() {
		return (this.getFieldAsInteger("Result") > 0);
	}
}
