private static DefaultLink readLink(JsonReader reader, Double[] weight) throws IOException {
String id = null;
Label label = null;
LinkType type = null;
String hNodeId = null;
ObjectPropertyType objectPropertyType = null;
String specializedLinkId = null;
LinkStatus status = null;
LinkKeyInfo keyInfo = null;
Set<String> modelIds = null;
if (weight == null) weight = new Double[1];
reader.beginObject();
while (reader.hasNext()) {
String key = reader.nextName();
if (key.equals("id") && reader.peek() != JsonToken.NULL) {
id = reader.nextString();
} else if (key.equals("label") && reader.peek() != JsonToken.NULL) {
label = readLabel(reader);
} else if (key.equals("type") && reader.peek() != JsonToken.NULL) {
type = LinkType.valueOf(reader.nextString());
} else if (key.equals("hNodeId") && reader.peek() != JsonToken.NULL) {
hNodeId = reader.nextString();
} else if (key.equals("objectPropertyType") && reader.peek() != JsonToken.NULL) {
objectPropertyType = ObjectPropertyType.valueOf(reader.nextString());
} else if (key.equals("specializedLinkId") && reader.peek() != JsonToken.NULL) {
specializedLinkId = reader.nextString();
} else if (key.equals("status") && reader.peek() != JsonToken.NULL) {
status = LinkStatus.valueOf(reader.nextString());
} else if (key.equals("keyInfo") && reader.peek() != JsonToken.NULL) {
keyInfo = LinkKeyInfo.valueOf(reader.nextString());
} else if (key.equals("modelIds") && reader.peek() != JsonToken.NULL) {
modelIds = readModelIds(reader);
} else if (key.equals("weight") && reader.peek() != JsonToken.NULL) {
weight[0] = new Double(reader.nextDouble());
} else {
reader.skipValue();
}
}
reader.endObject();
DefaultLink l = null;
if (type == LinkType.ClassInstanceLink) {
l = new ClassInstanceLink(id, keyInfo);
} else if (type == LinkType.ColumnSubClassLink) {
l = new ColumnSubClassLink(id);
} else if (type == LinkType.DataPropertyLink) {
l = new DataPropertyLink(id, label);
} else if (type == LinkType.DataPropertyOfColumnLink) {
l = new DataPropertyOfColumnLink(id, hNodeId, specializedLinkId);
} else if (type == LinkType.ObjectPropertyLink) {
l = new ObjectPropertyLink(id, label, objectPropertyType);
} else if (type == LinkType.ObjectPropertySpecializationLink) {
l = new ObjectPropertySpecializationLink(hNodeId, specializedLinkId);
} else if (type == LinkType.SubClassLink) {
l = new SubClassLink(id);
} else if (type == LinkType.CompactObjectPropertyLink) {
l = new CompactObjectPropertyLink(id, objectPropertyType);
} else if (type == LinkType.CompactSubClassLink) {
l = new CompactSubClassLink(id);
} else {
logger.error("cannot instanciate a link from the type: " + type.toString());
return null;
}
if (l instanceof LabeledLink) {
((LabeledLink)l).setStatus(status);