2010-02-10 02:15:25 +01:00
|
|
|
package com.metaweb.gridworks.protograph;
|
|
|
|
|
2010-02-11 07:44:48 +01:00
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.List;
|
2010-02-10 02:15:25 +01:00
|
|
|
import java.util.Properties;
|
|
|
|
|
|
|
|
import org.json.JSONException;
|
|
|
|
import org.json.JSONWriter;
|
|
|
|
|
2010-02-11 07:44:48 +01:00
|
|
|
public class CellTopicNode extends CellNode implements NodeWithLinks {
|
2010-03-03 05:19:58 +01:00
|
|
|
private static final long serialVersionUID = 1684854896739592911L;
|
|
|
|
|
|
|
|
final public boolean createForNoReconMatch;
|
|
|
|
final public FreebaseType type;
|
|
|
|
final public List<Link> links = new LinkedList<Link>();
|
|
|
|
|
|
|
|
public CellTopicNode(
|
|
|
|
String columnName,
|
|
|
|
boolean createForNoReconMatch,
|
|
|
|
FreebaseType type
|
|
|
|
) {
|
|
|
|
super(columnName);
|
|
|
|
|
|
|
|
this.createForNoReconMatch = createForNoReconMatch;
|
|
|
|
this.type = type;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void write(JSONWriter writer, Properties options)
|
|
|
|
throws JSONException {
|
|
|
|
|
|
|
|
writer.object();
|
|
|
|
writer.key("nodeType"); writer.value("cell-as-topic");
|
|
|
|
writer.key("columnName"); writer.value(columnName);
|
|
|
|
writer.key("createForNoReconMatch"); writer.value(createForNoReconMatch);
|
|
|
|
if (createForNoReconMatch && type != null) {
|
|
|
|
writer.key("type"); type.write(writer, options);
|
|
|
|
}
|
|
|
|
if (links != null) {
|
|
|
|
writer.key("links"); writer.array();
|
|
|
|
for (Link link : links) {
|
|
|
|
link.write(writer, options);
|
|
|
|
}
|
|
|
|
writer.endArray();
|
|
|
|
}
|
|
|
|
|
|
|
|
writer.endObject();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addLink(Link link) {
|
|
|
|
links.add(link);
|
|
|
|
}
|
|
|
|
|
|
|
|
public Link getLink(int index) {
|
|
|
|
return links.get(index);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getLinkCount() {
|
|
|
|
return links.size();
|
|
|
|
}
|
2010-02-10 02:15:25 +01:00
|
|
|
}
|