@Test public void doesNotMatchObject() throws Exception { final StatementPatternMatcher matcher = new StatementPatternMatcher(getSp( "SELECT * WHERE {" + "?s ?p <urn:Bob> ." + "}")); final ValueFactory vf = SimpleValueFactory.getInstance(); final Statement statement = vf.createStatement(vf.createIRI("urn:Charlie"), vf.createIRI("urn:knows"), vf.createIRI("urn:Alice"), vf.createIRI("urn:testGraph")); final Optional<BindingSet> bs = matcher.match(statement); assertFalse(bs.isPresent()); }
public Optional<BindingSet> match(final Statement statement) { requireNonNull(statement); final QueryBindingSet bs = new QueryBindingSet(); if(matchesValue(pattern.getSubjectVar(), statement.getSubject(), bs) && matchesValue(pattern.getPredicateVar(), statement.getPredicate(), bs) && matchesValue(pattern.getObjectVar(), statement.getObject(), bs) && matchesContext(pattern.getContextVar(), statement.getContext(), bs)) { return Optional.of(bs); } else { return Optional.empty(); } }
StatementPatternMatcher { public Optional<BindingSet> match(final Statement statement) { requireNonNull(statement); final QueryBindingSet bs = new QueryBindingSet(); if(matchesValue(pattern.getSubjectVar(), statement.getSubject(), bs) && matchesValue(pattern.getPredicateVar(), statement.getPredicate(), bs) && matchesValue(pattern.getObjectVar(), statement.getObject(), bs) && matchesContext(pattern.getContextVar(), statement.getContext(), bs)) { return Optional.of(bs); } else { return Optional.empty(); } } }
StatementPatternMatcher { public Optional<BindingSet> match(final Statement statement) { requireNonNull(statement); final QueryBindingSet bs = new QueryBindingSet(); if(matchesValue(pattern.getSubjectVar(), statement.getSubject(), bs) && matchesValue(pattern.getPredicateVar(), statement.getPredicate(), bs) && matchesValue(pattern.getObjectVar(), statement.getObject(), bs) && matchesContext(pattern.getContextVar(), statement.getContext(), bs)) { return Optional.of(bs); } else { return Optional.empty(); } } StatementPatternMatcher(final StatementPattern pattern); }
StatementPatternMatcher { public Optional<BindingSet> match(final Statement statement) { requireNonNull(statement); final QueryBindingSet bs = new QueryBindingSet(); if(matchesValue(pattern.getSubjectVar(), statement.getSubject(), bs) && matchesValue(pattern.getPredicateVar(), statement.getPredicate(), bs) && matchesValue(pattern.getObjectVar(), statement.getObject(), bs) && matchesContext(pattern.getContextVar(), statement.getContext(), bs)) { return Optional.of(bs); } else { return Optional.empty(); } } StatementPatternMatcher(final StatementPattern pattern); Optional<BindingSet> match(final Statement statement); }
StatementPatternMatcher { public Optional<BindingSet> match(final Statement statement) { requireNonNull(statement); final QueryBindingSet bs = new QueryBindingSet(); if(matchesValue(pattern.getSubjectVar(), statement.getSubject(), bs) && matchesValue(pattern.getPredicateVar(), statement.getPredicate(), bs) && matchesValue(pattern.getObjectVar(), statement.getObject(), bs) && matchesContext(pattern.getContextVar(), statement.getContext(), bs)) { return Optional.of(bs); } else { return Optional.empty(); } } StatementPatternMatcher(final StatementPattern pattern); Optional<BindingSet> match(final Statement statement);  }