MARMOTTA-484: added some javadoc
Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/1a4c3038 Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/1a4c3038 Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/1a4c3038 Branch: refs/heads/ldp Commit: 1a4c3038b7dd28d663fbad0e50d9c47d00e5dc6d Parents: 271622e Author: Jakob Frank <[email protected]> Authored: Fri Jun 6 12:39:25 2014 +0200 Committer: Jakob Frank <[email protected]> Committed: Fri Jun 6 12:39:25 2014 +0200 ---------------------------------------------------------------------- .../commons/sesame/test/SesameMatchers.java | 23 +++++++++++ .../test/connection/HasStatementMatcher.java | 42 ++++++++++++++++++-- 2 files changed, 62 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/marmotta/blob/1a4c3038/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/SesameMatchers.java ---------------------------------------------------------------------- diff --git a/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/SesameMatchers.java b/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/SesameMatchers.java index 4c2e503..5baabe0 100644 --- a/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/SesameMatchers.java +++ b/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/SesameMatchers.java @@ -42,10 +42,33 @@ import org.openrdf.rio.UnsupportedRDFormatException; */ public class SesameMatchers { + /** + * Create a RepositoryConnection Matcher checking if the provided Statement is contained in the Connection. + * + * @param subject the subject of the statement, use {@code null} as wildcard. + * @param predicate the predicate of the statement, use {@code null} as wildcard. + * @param object the object of the statement, use {@code null} as wildcard. + * @param contexts the contexts in which to look for the statement, use an empty varargs array to look in all contexts available. + * + * @see org.apache.marmotta.commons.sesame.test.connection.HasStatementMatcher + * @see org.openrdf.repository.RepositoryConnection#hasStatement(org.openrdf.model.Resource, org.openrdf.model.URI, org.openrdf.model.Value, boolean, org.openrdf.model.Resource...) + */ public static <T extends RepositoryConnection> Matcher<T> hasStatement(Resource subject, URI predicate, Value object, Resource... contexts) { return HasStatementMatcher.hasStatement(subject, predicate, object, contexts); } + /** + * Create a Repository Matcher checking if the provided Statement is contained in the Repository. + * + * @param subject the subject of the statement, use {@code null} as wildcard. + * @param predicate the predicate of the statement, use {@code null} as wildcard. + * @param object the object of the statement, use {@code null} as wildcard. + * @param contexts the contexts in which to look for the statement, use an empty varargs array to look in all contexts available. + * + * @see org.apache.marmotta.commons.sesame.test.base.RepositoryMatcher + * @see org.apache.marmotta.commons.sesame.test.connection.HasStatementMatcher + * @see org.openrdf.repository.RepositoryConnection#hasStatement(org.openrdf.model.Resource, org.openrdf.model.URI, org.openrdf.model.Value, boolean, org.openrdf.model.Resource...) + */ public static <T extends Repository> Matcher<T> repositoryHasStatement(Resource subject, URI predicate, Value object, Resource... contexts) { return RepositoryMatcher.wrap(hasStatement(subject, predicate, object,contexts)); } http://git-wip-us.apache.org/repos/asf/marmotta/blob/1a4c3038/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/connection/HasStatementMatcher.java ---------------------------------------------------------------------- diff --git a/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/connection/HasStatementMatcher.java b/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/connection/HasStatementMatcher.java index e04a7aa..e2dbbc1 100644 --- a/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/connection/HasStatementMatcher.java +++ b/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/connection/HasStatementMatcher.java @@ -35,18 +35,45 @@ public class HasStatementMatcher<T extends RepositoryConnection> extends Abstrac private final URI predicate; private final Value object; private final Resource[] contexts; + private final boolean includeInferred; - protected HasStatementMatcher(Resource subject, URI predicate, Value object, Resource... contexts) { + /** + * Create a RepositoryConnection Matcher checking if the provided Statement is contained in the Connection. + * @param subject the subject of the statement, use {@code null} as wildcard. + * @param predicate the predicate of the statement, use {@code null} as wildcard. + * @param object the object of the statement, use {@code null} as wildcard. + * @param contexts the contexts in which to look for the statement, use an empty varargs array to look in all contexts available. + * + * @see org.apache.marmotta.commons.sesame.test.connection.HasStatementMatcher + * @see org.openrdf.repository.RepositoryConnection#hasStatement(org.openrdf.model.Resource, org.openrdf.model.URI, org.openrdf.model.Value, boolean, org.openrdf.model.Resource...) + */ + public HasStatementMatcher(Resource subject, URI predicate, Value object, Resource... contexts) { + this(subject, predicate, object, true, contexts); + } + + /** + * Create a RepositoryConnection Matcher checking if the provided Statement is contained in the Connection. + * @param subject the subject of the statement, use {@code null} as wildcard. + * @param predicate the predicate of the statement, use {@code null} as wildcard. + * @param object the object of the statement, use {@code null} as wildcard. + * @param includeInferrred if false, no inferred statements are considered; if true, inferred statements are considered if available + * @param contexts the contexts in which to look for the statement, use an empty varargs array to look in all contexts available. + * + * @see org.apache.marmotta.commons.sesame.test.connection.HasStatementMatcher + * @see org.openrdf.repository.RepositoryConnection#hasStatement(org.openrdf.model.Resource, org.openrdf.model.URI, org.openrdf.model.Value, boolean, org.openrdf.model.Resource...) + */ + public HasStatementMatcher(Resource subject, URI predicate, Value object, boolean includeInferrred, Resource... contexts) { super(); this.subject = subject; this.predicate = predicate; this.object = object; + this.includeInferred = includeInferrred; this.contexts = contexts; } @Override protected boolean matchesConnection(RepositoryConnection con) throws RepositoryException { - return con.hasStatement(subject, predicate, object, true, contexts); + return con.hasStatement(subject, predicate, object, includeInferred, contexts); } @Override @@ -57,7 +84,16 @@ public class HasStatementMatcher<T extends RepositoryConnection> extends Abstrac .appendValue(object).appendText(")"); } - + /** + * Create a RepositoryConnection Matcher checking if the provided Statement is contained in the Connection. + * @param subject the subject of the statement, use {@code null} as wildcard. + * @param predicate the predicate of the statement, use {@code null} as wildcard. + * @param object the object of the statement, use {@code null} as wildcard. + * @param contexts the contexts in which to look for the statement, use an empty varargs array to look in all contexts available. + * + * @see org.apache.marmotta.commons.sesame.test.connection.HasStatementMatcher + * @see org.openrdf.repository.RepositoryConnection#hasStatement(org.openrdf.model.Resource, org.openrdf.model.URI, org.openrdf.model.Value, boolean, org.openrdf.model.Resource...) + */ public static <T extends RepositoryConnection> Matcher<T> hasStatement(Resource subject, URI predicate, Value object, Resource... contexts) { return new HasStatementMatcher<T>(subject, predicate, object, contexts); }
