Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 3E95D200B9A for ; Fri, 7 Oct 2016 17:01:13 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 3D3C0160AE8; Fri, 7 Oct 2016 15:01:13 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 5358F160AF5 for ; Fri, 7 Oct 2016 17:01:12 +0200 (CEST) Received: (qmail 76092 invoked by uid 500); 7 Oct 2016 15:01:11 -0000 Mailing-List: contact commits-help@commonsrdf.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commonsrdf.incubator.apache.org Delivered-To: mailing list commits@commonsrdf.incubator.apache.org Received: (qmail 76083 invoked by uid 99); 7 Oct 2016 15:01:11 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Oct 2016 15:01:11 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 19EB21A08B7 for ; Fri, 7 Oct 2016 15:01:11 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -6.219 X-Spam-Level: X-Spam-Status: No, score=-6.219 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id z95D-dU7oOz6 for ; Fri, 7 Oct 2016 15:01:09 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id C3F3760DFB for ; Fri, 7 Oct 2016 15:01:06 +0000 (UTC) Received: (qmail 74624 invoked by uid 99); 7 Oct 2016 15:01:05 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Oct 2016 15:01:05 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 2D962E0999; Fri, 7 Oct 2016 15:01:05 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: stain@apache.org To: commits@commonsrdf.incubator.apache.org Date: Fri, 07 Oct 2016 15:01:43 -0000 Message-Id: In-Reply-To: <5d52302d6ad34704ae38a97ba65e6a3d@git.apache.org> References: <5d52302d6ad34704ae38a97ba65e6a3d@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [40/50] incubator-commonsrdf git commit: Option... instead of boolean parameters archived-at: Fri, 07 Oct 2016 15:01:13 -0000 Option... instead of boolean parameters Project: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/commit/7f4fe0b0 Tree: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/tree/7f4fe0b0 Diff: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/diff/7f4fe0b0 Branch: refs/heads/master Commit: 7f4fe0b04b3c56c4c205fbc55a9e1045ecce0d36 Parents: 756977a Author: Stian Soiland-Reyes Authored: Fri Oct 7 09:12:37 2016 +0100 Committer: Stian Soiland-Reyes Committed: Fri Oct 7 09:12:37 2016 +0100 ---------------------------------------------------------------------- .../commons/rdf/rdf4j/RDF4JTermFactory.java | 96 +++++++++----------- 1 file changed, 45 insertions(+), 51 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/7f4fe0b0/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.java ---------------------------------------------------------------------- diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.java index d35ed47..634648a 100644 --- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.java +++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.java @@ -17,6 +17,8 @@ */ package org.apache.commons.rdf.rdf4j; +import java.util.Arrays; +import java.util.EnumSet; import java.util.Objects; import java.util.Set; import java.util.UUID; @@ -102,6 +104,19 @@ public final class RDF4JTermFactory implements RDFTermFactory { private static InternalRDF4JFactory rdf4j = new InternalRDF4JFactory() { }; + public enum Option { + /** + * The Graph/Dataset should include any inferred statements + */ + includeInferred, + /** + * The graph/dataset should handle {@link Repository#initialize()} (if + * needed) and {@link Repository#shutDown()} on {@link Graph#close()} / + * {@link Dataset#close()}. + */ + handleInitAndShutdown + } + /** * Adapt a RDF4J {@link Value} as a Commons RDF {@link RDFTerm}. *

@@ -266,34 +281,18 @@ public final class RDF4JTermFactory implements RDFTermFactory { * {@link RepositoryConnection}s, including * {@link RDF4JDataset#iterate()}, * {@link RDF4JDataset#stream()} and {@link RDF4JDataset#getGraphNames()}. - * - * @param repository - * RDF4J {@link Repository} to connect to. - * @return A {@link Dataset} backed by the RDF4J repository. - */ - public RDF4JDataset asRDFTermDataset(Repository repository) { - return rdf4j.createRepositoryDatasetImpl(repository, false, false); - } - - /** - * Adapt an RDF4J {@link Repository} as a Commons RDF {@link Dataset}. - *

- * Changes to the dataset are reflected in the repository, and vice versa. - *

- * Note: Some operations on the {@link RDF4JDataset} - * requires the use of try-with-resources to close underlying - * {@link RepositoryConnection}s, including - * {@link RDF4JDataset#iterate()}, - * {@link RDF4JDataset#stream()} and {@link RDF4JDataset#getGraphNames()}. * * @param repository * RDF4J {@link Repository} to connect to. - * @param includeInferred - * If true, any inferred quads are included in the dataset + * @param options + * Zero or more {@link Option} * @return A {@link Dataset} backed by the RDF4J repository. */ - public RDF4JDataset asRDFTermDataset(Repository repository, boolean includeInferred) { - return rdf4j.createRepositoryDatasetImpl(repository, false, includeInferred); + public RDF4JDataset asRDFTermDataset(Repository repository, Option... options) { + EnumSet

- * The graph will include triples in any contexts (e.g. the union graph). - *

- * Changes to the graph are reflected in the repository, and vice versa. - *

- * Note: Some operations on the {@link RDF4JGraph} - * requires the use of try-with-resources to close underlying - * {@link RepositoryConnection}s, including - * {@link RDF4JGraph#iterate()} and - * {@link RDF4JGraph#stream()}. - * - * @param repository - * RDF4J {@link Repository} to connect to. - * @param includeInferred - * If true, any inferred triples are included in the graph - * @return A {@link Graph} backed by the RDF4J repository. - */ - public RDF4JGraph asRDFTermGraph(Repository repository, boolean includeInferred) { - return rdf4j.createRepositoryGraphImpl(repository, false, includeInferred); + return rdf4j.createRepositoryGraphImpl(Objects.requireNonNull(repository), + opts.contains(Option.handleInitAndShutdown), + opts.contains(Option.includeInferred), + resources); } /** @@ -598,4 +586,10 @@ public final class RDF4JTermFactory implements RDFTermFactory { return valueFactory; } + private EnumSet