Simple answer:
inMemModel.removeAll(null, RDF.value, ResourceFactory.createPlainLiteral("class"));
That will remove all triples where the predicate is rdf:value
and object is "class"
.
Internally — at the SPI level you were trying — you could have used inMemModel.remove(Node.ANY, nodePredicate, nodeObject)
, which finds and deletes (using delete
) matching triples. delete
takes a ground triple and hence doesn't do a find.
createAnon()
doesn't work simply because it's a different subject, so there is nothing to delete.