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 0419F200BC5 for ; Tue, 22 Nov 2016 08:56:13 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 02AD4160B21; Tue, 22 Nov 2016 07:56: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 A07B3160B1C for ; Tue, 22 Nov 2016 08:56:10 +0100 (CET) Received: (qmail 7284 invoked by uid 500); 22 Nov 2016 07:56:09 -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 7256 invoked by uid 99); 22 Nov 2016 07:56:09 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Nov 2016 07:56:09 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id DE1A0C72BC for ; Tue, 22 Nov 2016 07:56:08 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.199 X-Spam-Level: X-Spam-Status: No, score=-1.199 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id eAOc3s2QApy6 for ; Tue, 22 Nov 2016 07:56:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 6CB7E5FB25 for ; Tue, 22 Nov 2016 07:55:58 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 6DA0AE8EB4 for ; Tue, 22 Nov 2016 07:55:45 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 6ACA53A0248 for ; Tue, 22 Nov 2016 07:55:45 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1001470 [31/36] - in /websites/production/commonsrdf/content: ./ apidocs/ apidocs/org/apache/commons/rdf/api/ apidocs/org/apache/commons/rdf/api/class-use/ apidocs/org/apache/commons/rdf/experimental/ apidocs/org/apache/commons/rdf/experim... Date: Tue, 22 Nov 2016 07:55:40 -0000 To: commits@commonsrdf.incubator.apache.org From: wikier@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20161122075545.6ACA53A0248@svn01-us-west.apache.org> archived-at: Tue, 22 Nov 2016 07:56:13 -0000 Modified: websites/production/commonsrdf/content/xref/org/apache/commons/rdf/rdf4j/experimental/RDF4JParser.html ============================================================================== --- websites/production/commonsrdf/content/xref/org/apache/commons/rdf/rdf4j/experimental/RDF4JParser.html (original) +++ websites/production/commonsrdf/content/xref/org/apache/commons/rdf/rdf4j/experimental/RDF4JParser.html Tue Nov 22 07:55:35 2016 @@ -38,43 +38,43 @@ 30 import org.apache.commons.rdf.api.IRI; 31 import org.apache.commons.rdf.api.Quad; 32 import org.apache.commons.rdf.api.RDFSyntax; -33 import org.apache.commons.rdf.experimental.RDFParser; +33 import org.apache.commons.rdf.rdf4j.RDF4J; 34 import org.apache.commons.rdf.rdf4j.RDF4JBlankNodeOrIRI; 35 import org.apache.commons.rdf.rdf4j.RDF4JDataset; 36 import org.apache.commons.rdf.rdf4j.RDF4JGraph; -37 import org.apache.commons.rdf.rdf4j.RDF4J; -38 import org.apache.commons.rdf.simple.experimental.AbstractRDFParser; -39 import org.eclipse.rdf4j.model.Model; -40 import org.eclipse.rdf4j.model.Resource; -41 import org.eclipse.rdf4j.repository.util.RDFInserter; -42 import org.eclipse.rdf4j.repository.util.RDFLoader; -43 import org.eclipse.rdf4j.rio.ParserConfig; -44 import org.eclipse.rdf4j.rio.RDFFormat; -45 import org.eclipse.rdf4j.rio.RDFHandler; -46 import org.eclipse.rdf4j.rio.RDFHandlerException; -47 import org.eclipse.rdf4j.rio.Rio; -48 import org.eclipse.rdf4j.rio.helpers.AbstractRDFHandler; -49 -50 /** -51 * RDF4J-based parser. -52 * <p> -53 * This can handle the RDF syntaxes {@link RDFSyntax#JSONLD}, -54 * {@link RDFSyntax#NQUADS}, {@link RDFSyntax#NTRIPLES}, -55 * {@link RDFSyntax#RDFXML}, {@link RDFSyntax#TRIG} and {@link RDFSyntax#TURTLE} -56 * - additional syntaxes can be supported by including the corresponding -57 * <em>rdf4j-rio-*</em> module on the classpath. -58 * -59 */ -60 public class RDF4JParser extends AbstractRDFParser<RDF4JParser> implements RDFParser { -61 -62 private final class AddToQuadConsumer extends AbstractRDFHandler { -63 private final Consumer<Quad> quadTarget; -64 -65 private AddToQuadConsumer(Consumer<Quad> quadTarget) { -66 this.quadTarget = quadTarget; -67 } -68 -69 public void handleStatement(org.eclipse.rdf4j.model.Statement st) +37 import org.apache.commons.rdf.simple.experimental.AbstractRDFParser; +38 import org.eclipse.rdf4j.model.Model; +39 import org.eclipse.rdf4j.model.Resource; +40 import org.eclipse.rdf4j.repository.util.RDFInserter; +41 import org.eclipse.rdf4j.repository.util.RDFLoader; +42 import org.eclipse.rdf4j.rio.ParserConfig; +43 import org.eclipse.rdf4j.rio.RDFFormat; +44 import org.eclipse.rdf4j.rio.RDFHandler; +45 import org.eclipse.rdf4j.rio.RDFHandlerException; +46 import org.eclipse.rdf4j.rio.Rio; +47 import org.eclipse.rdf4j.rio.helpers.AbstractRDFHandler; +48 +49 /** +50 * RDF4J-based parser. +51 * <p> +52 * This can handle the RDF syntaxes {@link RDFSyntax#JSONLD}, +53 * {@link RDFSyntax#NQUADS}, {@link RDFSyntax#NTRIPLES}, +54 * {@link RDFSyntax#RDFXML}, {@link RDFSyntax#TRIG} and {@link RDFSyntax#TURTLE} +55 * - additional syntaxes can be supported by including the corresponding +56 * <em>rdf4j-rio-*</em> module on the classpath. +57 * +58 */ +59 public class RDF4JParser extends AbstractRDFParser<RDF4JParser> { +60 +61 private final class AddToQuadConsumer extends AbstractRDFHandler { +62 private final Consumer<Quad> quadTarget; +63 +64 private AddToQuadConsumer(final Consumer<Quad> quadTarget) { +65 this.quadTarget = quadTarget; +66 } +67 +68 @Override +69 public void handleStatement(final org.eclipse.rdf4j.model.Statement st) 70 throws org.eclipse.rdf4j.rio.RDFHandlerException { 71 // TODO: if getRdfTermFactory() is a non-rdf4j factory, should 72 // we use factory.createQuad() instead? @@ -94,154 +94,155 @@ 86 private final static class AddToModel extends AbstractRDFHandler { 87 private final Model model; 88 -89 public AddToModel(Model model) { +89 public AddToModel(final Model model) { 90 this.model = model; 91 } 92 -93 public void handleStatement(org.eclipse.rdf4j.model.Statement st) -94 throws org.eclipse.rdf4j.rio.RDFHandlerException { -95 model.add(st); -96 } -97 -98 @Override -99 public void handleNamespace(String prefix, String uri) throws RDFHandlerException { -100 model.setNamespace(prefix, uri); -101 } -102 } -103 -104 private RDF4J rdf4jTermFactory; -105 private ParserConfig parserConfig = new ParserConfig(); -106 -107 @Override -108 protected RDF4J createRDFTermFactory() { -109 return new RDF4J(); -110 } -111 -112 @Override -113 protected RDF4JParser prepareForParsing() throws IOException, IllegalStateException { -114 RDF4JParser c = super.prepareForParsing(); -115 // Ensure we have an RDF4J for conversion. -116 // We'll make a new one if user has provided a non-RDF4J factory -117 c.rdf4jTermFactory = (RDF4J) getRdfTermFactory().filter(RDF4J.class::isInstance) -118 .orElseGet(c::createRDFTermFactory); -119 return c; -120 } -121 -122 @Override -123 protected void parseSynchronusly() throws IOException { -124 Optional<RDFFormat> formatByMimeType = getContentType().flatMap(Rio::getParserFormatForMIMEType); -125 String base = getBase().map(IRI::getIRIString).orElse(null); -126 -127 ParserConfig parserConfig = getParserConfig(); -128 // TODO: Should we need to set anything? -129 RDFLoader loader = new RDFLoader(parserConfig, rdf4jTermFactory.getValueFactory()); -130 RDFHandler rdfHandler = makeRDFHandler(); -131 if (getSourceFile().isPresent()) { -132 // NOTE: While we could have used -133 // loader.load(sourcePath.toFile() -134 // if the path fs provider == FileSystems.getDefault(), -135 // that RDFLoader method does not use absolute path -136 // as the base URI, so to be consistent -137 // we'll always do it with our own input stream -138 // -139 // That means we may have to guess format by extensions: -140 Optional<RDFFormat> formatByFilename = getSourceFile().map(Path::getFileName).map(Path::toString) -141 .flatMap(Rio::getParserFormatForFileName); -142 // TODO: for the excited.. what about the extension after following -143 // symlinks? -144 -145 RDFFormat format = formatByMimeType.orElse(formatByFilename.orElse(null)); -146 try (InputStream in = Files.newInputStream(getSourceFile().get())) { -147 loader.load(in, base, format, rdfHandler); -148 } -149 } else if (getSourceIri().isPresent()) { -150 try { -151 // TODO: Handle international IRIs properly -152 // (Unicode support for for hostname, path and query) -153 URL url = new URL(getSourceIri().get().getIRIString()); -154 // TODO: This probably does not support https:// -> http:// -155 // redirections -156 loader.load(url, base, formatByMimeType.orElse(null), makeRDFHandler()); -157 } catch (MalformedURLException ex) { -158 throw new IOException("Can't handle source URL: " + getSourceIri().get(), ex); -159 } -160 } -161 // must be getSourceInputStream then, this is guaranteed by -162 // super.checkSource(); -163 loader.load(getSourceInputStream().get(), base, formatByMimeType.orElse(null), rdfHandler); -164 } -165 -166 /** -167 * Get the RDF4J {@link ParserConfig} to use. -168 * <p> -169 * If no parser config is set, the default configuration is provided. -170 * <p> -171 * <strong>Note:</strong> The parser config is mutable - changes in the -172 * returned config is reflected in this instance of the parser. To avoid -173 * mutation, create a new {@link ParserConfig} and set -174 * {@link #setParserConfig(ParserConfig)}. -175 * -176 * @return The RDF4J {@link ParserConfig} -177 */ -178 public ParserConfig getParserConfig() { -179 return parserConfig; -180 } -181 -182 /** -183 * Set an RDF4J {@link ParserConfig} to use -184 * -185 * @param parserConfig -186 * Parser configuration -187 */ -188 public void setParserConfig(ParserConfig parserConfig) { -189 this.parserConfig = parserConfig; -190 } -191 -192 protected RDFHandler makeRDFHandler() { -193 -194 // TODO: Can we join the below DF4JDataset and RDF4JGraph cases -195 // using RDF4JGraphLike<TripleLike<BlankNodeOrIRI,IRI,RDFTerm>> -196 // or will that need tricky generics types? -197 -198 if (getTargetDataset().filter(RDF4JDataset.class::isInstance).isPresent()) { -199 // One of us, we can add them as Statements directly -200 RDF4JDataset dataset = (RDF4JDataset) getTargetDataset().get(); -201 if (dataset.asRepository().isPresent()) { -202 return new RDFInserter(dataset.asRepository().get().getConnection()); -203 } -204 if (dataset.asModel().isPresent()) { -205 Model model = dataset.asModel().get(); -206 return new AddToModel(model); -207 } -208 // Not backed by Repository or Model? -209 // Third-party RDF4JDataset subclass, so we'll fall through to the -210 // getTarget() handling further down -211 } else if (getTargetGraph().filter(RDF4JGraph.class::isInstance).isPresent()) { -212 RDF4JGraph graph = (RDF4JGraph) getTargetGraph().get(); -213 -214 if (graph.asRepository().isPresent()) { -215 RDFInserter inserter = new RDFInserter(graph.asRepository().get().getConnection()); -216 if (!graph.getContextMask().isEmpty()) { -217 Stream<RDF4JBlankNodeOrIRI> b = graph.getContextMask().stream(); -218 Stream<Resource> c = b.map(RDF4JBlankNodeOrIRI::asValue); -219 Resource[] contexts = c.toArray(Resource[]::new); -220 inserter.enforceContext(contexts); -221 } -222 return inserter; -223 } -224 if (graph.asModel().isPresent() && graph.getContextMask().isEmpty()) { -225 // the model accepts any quad -226 Model model = graph.asModel().get(); -227 return new AddToModel(model); -228 } -229 // else - fall through -230 } -231 -232 // Fall thorough: let target() consume our converted quads. -233 return new AddToQuadConsumer(getTarget()); -234 } -235 -236 } +93 @Override +94 public void handleStatement(final org.eclipse.rdf4j.model.Statement st) +95 throws org.eclipse.rdf4j.rio.RDFHandlerException { +96 model.add(st); +97 } +98 +99 @Override +100 public void handleNamespace(final String prefix, final String uri) throws RDFHandlerException { +101 model.setNamespace(prefix, uri); +102 } +103 } +104 +105 private RDF4J rdf4jTermFactory; +106 private ParserConfig parserConfig = new ParserConfig(); +107 +108 @Override +109 protected RDF4J createRDFTermFactory() { +110 return new RDF4J(); +111 } +112 +113 @Override +114 protected RDF4JParser prepareForParsing() throws IOException, IllegalStateException { +115 final RDF4JParser c = super.prepareForParsing(); +116 // Ensure we have an RDF4J for conversion. +117 // We'll make a new one if user has provided a non-RDF4J factory +118 c.rdf4jTermFactory = (RDF4J) getRdfTermFactory().filter(RDF4J.class::isInstance) +119 .orElseGet(c::createRDFTermFactory); +120 return c; +121 } +122 +123 @Override +124 protected void parseSynchronusly() throws IOException { +125 final Optional<RDFFormat> formatByMimeType = getContentType().flatMap(Rio::getParserFormatForMIMEType); +126 final String base = getBase().map(IRI::getIRIString).orElse(null); +127 +128 final ParserConfig parserConfig = getParserConfig(); +129 // TODO: Should we need to set anything? +130 final RDFLoader loader = new RDFLoader(parserConfig, rdf4jTermFactory.getValueFactory()); +131 final RDFHandler rdfHandler = makeRDFHandler(); +132 if (getSourceFile().isPresent()) { +133 // NOTE: While we could have used +134 // loader.load(sourcePath.toFile() +135 // if the path fs provider == FileSystems.getDefault(), +136 // that RDFLoader method does not use absolute path +137 // as the base URI, so to be consistent +138 // we'll always do it with our own input stream +139 // +140 // That means we may have to guess format by extensions: +141 final Optional<RDFFormat> formatByFilename = getSourceFile().map(Path::getFileName).map(Path::toString) +142 .flatMap(Rio::getParserFormatForFileName); +143 // TODO: for the excited.. what about the extension after following +144 // symlinks? +145 +146 final RDFFormat format = formatByMimeType.orElse(formatByFilename.orElse(null)); +147 try (InputStream in = Files.newInputStream(getSourceFile().get())) { +148 loader.load(in, base, format, rdfHandler); +149 } +150 } else if (getSourceIri().isPresent()) { +151 try { +152 // TODO: Handle international IRIs properly +153 // (Unicode support for for hostname, path and query) +154 final URL url = new URL(getSourceIri().get().getIRIString()); +155 // TODO: This probably does not support https:// -> http:// +156 // redirections +157 loader.load(url, base, formatByMimeType.orElse(null), makeRDFHandler()); +158 } catch (final MalformedURLException ex) { +159 throw new IOException("Can't handle source URL: " + getSourceIri().get(), ex); +160 } +161 } +162 // must be getSourceInputStream then, this is guaranteed by +163 // super.checkSource(); +164 loader.load(getSourceInputStream().get(), base, formatByMimeType.orElse(null), rdfHandler); +165 } +166 +167 /** +168 * Get the RDF4J {@link ParserConfig} to use. +169 * <p> +170 * If no parser config is set, the default configuration is provided. +171 * <p> +172 * <strong>Note:</strong> The parser config is mutable - changes in the +173 * returned config is reflected in this instance of the parser. To avoid +174 * mutation, create a new {@link ParserConfig} and set +175 * {@link #setParserConfig(ParserConfig)}. +176 * +177 * @return The RDF4J {@link ParserConfig} +178 */ +179 public ParserConfig getParserConfig() { +180 return parserConfig; +181 } +182 +183 /** +184 * Set an RDF4J {@link ParserConfig} to use +185 * +186 * @param parserConfig +187 * Parser configuration +188 */ +189 public void setParserConfig(final ParserConfig parserConfig) { +190 this.parserConfig = parserConfig; +191 } +192 +193 protected RDFHandler makeRDFHandler() { +194 +195 // TODO: Can we join the below DF4JDataset and RDF4JGraph cases +196 // using RDF4JGraphLike<TripleLike<BlankNodeOrIRI,IRI,RDFTerm>> +197 // or will that need tricky generics types? +198 +199 if (getTargetDataset().filter(RDF4JDataset.class::isInstance).isPresent()) { +200 // One of us, we can add them as Statements directly +201 final RDF4JDataset dataset = (RDF4JDataset) getTargetDataset().get(); +202 if (dataset.asRepository().isPresent()) { +203 return new RDFInserter(dataset.asRepository().get().getConnection()); +204 } +205 if (dataset.asModel().isPresent()) { +206 final Model model = dataset.asModel().get(); +207 return new AddToModel(model); +208 } +209 // Not backed by Repository or Model? +210 // Third-party RDF4JDataset subclass, so we'll fall through to the +211 // getTarget() handling further down +212 } else if (getTargetGraph().filter(RDF4JGraph.class::isInstance).isPresent()) { +213 final RDF4JGraph graph = (RDF4JGraph) getTargetGraph().get(); +214 +215 if (graph.asRepository().isPresent()) { +216 final RDFInserter inserter = new RDFInserter(graph.asRepository().get().getConnection()); +217 if (!graph.getContextMask().isEmpty()) { +218 final Stream<RDF4JBlankNodeOrIRI> b = graph.getContextMask().stream(); +219 final Stream<Resource> c = b.map(RDF4JBlankNodeOrIRI::asValue); +220 final Resource[] contexts = c.toArray(Resource[]::new); +221 inserter.enforceContext(contexts); +222 } +223 return inserter; +224 } +225 if (graph.asModel().isPresent() && graph.getContextMask().isEmpty()) { +226 // the model accepts any quad +227 final Model model = graph.asModel().get(); +228 return new AddToModel(model); +229 } +230 // else - fall through +231 } +232 +233 // Fall thorough: let target() consume our converted quads. +234 return new AddToQuadConsumer(getTarget()); +235 } +236 +237 }
Modified: websites/production/commonsrdf/content/xref/org/apache/commons/rdf/rdf4j/experimental/package-frame.html ============================================================================== --- websites/production/commonsrdf/content/xref/org/apache/commons/rdf/rdf4j/experimental/package-frame.html (original) +++ websites/production/commonsrdf/content/xref/org/apache/commons/rdf/rdf4j/experimental/package-frame.html Tue Nov 22 07:55:35 2016 @@ -3,7 +3,7 @@ - Commons RDF 0.3.0-incubating Reference Package org.apache.commons.rdf.rdf4j.experimental + Commons RDF 0.4.0-incubating-SNAPSHOT Reference Package org.apache.commons.rdf.rdf4j.experimental Modified: websites/production/commonsrdf/content/xref/org/apache/commons/rdf/rdf4j/experimental/package-summary.html ============================================================================== --- websites/production/commonsrdf/content/xref/org/apache/commons/rdf/rdf4j/experimental/package-summary.html (original) +++ websites/production/commonsrdf/content/xref/org/apache/commons/rdf/rdf4j/experimental/package-summary.html Tue Nov 22 07:55:35 2016 @@ -3,7 +3,7 @@ - Commons RDF 0.3.0-incubating Reference Package org.apache.commons.rdf.rdf4j.experimental + Commons RDF 0.4.0-incubating-SNAPSHOT Reference Package org.apache.commons.rdf.rdf4j.experimental Modified: websites/production/commonsrdf/content/xref/org/apache/commons/rdf/rdf4j/impl/AbstractRDFTerm.html ============================================================================== --- websites/production/commonsrdf/content/xref/org/apache/commons/rdf/rdf4j/impl/AbstractRDFTerm.html (original) +++ websites/production/commonsrdf/content/xref/org/apache/commons/rdf/rdf4j/impl/AbstractRDFTerm.html Tue Nov 22 07:55:35 2016 @@ -31,14 +31,15 @@ 23 abstract class AbstractRDFTerm<T extends Value> implements RDF4JTerm { 24 T value; 25 -26 AbstractRDFTerm(T value) { +26 AbstractRDFTerm(final T value) { 27 this.value = value; 28 } 29 -30 public T asValue() { -31 return value; -32 } -33 } +30 @Override +31 public T asValue() { +32 return value; +33 } +34 }
Modified: websites/production/commonsrdf/content/xref/org/apache/commons/rdf/rdf4j/impl/AbstractRepositoryGraphLike.html ============================================================================== --- websites/production/commonsrdf/content/xref/org/apache/commons/rdf/rdf4j/impl/AbstractRepositoryGraphLike.html (original) +++ websites/production/commonsrdf/content/xref/org/apache/commons/rdf/rdf4j/impl/AbstractRepositoryGraphLike.html Tue Nov 22 07:55:35 2016 @@ -44,8 +44,8 @@ 36 protected final RDF4J rdf4jTermFactory; 37 protected final UUID salt; 38 -39 AbstractRepositoryGraphLike(Repository repository, UUID salt, boolean handleInitAndShutdown, -40 boolean includeInferred) { +39 AbstractRepositoryGraphLike(final Repository repository, final UUID salt, final boolean handleInitAndShutdown, +40 final boolean includeInferred) { 41 this.repository = repository; 42 this.salt = salt; 43 this.includeInferred = includeInferred; @@ -71,16 +71,17 @@ 63 return repository.getConnection(); 64 } 65 -66 public Optional<Repository> asRepository() { -67 return Optional.of(repository); -68 } -69 -70 @Override -71 public Optional<Model> asModel() { -72 return Optional.empty(); -73 } -74 -75 } +66 @Override +67 public Optional<Repository> asRepository() { +68 return Optional.of(repository); +69 } +70 +71 @Override +72 public Optional<Model> asModel() { +73 return Optional.empty(); +74 } +75 +76 }
Modified: websites/production/commonsrdf/content/xref/org/apache/commons/rdf/rdf4j/impl/BlankNodeImpl.html ============================================================================== --- websites/production/commonsrdf/content/xref/org/apache/commons/rdf/rdf4j/impl/BlankNodeImpl.html (original) +++ websites/production/commonsrdf/content/xref/org/apache/commons/rdf/rdf4j/impl/BlankNodeImpl.html Tue Nov 22 07:55:35 2016 @@ -36,73 +36,74 @@ 28 final class BlankNodeImpl extends AbstractRDFTerm<BNode> implements RDF4JBlankNode { 29 30 private transient int hashCode = 0; -31 private long saltUUIDleast; -32 private long saltUUIDmost; +31 private final long saltUUIDleast; +32 private final long saltUUIDmost; 33 -34 BlankNodeImpl(BNode bNode, UUID salt) { +34 BlankNodeImpl(final BNode bNode, final UUID salt) { 35 super(bNode); 36 // Space-efficient storage of salt UUID 37 saltUUIDmost = salt.getMostSignificantBits(); 38 saltUUIDleast = salt.getLeastSignificantBits(); 39 } 40 -41 public boolean equals(Object obj) { -42 if (obj == this) { -43 return true; -44 } -45 // NOTE: Do NOT use Bnode.equals() as it has a more generous -46 // equality based only on the value.getID(); -47 if (obj instanceof BlankNode) { -48 BlankNode blankNode = (BlankNode) obj; -49 return uniqueReference().equals(blankNode.uniqueReference()); -50 } -51 return false; -52 } -53 -54 @Override -55 public int hashCode() { -56 if (hashCode != 0) { -57 return hashCode; -58 } -59 return hashCode = uniqueReference().hashCode(); -60 } -61 -62 private boolean isValidBlankNodeLabel(String id) { -63 // FIXME: Replace with a regular expression? -64 if (id.isEmpty()) { -65 return false; -66 } -67 if (!TurtleUtil.isBLANK_NODE_LABEL_StartChar(id.codePointAt(0))) { -68 return false; -69 } -70 for (int i = 1; i < id.length(); i++) { -71 if (!TurtleUtil.isBLANK_NODE_LABEL_Char(id.codePointAt(i))) { -72 return false; -73 } -74 } -75 return true; -76 } -77 -78 @Override -79 public String ntriplesString() { -80 if (isValidBlankNodeLabel(value.getID())) { -81 return "_:" + value.getID(); -82 } else { -83 return "_:" + UUID.nameUUIDFromBytes(value.getID().getBytes(StandardCharsets.UTF_8)); -84 } -85 } -86 -87 @Override -88 public String uniqueReference() { -89 UUID uuid = new UUID(saltUUIDmost, saltUUIDleast); -90 return "urn:uuid:" + uuid + "#" + value.getID(); -91 } -92 -93 @Override -94 public String toString() { -95 return ntriplesString() + " [" + uniqueReference() + "]"; -96 } -97 } +41 @Override +42 public boolean equals(final Object obj) { +43 if (obj == this) { +44 return true; +45 } +46 // NOTE: Do NOT use Bnode.equals() as it has a more generous +47 // equality based only on the value.getID(); +48 if (obj instanceof BlankNode) { +49 final BlankNode blankNode = (BlankNode) obj; +50 return uniqueReference().equals(blankNode.uniqueReference()); +51 } +52 return false; +53 } +54 +55 @Override +56 public int hashCode() { +57 if (hashCode != 0) { +58 return hashCode; +59 } +60 return hashCode = uniqueReference().hashCode(); +61 } +62 +63 private boolean isValidBlankNodeLabel(final String id) { +64 // FIXME: Replace with a regular expression? +65 if (id.isEmpty()) { +66 return false; +67 } +68 if (!TurtleUtil.isBLANK_NODE_LABEL_StartChar(id.codePointAt(0))) { +69 return false; +70 } +71 for (int i = 1; i < id.length(); i++) { +72 if (!TurtleUtil.isBLANK_NODE_LABEL_Char(id.codePointAt(i))) { +73 return false; +74 } +75 } +76 return true; +77 } +78 +79 @Override +80 public String ntriplesString() { +81 if (isValidBlankNodeLabel(value.getID())) { +82 return "_:" + value.getID(); +83 } else { +84 return "_:" + UUID.nameUUIDFromBytes(value.getID().getBytes(StandardCharsets.UTF_8)); +85 } +86 } +87 +88 @Override +89 public String uniqueReference() { +90 final UUID uuid = new UUID(saltUUIDmost, saltUUIDleast); +91 return "urn:uuid:" + uuid + "#" + value.getID(); +92 } +93 +94 @Override +95 public String toString() { +96 return ntriplesString() + " [" + uniqueReference() + "]"; +97 } +98 }
Modified: websites/production/commonsrdf/content/xref/org/apache/commons/rdf/rdf4j/impl/ConvertedStatements.html ============================================================================== --- websites/production/commonsrdf/content/xref/org/apache/commons/rdf/rdf4j/impl/ConvertedStatements.html (original) +++ websites/production/commonsrdf/content/xref/org/apache/commons/rdf/rdf4j/impl/ConvertedStatements.html Tue Nov 22 07:55:35 2016 @@ -38,12 +38,12 @@ 30 31 final class ConvertedStatements<T> implements ClosableIterable<T> { 32 -33 private RepositoryConnection conn; -34 private RepositoryResult<Statement> results; -35 private Function<Statement, T> statementAdapter; +33 private final RepositoryConnection conn; +34 private final RepositoryResult<Statement> results; +35 private final Function<Statement, T> statementAdapter; 36 -37 ConvertedStatements(Supplier<RepositoryConnection> repositoryConnector, Function<Statement, T> statementAdapter, -38 Resource subj, org.eclipse.rdf4j.model.IRI pred, Value obj, Resource... contexts) { +37 ConvertedStatements(final Supplier<RepositoryConnection> repositoryConnector, final Function<Statement, T> statementAdapter, +38 final Resource subj, final org.eclipse.rdf4j.model.IRI pred, final Value obj, final Resource... contexts) { 39 this.statementAdapter = statementAdapter; 40 this.conn = repositoryConnector.get(); 41 this.results = conn.getStatements(subj, pred, obj, contexts); @@ -63,7 +63,7 @@ 55 private final class ConvertedIterator implements Iterator<T> { 56 @Override 57 public boolean hasNext() { -58 boolean hasNext = results.hasNext(); +58 final boolean hasNext = results.hasNext(); 59 if (!hasNext) { 60 close(); 61 }