2010-01-24 22:09:50 +01:00
|
|
|
package com.metaweb.gridlock.model;
|
|
|
|
|
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-01 20:16:09 +01:00
|
|
|
import com.metaweb.gridlock.Jsonizable;
|
2010-01-27 02:48:42 +01:00
|
|
|
import com.metaweb.gridlock.expr.HasFields;
|
|
|
|
|
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-01-24 22:09:50 +01:00
|
|
|
public Object value;
|
|
|
|
public Recon recon;
|
2010-01-25 23:51:25 +01:00
|
|
|
|
2010-01-27 02:48:42 +01:00
|
|
|
@Override
|
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
|
|
|
|
|
|
|
@Override
|
|
|
|
public void write(JSONWriter writer, Properties options) throws JSONException {
|
|
|
|
writer.object();
|
|
|
|
writer.key("v");
|
|
|
|
writer.value(value);
|
|
|
|
|
|
|
|
if (recon != null && options.containsKey("cell-recon")) {
|
|
|
|
writer.key("recon");
|
|
|
|
recon.write(writer, options);
|
|
|
|
}
|
|
|
|
writer.endObject();
|
|
|
|
}
|
2010-01-24 22:09:50 +01:00
|
|
|
}
|