}
if (property) {
return;
}
} else {
report.logIssue(new Issue(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_error_attributeempty", title), Issue.Level.SEVERE));
return;
}
if (!property && type.isEmpty()) {
report.logIssue(new Issue(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_error_attributetype1", title), Issue.Level.SEVERE));
type = "string";
}
if (!property) {
//Class type
if (forStr.isEmpty() || !(forStr.equalsIgnoreCase("node") || forStr.equalsIgnoreCase("edge") || forStr.equalsIgnoreCase("all"))) {
report.logIssue(new Issue(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_error_attributeclass", title), Issue.Level.SEVERE));
return;
}
//Default?
boolean end = false;
boolean defaultFlag = false;
while (reader.hasNext() && !end) {
int xmltype = reader.next();
switch (xmltype) {
case XMLStreamReader.START_ELEMENT:
if (ATTRIBUTE_DEFAULT.equalsIgnoreCase(xmlReader.getLocalName())) {
defaultFlag = true;
}
break;
case XMLStreamReader.CHARACTERS:
if (defaultFlag && !xmlReader.isWhiteSpace()) {
defaultStr = xmlReader.getText();
}
break;
case XMLStreamReader.END_ELEMENT:
if (ATTRIBUTE.equalsIgnoreCase(xmlReader.getLocalName())) {
end = true;
}
break;
}
}
//Type
Class attributeType = String.class;
if (type.equalsIgnoreCase("boolean") || type.equalsIgnoreCase("bool")) {
attributeType = boolean.class;
} else if (type.equalsIgnoreCase("integer") || type.equalsIgnoreCase("int")) {
attributeType = int.class;
} else if (type.equalsIgnoreCase("long")) {
attributeType = Long.class;
} else if (type.equalsIgnoreCase("float")) {
attributeType = Float.class;
} else if (type.equalsIgnoreCase("double")) {
attributeType = Double.class;
} else if (type.equalsIgnoreCase("string")) {
attributeType = String.class;
} else if (type.equalsIgnoreCase("bigdecimal")) {
attributeType = BigDecimal.class;
} else if (type.equalsIgnoreCase("biginteger")) {
attributeType = BigInteger.class;
} else if (type.equalsIgnoreCase("byte")) {
attributeType = Byte.class;
} else if (type.equalsIgnoreCase("char")) {
attributeType = Character.class;
} else if (type.equalsIgnoreCase("short")) {
attributeType = Short.class;
} else if (type.equalsIgnoreCase("listboolean")) {
attributeType = boolean[].class;
} else if (type.equalsIgnoreCase("listint")) {
attributeType = int[].class;
} else if (type.equalsIgnoreCase("listlong")) {
attributeType = long[].class;
} else if (type.equalsIgnoreCase("listfloat")) {
attributeType = float[].class;
} else if (type.equalsIgnoreCase("listdouble")) {
attributeType = double[].class;
} else if (type.equalsIgnoreCase("liststring")) {
attributeType = String[].class;
} else if (type.equalsIgnoreCase("listbigdecimal")) {
attributeType = BigDecimal[].class;
} else if (type.equalsIgnoreCase("listbiginteger")) {
attributeType = BigInteger[].class;
} else if (type.equalsIgnoreCase("listbyte")) {
attributeType = byte[].class;
} else if (type.equalsIgnoreCase("listchar")) {
attributeType = char[].class;
} else if (type.equalsIgnoreCase("listshort")) {
attributeType = short[].class;
} else {
report.logIssue(new Issue(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_error_attributetype2", type), Issue.Level.SEVERE));
return;
}
//Add to model
ColumnDraft column = null;
if ("node".equalsIgnoreCase(forStr) || "all".equalsIgnoreCase(forStr)) {
if (container.getNodeColumn(id) != null) {
report.log(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_error_attributecolumn_exist", id));
return;
}
column = container.addNodeColumn(id, attributeType);
column.setTitle(title);
report.log(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_log_nodeattribute", title, attributeType.getCanonicalName()));
} else if ("edge".equalsIgnoreCase(forStr) || "all".equalsIgnoreCase(forStr)) {
if (container.getEdgeColumn(id) != null) {
report.log(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_error_attributecolumn_exist", id));
return;
}
column = container.addEdgeColumn(id, attributeType);
column.setTitle(title);
report.log(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_log_edgeattribute", title, attributeType.getCanonicalName()));
}
if (column != null && !defaultStr.isEmpty()) {
try {
column.setDefaultValueString(defaultStr);
report.log(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_log_default", defaultStr, title));
} catch (Exception e) {
report.logIssue(new Issue(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_error_attributedefault", title, attributeType.getCanonicalName()), Issue.Level.SEVERE));
}
}
} else {
report.logIssue(new Issue(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_error_attributeempty", title), Issue.Level.SEVERE));
}
}