All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.cloudboost.QueueMessage Maven / Gradle / Ivy

There is a newer version: 1.0.7
Show newest version
package io.cloudboost;

import io.cloudboost.json.JSONException;
import io.cloudboost.json.JSONObject;

import java.util.ArrayList;

public class QueueMessage {
	private ACL acl;
	private long timeout=1800;
	private String message;
	private JSONObject document;
	private ArrayList _modifiedColumns;
	private String type="queue-message";
	public QueueMessage() {
		this._modifiedColumns = new ArrayList();
		this._modifiedColumns.add("createdAt");
		this._modifiedColumns.add("updatedAt");
		this._modifiedColumns.add("ACL");
		this._modifiedColumns.add("expires");
		this._modifiedColumns.add("timeout");
		this._modifiedColumns.add("delay");
		this._modifiedColumns.add("message");

		this.acl = new ACL();
		document = new JSONObject();
		try {
			document.put("_id", JSONObject.NULL);
			document.put("timeout", timeout);
			document.put("delay", JSONObject.NULL);

			document.put("_type",type);
			document.put("ACL", acl.getACL());
			document.put("expires", JSONObject.NULL);
			document.put("_modifiedColumns", this._modifiedColumns);
			document.put("_isModified", true);
			document.put("message", message);

		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public boolean hasKey(String key){
		return document.has(key);
	}
	public String getId(){
		return (String) getElement("_id");
	}
	public void setDelay(Object delay){
		addElement("delay", delay);
	}
	public void push(String message){
		this.message=message;
		addElement("message", message);
	
	}
	public ACL getAcl() {
		return (ACL) getElement("ACL");
	}
	public void setAcl(ACL acl) {
		addElement("ACL", acl);;
	}
	public long getTimeout() {
		return (long) getElement("timeout");
	}
	public void setTimeout(long timeout) {
		addElement("timeout",timeout);
	}
	public String getMessage() {
		return (String) getElement("message");
		
	}
	public void addElement(String key,Object val){
		try {
			document.put(key, val);
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public Object getElement(String key){
		Object obj=null;
		try {
			obj=document.get(key);
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return obj;
	}
	public void setMessage(String message) {
		addElement("message", message);
	}
	public JSONObject getDocument() {
		return document;
	}
	public void setDocument(JSONObject document) {
		this.document = document;
	}
	public ArrayList get_modifiedColumns() {
		return _modifiedColumns;
	}
	public void set_modifiedColumns(ArrayList _modifiedColumns) {
		this._modifiedColumns = _modifiedColumns;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy