@Override public void handleStatement(Statement st) throws RDFHandlerException { assertTrue(!stmt.equals(st)); } });
/** * Two ReasonerFacts are equivalent if they represent the same triple * (regardless of where it came from). If they don't contain triples, * compare their derivations. */ @Override public boolean equals(final Object o) { if (this == o) { return true; } if (o == null || this.getClass() != o.getClass()) { return false; } final Fact other = (Fact) o; if (this.triple == null) { if (other.triple == null) { // Derivations only matter if both facts are empty return this.getDerivation().equals(other.getDerivation()); } else { return false; } } else { return this.triple.equals(other.triple); } }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj instanceof Statement) { Statement other = (Statement)obj; return this.delegate.equals(other) && ((this.getContext() == null && other.getContext() == null) || (this.getContext() != null && other.getContext() != null && this.getContext().equals(other.getContext()))); } return false; }
@Test public void testStatementSerialization() throws Exception { testCon.add(bob, name, nameBob); Statement st; RepositoryResult<Statement> statements = testCon.getStatements(null, null, null, true); try { st = statements.next(); } finally { statements.close(); } ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(baos); out.writeObject(st); out.close(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream in = new ObjectInputStream(bais); Statement deserializedStatement = (Statement) in.readObject(); in.close(); assertTrue(st.equals(deserializedStatement)); assertTrue(testCon.hasStatement(st, true)); assertTrue(testCon.hasStatement(deserializedStatement, true)); }
private void copyDescription(Resource subject) throws IOException { Statement dedup = null; try (CloseableIteration<? extends Statement, SailException> it = sail.getStatements(subject, null, null, true)) { while (it.hasNext()) { Statement st = it.next(); if (!st.getPredicate().stringValue().startsWith(FILTER_NAMESPACE_PREFIX)) { st = SVF.createStatement(st.getSubject(), st.getPredicate(), st.getObject(), namedGraph); if (!st.equals(dedup)) { writer.handleStatement(st); } dedup = st; } } } if (splitOutput && fsOut.getPos() > outputLimit) { setupOutput(); } }