Jena 3.1.1 upgrade - Fixing broken string literal reading code.
@@ -41,6 +41,8 @@ import org.apache.jena.rdf.model.AnonId;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.Property;
import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.rdf.model.Statement;
+import org.apache.jena.rdf.model.impl.PropertyImpl;
import org.apache.jena.util.iterator.ExtendedIterator;
/**
@@ -319,21 +321,16 @@ public abstract class RdfModelObject implements IRdfModel, Cloneable {
if (this.model == null || this.node == null) {
return null;
}
- Node p = model.getProperty(namespace, propertyName).asNode();
- Triple m = Triple.createMatch(node, p, null);
- ExtendedIterator<Triple> tripleIter = model.getGraph().find(m);
- while (tripleIter.hasNext()) {
- Triple t = tripleIter.next();
- if (t.getObject().isURI()) {
- // check for predefined
- String retval = PRE_DEFINED_URI_VALUE.get(t.getObject().getURI());
- if (retval != null) {
- return retval;
- }
- }
- return t.getObject().toString(false);
+
+ Statement stmt = resource.getProperty(new PropertyImpl(namespace, propertyName));
+ if (stmt == null) return null;
+ else if (stmt.getObject().isLiteral()){
+ return stmt.getObject().asLiteral().getString();
+ } else if (stmt.getObject().isResource()){
+ return PRE_DEFINED_URI_VALUE.get(stmt.getObject().asResource().getURI());
+ } else {
+ return stmt.getObject().toString();
}
- return null;
}
/**
@@ -427,7 +424,7 @@ public abstract class RdfModelObject implements IRdfModel, Cloneable {
Resource valueResource = this.model.createResource(valueUri);
this.resource.addProperty(p, valueResource);
} else {
- this.resource.addProperty(p, values[i]);
+ this.resource.addLiteral(p, values[i]);
}
}
}
