use of org.xmlcml.cml.element.CMLArray in project cdk by cdk.
the class QSARCustomizer method createScalar.
private Element createScalar(IDescriptorResult value) {
Element scalar;
if (value instanceof DoubleResult) {
scalar = new CMLScalar();
scalar.addAttribute(new Attribute("dataType", "xsd:double"));
scalar.appendChild("" + ((DoubleResult) value).doubleValue());
} else if (value instanceof IntegerResult) {
scalar = new CMLScalar();
scalar.addAttribute(new Attribute("dataType", "xsd:int"));
scalar.appendChild("" + ((IntegerResult) value).intValue());
} else if (value instanceof BooleanResult) {
scalar = new CMLScalar();
scalar.addAttribute(new Attribute("dataType", "xsd:boolean"));
scalar.appendChild("" + ((BooleanResult) value).booleanValue());
} else if (value instanceof IntegerArrayResult) {
IntegerArrayResult result = (IntegerArrayResult) value;
scalar = new CMLArray();
scalar.addAttribute(new Attribute("dataType", "xsd:int"));
scalar.addAttribute(new Attribute("size", "" + result.length()));
StringBuilder buffer = new StringBuilder();
for (int i = 0; i < result.length(); i++) {
buffer.append(result.get(i) + " ");
}
scalar.appendChild(buffer.toString());
} else if (value instanceof DoubleArrayResult) {
DoubleArrayResult result = (DoubleArrayResult) value;
scalar = new CMLArray();
scalar.addAttribute(new Attribute("dataType", "xsd:double"));
scalar.addAttribute(new Attribute("size", "" + result.length()));
StringBuilder buffer = new StringBuilder();
for (int i = 0; i < result.length(); i++) {
buffer.append(result.get(i) + " ");
}
scalar.appendChild(buffer.toString());
} else {
// logger.error("Could not convert this object to a scalar element: ", value);
scalar = new CMLScalar();
scalar.appendChild(value.toString());
}
return scalar;
}
Aggregations