else {
value = null;
}
}
else if (attributeElements.getLength() > 1) {
throw new EOGeneralAdaptorException("There was more than one column named '" + columnName + "'.");
}
else {
Element attributeElement = (Element) attributeElements.item(0);
if ("true".equals(attributeElement.getAttribute("nil"))) {
value = null;
}
else {
String strValue = textValue(attributeElement);
if (attributeElement.hasAttribute("type")) {
String type = attributeElement.getAttribute("type");
if ("bigit".equals(type)) {
value = new BigDecimal(strValue);
}
else if ("boolean".equals(type)) {
value = Boolean.parseBoolean(strValue);
}
else if ("datetime".equals(type)) {
value = ERRESTAdaptorChannel.restDateFormat.parseObject(strValue);
}
else if ("double".equals(type)) {
value = Double.parseDouble(strValue);
}
else if ("float".equals(type)) {
value = Float.parseFloat(strValue);
}
else if ("integer".equals(type)) {
value = Integer.parseInt(strValue);
}
else if ("short".equals(type)) {
value = Short.parseShort(strValue);
}
else {
throw new IllegalArgumentException("Unknown type '" + type + "'.");
}
}
else {
value = convertValue(strValue, attribute);
}
}
}
if (value != null) {
row.setObjectForKey(value, attribute.name());
}
}
// Just in case you qualified against attributes that ended up not
// being returned in the results, we augment the resulting row
// with the key-value pairs from your qualifier.
if (attributesFromQualifier.count() > 0) {
for (String qualifierAttributeName : attributesFromQualifier.allKeys()) {
if (!row.containsKey(qualifierAttributeName)) {
EOAttribute qualifierAttribute = entity.attributeNamed(qualifierAttributeName);
if (qualifierAttribute != null && attributesToFetch.containsObject(qualifierAttribute)) {
row.setObjectForKey(attributesFromQualifier.objectForKey(qualifierAttributeName), qualifierAttributeName);
}
}
}
}
// Because we can only interpret parts of your qualifier, we now run the
// fetched dictionaries through the in-memory qualifier and let it weed
// out results using the more complicatd qualifiers.
EOQualifier qualifier = fetchSpecification.qualifier();
if (qualifier == null || qualifier.evaluateWithObject(row)) {
_fetchedRows.addObject(row);
}
else {
System.out.println("ERRESTAdaptorChannel.selectAttributes: skipping " + row + " (" + qualifier + ")");
}
}
}
catch (EOGeneralAdaptorException e) {
throw e;
}
catch (Throwable e) {
e.printStackTrace();
throw new EOGeneralAdaptorException("Failed to fetch '" + entity.name() + "' with fetch specification '" + fetchSpecification + "': " + e.getMessage());
}
}