/** * Finds the resource object matching the pattern <code>(s p _)</code>, asserts to find exactly * one result. * * @param s subject. * @param p predicate. * @return matching object. * @throws RepositoryException */ protected Resource findObjectAsResource(Resource s, URI p) throws RepositoryException { final Value v = findObject(s, p); try { return (Resource) v; } catch (ClassCastException cce) { Assert.fail("Expected resource object, found: " + v.getClass().getSimpleName()); throw new IllegalStateException(); } }
public NativeValue getNativeValue(Value value) { if (value instanceof Resource) { return getNativeResource((Resource) value); } else if (value instanceof Literal) { return getNativeLiteral((Literal) value); } else { throw new IllegalArgumentException("Unknown value type: " + value.getClass()); } }