Add support to parse typed literal values
@@ -349,11 +349,15 @@ public abstract class RdfModelObject implements IRdfModel, Cloneable {
while (tripleIter.hasNext()) {
Triple t = tripleIter.next();
if (t.getObject().isLiteral()) {
- String sRetval = t.getObject().toString(false);
+ Object retval = t.getObject().getLiteralValue();
+ if (retval instanceof Integer) {
+ return (Integer)retval;
+ } else if (retval instanceof String) {
try {
- return Integer.parseInt(sRetval);
+ return Integer.parseInt((String)retval);
} catch (Exception ex) {
- return null;
+ // ignore - we'll go on to the next object and return null if there are no integers
+ }
}
}
}
