endDate = reader.getAttributeValue(i);
endOpen = true;
}
}
EdgeDraft edge = container.factory().newEdgeDraft();
NodeDraft nodeSource = container.getNode(source);
NodeDraft nodeTarget = container.getNode(target);
edge.setSource(nodeSource);
edge.setTarget(nodeTarget);
//Type
if (!edgeType.isEmpty()) {
if (edgeType.equalsIgnoreCase("undirected")) {
edge.setType(EdgeDraft.EdgeType.UNDIRECTED);
} else if (edgeType.equalsIgnoreCase("directed")) {
edge.setType(EdgeDraft.EdgeType.DIRECTED);
} else if (edgeType.equalsIgnoreCase("mutual")) {
edge.setType(EdgeDraft.EdgeType.MUTUAL);
} else {
report.logIssue(new Issue(NbBundle.getMessage(ImporterGEXF.class, "importerGEXF_error_edgetype", edgeType, edge), Issue.Level.SEVERE));
}
}
//Id
if (!id.isEmpty()) {
edge.setId(id);
}
//Weight
if (!weight.isEmpty()) {
try {
float weightNumber = Float.parseFloat(weight);
edge.setWeight(weightNumber);
} catch (NumberFormatException e) {
report.logIssue(new Issue(NbBundle.getMessage(ImporterGEXF.class, "importerGEXF_error_edgeweight", edge), Issue.Level.WARNING));
}
}
//Label
if (!label.isEmpty()) {
edge.setLabel(label);
}
container.addEdge(edge);
boolean end = false;
boolean spells = false;
while (reader.hasNext() && !end) {
int type = reader.next();
switch (type) {
case XMLStreamReader.START_ELEMENT:
if (ATTVALUE.equalsIgnoreCase(xmlReader.getLocalName())) {
readEdgeAttValue(reader, edge);
} else if (EDGE_COLOR.equalsIgnoreCase(xmlReader.getLocalName())) {
readEdgeColor(reader, edge);
} else if (EDGE_SPELL.equalsIgnoreCase(xmlReader.getLocalName()) ||
EDGE_SPELL2.equalsIgnoreCase(xmlReader.getLocalName())) {
readEdgeSpell(reader, edge);
spells = true;
}
break;
case XMLStreamReader.END_ELEMENT:
if (EDGE.equalsIgnoreCase(xmlReader.getLocalName())) {
end = true;
}
break;
}
}
//Dynamic
if (!spells && (!startDate.isEmpty() || !endDate.isEmpty())) {
try {
edge.addTimeInterval(startDate, endDate, startOpen, endOpen);
} catch (IllegalArgumentException e) {
report.logIssue(new Issue(NbBundle.getMessage(ImporterGEXF.class, "importerGEXF_error_edge_timeinterval_parseerror", edge), Issue.Level.SEVERE));
}
}
}