2010-02-03 03:29:47 +01:00
|
|
|
package com.metaweb.gridworks.model;
|
2010-01-24 22:09:50 +01:00
|
|
|
|
2010-01-25 23:51:25 +01:00
|
|
|
import java.io.Serializable;
|
2010-01-27 02:48:42 +01:00
|
|
|
import java.util.Properties;
|
2010-01-25 23:51:25 +01:00
|
|
|
|
|
|
|
import org.json.JSONException;
|
2010-02-01 20:16:09 +01:00
|
|
|
import org.json.JSONWriter;
|
2010-01-25 23:51:25 +01:00
|
|
|
|
2010-02-03 03:29:47 +01:00
|
|
|
import com.metaweb.gridworks.Jsonizable;
|
|
|
|
import com.metaweb.gridworks.expr.HasFields;
|
2010-01-27 02:48:42 +01:00
|
|
|
|
2010-02-01 20:16:09 +01:00
|
|
|
public class Cell implements Serializable, HasFields, Jsonizable {
|
2010-01-25 23:51:25 +01:00
|
|
|
private static final long serialVersionUID = -5891067829205458102L;
|
|
|
|
|
2010-02-03 22:57:38 +01:00
|
|
|
final public Object value;
|
|
|
|
final public Recon recon;
|
|
|
|
|
|
|
|
public Cell(Object value, Recon recon) {
|
|
|
|
this.value = value;
|
|
|
|
this.recon = recon;
|
|
|
|
}
|
2010-01-25 23:51:25 +01:00
|
|
|
|
2010-02-01 00:15:50 +01:00
|
|
|
public Object getField(String name, Properties bindings) {
|
2010-01-27 02:48:42 +01:00
|
|
|
if ("value".equals(name)) {
|
|
|
|
return value;
|
2010-02-01 00:15:50 +01:00
|
|
|
} else if ("recon".equals(name)) {
|
|
|
|
return recon;
|
2010-01-27 02:48:42 +01:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2010-02-01 20:16:09 +01:00
|
|
|
|
|
|
|
public void write(JSONWriter writer, Properties options) throws JSONException {
|
|
|
|
writer.object();
|
|
|
|
writer.key("v");
|
|
|
|
writer.value(value);
|
|
|
|
|
2010-02-01 21:57:52 +01:00
|
|
|
if (recon != null) {
|
|
|
|
writer.key("r");
|
2010-02-01 20:16:09 +01:00
|
|
|
recon.write(writer, options);
|
|
|
|
}
|
|
|
|
writer.endObject();
|
|
|
|
}
|
2010-01-24 22:09:50 +01:00
|
|
|
}
|