package org.azavea.otm.data;

import org.json.JSONException;
import org.json.JSONObject;

public abstract class Model {
	protected JSONObject data;
	
	protected long getLongOrDefault(String key, Long defaultValue) throws JSONException {
		if (data.isNull(key)){ 
			return defaultValue;
		} else {
			return data.getLong(key);
		}
	}
	public void setData(JSONObject data) {
		this.data = data;
	}
	
	public JSONObject getData() {
		return data;
	}
}

package org.azavea.otm.data;

import org.json.JSONException;
import org.json.JSONObject;

public abstract class Model {
	protected JSONObject data;
	
	protected long getLongOrDefault(String key, Long defaultValue) throws JSONException {
		if (data.isNull(key)){ 
			return defaultValue;
		} else {
			return data.getLong(key);
		}
	}
	public void setData(JSONObject data) {
		this.data = data;
	}
	
	public JSONObject getData() {
		return data;
	}
	
	public Object getField(String key) {
		try {
			return data.get(key);
		} catch (JSONException e) {
			return null;
		}
	}
}

Add getField method to abstract model
Add getField method to abstract model

My future implementation of a Field class will depend on getting
plot data by field key, rather than through the model.  This opens
access to the underlaying JSON representation with keys identified
in the configuration details.
