![David Huynh](/assets/img/avatar_default.png)
git-svn-id: http://google-refine.googlecode.com/svn/trunk@95 7d457c2a-affb-35e4-300a-418c747d4874
48 lines
1.1 KiB
Java
48 lines
1.1 KiB
Java
package com.metaweb.gridworks.protograph;
|
|
|
|
import java.util.LinkedList;
|
|
import java.util.List;
|
|
import java.util.Properties;
|
|
|
|
import org.json.JSONException;
|
|
import org.json.JSONWriter;
|
|
|
|
public class AnonymousNode implements Node, NodeWithLinks {
|
|
private static final long serialVersionUID = -6956243664838720646L;
|
|
|
|
final public FreebaseType type;
|
|
final public List<Link> links = new LinkedList<Link>();
|
|
|
|
public AnonymousNode(FreebaseType type) {
|
|
this.type = type;
|
|
}
|
|
|
|
public void write(JSONWriter writer, Properties options)
|
|
throws JSONException {
|
|
|
|
writer.object();
|
|
writer.key("nodeType"); writer.value("anonymous");
|
|
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();
|
|
}
|
|
}
|