You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@jena.apache.org by GitBox <gi...@apache.org> on 2021/02/01 19:22:04 UTC
[GitHub] [jena] afs opened a new pull request #910: JENA-2031: IRI provider/functional abstraction
afs opened a new pull request #910:
URL: https://github.com/apache/jena/pull/910
This includes PR #901.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
[GitHub] [jena] rvesse commented on pull request #910: JENA-2031: IRI provider/functional abstraction
Posted by GitBox <gi...@apache.org>.
rvesse commented on pull request #910:
URL: https://github.com/apache/jena/pull/910#issuecomment-771497623
The basic interface looks fine as far as I'm able to pick it out amongst the swathe of related changes
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
[GitHub] [jena] kinow commented on a change in pull request #910: JENA-2031: IRI provider/functional abstraction
Posted by GitBox <gi...@apache.org>.
kinow commented on a change in pull request #910:
URL: https://github.com/apache/jena/pull/910#discussion_r571384840
##########
File path: jena-core/src/main/java/org/apache/jena/irix/IRIx.java
##########
@@ -0,0 +1,194 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.irix;
+
+import java.util.Objects;
+
+/**
+ * Support for RFC3986 IRIs.
+ * <p>
+ * The class {@code IRIx} is an abstraction layer; a provider is need to give an
Review comment:
s/is need/is needed
##########
File path: jena-core/src/main/java/org/apache/jena/irix/IRIx.java
##########
@@ -0,0 +1,194 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.irix;
+
+import java.util.Objects;
+
+/**
+ * Support for RFC3986 IRIs.
+ * <p>
+ * The class {@code IRIx} is an abstraction layer; a provider is need to give an
+ * implementation. A provider is selected at start-up and is not expected to changes
+ * while the system is running.
+ * <p>
+ * Use {@link IRIs#reference} to check a string is suitable for us in RDF.
+ *
+ * @see IRIxResolver for resolving relative IRIs against a base.
+ * @see IRIs for functions related to IRIs
+ */
+public abstract class IRIx {
+
+ private final String iriString;
+
+ /**
+ * Create an {@link IRIx} without resolving the iri. This operation may throw an
+ * {@link IRIException}.
+ * <p>
+ * See {@link IRIs#resolve(String)} to create an absolute IRI, resolving
+ * against the system base if necessary.
+ * <p>
+ * See {@link IRIs#check(String)} to check a string is an absolute URI and is suitable for use in RDF.
+ * <p>
+ * See {@link IRIs#reference(String)} when the string is an absolute URI and
+ * should not be resolved against local system base (e.g. it was passed in from
+ * outside)to create an {@link IRIx} that is suitable for use in RDF.
Review comment:
`outside)to create` to `outside) to create`
##########
File path: jena-core/src/main/java/org/apache/jena/irix/IRIx.java
##########
@@ -0,0 +1,194 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.irix;
+
+import java.util.Objects;
+
+/**
+ * Support for RFC3986 IRIs.
+ * <p>
+ * The class {@code IRIx} is an abstraction layer; a provider is need to give an
+ * implementation. A provider is selected at start-up and is not expected to changes
+ * while the system is running.
+ * <p>
+ * Use {@link IRIs#reference} to check a string is suitable for us in RDF.
+ *
+ * @see IRIxResolver for resolving relative IRIs against a base.
+ * @see IRIs for functions related to IRIs
+ */
+public abstract class IRIx {
+
+ private final String iriString;
+
+ /**
+ * Create an {@link IRIx} without resolving the iri. This operation may throw an
+ * {@link IRIException}.
+ * <p>
+ * See {@link IRIs#resolve(String)} to create an absolute IRI, resolving
+ * against the system base if necessary.
+ * <p>
+ * See {@link IRIs#check(String)} to check a string is an absolute URI and is suitable for use in RDF.
+ * <p>
+ * See {@link IRIs#reference(String)} when the string is an absolute URI and
+ * should not be resolved against local system base (e.g. it was passed in from
+ * outside)to create an {@link IRIx} that is suitable for use in RDF.
+ */
+ static public IRIx create(String iri) throws IRIException {
+ Objects.requireNonNull(iri);
+ return SystemIRIx.getProvider().create(iri);
+ }
+
+ /**
+ * String must have been validated (e.g complies with the grammar of RFC3986).
+ * This constructor does not perform any additional checking.
+ */
+ protected IRIx(String string) {
+ this.iriString = string;
+ }
+
+ /**
+ * An <a href="https://tools.ietf.org/html/rfc3986#section-4.3"><em>absolute URI</em></a>
+ * is one with a URI scheme and without a fragment.
+ * The other components, host (authority), path, and query, are optional.
+ * <p>
+ * absolute-URI = scheme ":" hier-part [ "?" query ]
+ * <p>
+ * Beware of the meaning : {@code http:abc} is an absolute URI - it has only a schema and a path without a root.
+ * <p>
+ * Note that a URI can be both "not absolute" and "not relative", e.g. {@code http://example/path#fragment}.
+ * <p>
+ * See {@linkplain #isReference()} for testing whether a URI is suitable for use in RDF.
+ */
+ public abstract boolean isAbsolute();
+
+ /**
+ * A <a href="https://tools.ietf.org/html/rfc3986#section-4.2"><em>relative
+ * URI</em></a> one without a scheme, and maybe without some of the other parts.
+ * <p>
+ * Often it is just the path part.
+ * <p>
+ * <p>
+ * See {@linkplain #isReference()} for testing whether a URI is suitable for use in RDF.
+ * <p>
+ * Note that a URI can be both "not absolute" and "not relative", e.g. {@code http://example/path#fragment}.
+ */
+ public abstract boolean isRelative();
+
+ /**
+ * An <em>RDF Reference</em> is an URI which has scheme.
+ * If it is hierarchical, it should a non-empty host- authority,
+ * and may have a query component and may have a fragment component.
+ * This not a term in
+ * <a href="https://tools.ietf.org/html/rfc3986">RFC 3986</a>
+ * and it is not the same as "absolute URI".
+ * <p>
+ * In RDF data it is a
+ * <a href="https://www.w3.org/TR/rdf11-concepts/#section-IRIs">useful concept</a>.
+ * It is either an absolute URI, but if it is hierarchical, it must have a host.
Review comment:
Drop the `either`?
##########
File path: jena-arq/src/main/java/org/apache/jena/riot/system/IRIResolver.java
##########
@@ -129,391 +129,381 @@ private static void printErrorWarning(PrintStream ps, IRIFactory factory, int co
ps.printf("%-40s : E:%-5s W:%-5s\n", x, factory.isError(code), factory.isWarning(code));
}
- /**
- * The current working directory, as a string.
- */
- static private String globalBase = IRILib.filenameToIRI("./");
-
- // The global resolver may be accessed by multiple threads
- // Other resolvers are not thread safe.
-
- private static IRIResolver globalResolver;
- /**
- * The current global resolver based on the working directory
- */
- static {
- IRI cwd;
- try {
- cwd = iriFactory().construct(globalBase);
- } catch (IRIException e) {
- Log.error(IRIResolver.class, "Unexpected IRIException in initializer: " + e.getMessage());
- cwd = iriFactory().create("file:///");
- e.printStackTrace(System.err);
- }
- globalResolver = new IRIResolverSync(IRIResolver.create(cwd));
- }
-
-
-
- // ---- System-wide IRI Factory.
-
- /** The IRI checker setup, focused on parsing and languages.
- * This is a clean version of jena-iri {@link IRIFactory#iriImplementation()}
- * modified to allow unregistered schemes and allow {@code <file:relative>} IRIs.
- *
- * @see IRIFactory
- */
- public static IRIFactory iriFactory() {
- return iriFactoryInst;
- }
-
- // ---- System-wide operations.
-
- /** Check an IRI string (does not resolve it) */
- public static boolean checkIRI(String iriStr) {
- IRI iri = parseIRI(iriStr);
- return iri.hasViolation(false);
- }
-
- /** Check an IRI string (does not resolve it) - throw exception if not good */
- public static void validateIRI(String iriStr) throws IRIException {
- parseIRIex(iriStr);
- }
-
- /** Parse an IRI (does not resolve it) */
- public static IRI parseIRI(String iriStr) {
- return iriFactory().create(iriStr);
- }
-
- /** Parse an IRI (does not resolve it) - throws exception on a bad IRI */
- public static IRI parseIRIex(String iriStr) throws IRIException {
- return iriFactory().construct(iriStr);
- }
-
- /**
- * Resolve a URI against a base. If baseStr is a relative file IRI
- * then it is first resolved against the current working directory.
- *
- * @param relStr
- * @param baseStr
- * Can be null if relStr is absolute
- * @return An absolute URI
- * @throws RiotException
- * If result would not be legal, absolute IRI
- */
- public static IRI resolve(String relStr, String baseStr) throws RiotException {
- return exceptions(resolveIRI(relStr, baseStr));
- }
-
- /**
- * Resolve an IRI against whatever is the base for this process (likely to
- * be based on the current working directory of this process at the time of
- * initialization of this class).
- */
- public static IRI resolveIRI(String uriStr) {
- return exceptions(globalResolver.resolve(uriStr));
- }
-
- /**
- * Resolve a string against a base.
- * <p>
- * No exceptions thrown by this method; the application should test the returned
- * IRI for violations with {@link IRI#hasViolation(boolean)}.
- */
- public static IRI resolveIRI(String relStr, String baseStr) {
- IRI i = iriFactory().create(relStr);
- if (i.isAbsolute())
- // removes excess . segments
- return globalResolver.getBaseIRI().create(i);
-
- IRI base = iriFactory().create(baseStr);
- return base.create(i);
- }
-
- /**
- * Choose a base URI based on the current directory
- *
- * @return String Absolute URI
- */
- public static IRI chooseBaseURI() {
- return globalResolver.getBaseIRI();
- }
-
- // The global resolver may be accessed by multiple threads
- // Other resolvers are not thread safe.
+ // ---- Global System base.
// /**
-// * Turn a filename into a well-formed file: URL relative to the working
-// * directory.
+// * The current working directory, as a string.
+// */
+// static private String globalBase = IRILib.filenameToIRI("./");
+//
+// // The global resolver may be accessed by multiple threads
+// // Other resolvers are not thread safe.
+//
+// private static IRIResolver globalResolver;
+// /**
+// * The current global resolver based on the working directory
+// */
+// static {
+// IRI cwd;
+// try {
+// cwd = iriFactory().construct(globalBase);
+// } catch (IRIException e) {
+// Log.error(IRIResolver.class, "Unexpected IRIException in initializer: " + e.getMessage());
+// cwd = iriFactory().create("file:///");
+// e.printStackTrace(System.err);
+// }
+// globalResolver = new IRIResolverSync(IRIResolver.create(cwd));
+// }
+//
+// // ---- System-wide IRI Factory.
+//
+// // ---- System-wide operations.
+//
+// /** Check an IRI string (does not resolve it) */
+// public static boolean checkIRI(String iriStr) {
+// IRI iri = parseIRI(iriStr);
+// return iri.hasViolation(false);
+// }
+//
+// /** Check an IRI string (does not resolve it) - throw exception if not good */
+// public static void validateIRI(String iriStr) throws IRIException {
+// parseIRIex(iriStr);
+// }
+//
+// /** Parse an IRI (does not resolve it) */
+// public static IRI parseIRI(String iriStr) {
+// return iriFactory().create(iriStr);
+// }
+//
+// /** Parse an IRI (does not resolve it) - throws exception on a bad IRI */
+// public static IRI parseIRIex(String iriStr) throws IRIException {
+// return iriFactory().construct(iriStr);
+// }
+//
+// /**
+// * Resolve a URI against a base. If baseStr is a relative file IRI
+// * then it is first resolved against the current working directory.
// *
-// * @param filename
-// * @return String The filename as an absolute URL
+// * @param relStr
+// * @param baseStr
+// * Can be null if relStr is absolute
+// * @return An absolute URI
+// * @throws RiotException
+// * If result would not be legal, absolute IRI
// */
- static public String resolveFileURL(String filename) throws IRIException {
- IRI r = globalResolver.resolve(filename);
- if (!r.getScheme().equalsIgnoreCase("file")) {
- // Pragmatic hack that copes with "c:"
- return resolveFileURL("./" + filename);
- }
- return r.toString();
- }
-
- /**
- * Resolve a URI against a base.
- *
- * @param relStr
- * @param baseStr
- * Can be null if relStr is absolute
- * @return String An absolute URI
- * @throws RiotException
- * If result would not be legal, absolute IRI
- */
- static public String resolveString(String relStr, String baseStr) throws RiotException {
- return exceptions(resolveIRI(relStr, baseStr)).toString();
- }
-
- /**
- * Resolve a URI against the base for this process. If baseStr is a
- * relative file IRI then it is first resolved against the current
- * working directory. If it is an absolute URI, it is normalized.
- *
- * @param uriStr
- * @return String An absolute URI
- * @throws RiotException
- * If result would not be legal, absolute IRI
- */
- static public String resolveString(String uriStr) throws RiotException {
- return exceptions(resolveIRI(uriStr)).toString();
- }
-
- /**
- * Resolve a URI against a base. If baseStr is a relative file IRI
- * then it is first resolved against the current working directory.
- * If it is an absolute URI, it is normalized.
- *
- * @param uriStr
- * @return String An absolute URI
- */
- static public String resolveStringSilent(String uriStr) throws RiotException {
- return globalResolver.resolveSilent(uriStr).toString();
- }
-
- public static IRIResolver create() {
- return new IRIResolverNormal();
- }
-
- public static IRIResolver create(String baseStr) {
- return new IRIResolverNormal(baseStr);
- }
-
- public static IRIResolver create(IRI baseIRI) {
- return new IRIResolverNormal(baseIRI);
- }
-
- /** A resolver that does not resolv against a base IRI. */
- public static IRIResolver createNoResolve() {
- return new IRIResolverNoOp();
- }
-
- /**
- * To allow Eyeball to bypass IRI checking (because it's doing its own)
- */
- public static void suppressExceptions() {
- showExceptions = false;
- }
-
- public String getBaseIRIasString() {
- IRI iri = getBaseIRI();
- if (iri == null)
- return null;
- return iri.toString();
- }
-
- /**
- * The base of this IRIResolver.
- *
- * @return String
- */
- protected abstract IRI getBaseIRI();
-
- /**
- * Resolve a relative URI against the base of this IRIResolver
- * or normalize an absolute URI.
- *
- * @param uriStr
- * @return the resolved IRI
- * @throws RiotException
- * If resulting URI would not be legal, absolute IRI
- */
- public IRI resolve(String uriStr) {
- return exceptions(resolveSilent(uriStr));
- }
-
- /**
- * Create a URI, resolving relative IRIs,
- * normalize an absolute URI,
- * but do not throw exception on a bad IRI.
- *
- * @param uriStr
- * @return the resolved IRI
- * @throws RiotException
- * If resulting URI would not be legal, absolute IRI
- */
- public abstract IRI resolveSilent(String uriStr);
-
- /** Resolving relative IRIs, return a string */
- public String resolveToString(String uriStr) {
- return resolve(uriStr).toString();
- }
-
- /**
- * Resolving relative IRIs, return a string, but do not throw exception on
- * bad a IRI
- */
- public String resolveToStringSilent(String uriStr) {
- return resolveSilent(uriStr).toString();
- }
-
- protected IRIResolver()
- {}
-
- /**
- * Throw any exceptions resulting from IRI.
- *
- * @param iri
- * @return iri
- */
- private static IRI exceptions(IRI iri) {
- if (!showExceptions)
- return iri;
- if (!iri.hasViolation(false))
- return iri;
- String msg = iri.violations(false).next().getShortMessage();
- throw new RiotException(msg);
- }
-
- private static final int CacheSize = 1000;
-
- /**
- * A resolver that does not resolve IRIs against base.
- * This can generate relative IRIs.
- **/
- static class IRIResolverNoOp extends IRIResolver
- {
- protected IRIResolverNoOp()
- {}
-
- private Cache<String, IRI> resolvedIRIs = CacheFactory.createCache(CacheSize);
-
- @Override
- protected IRI getBaseIRI() {
- return null;
- }
-
- @Override
- public IRI resolveSilent(final String uriStr) {
- if ( resolvedIRIs == null )
- return iriFactory().create(uriStr);
- Callable<IRI> filler = () -> iriFactory().create(uriStr);
- IRI iri = resolvedIRIs.getOrFill(uriStr, filler);
- return iri;
- }
-
- @Override
- public String resolveToString(String uriStr) {
- return uriStr;
- }
- }
-
- /** Resolving resolver **/
- static class IRIResolverNormal extends IRIResolver
- {
- final private IRI base;
- // Not static - contains relative IRIs
- // Could split into absolute (static, global cached) and relative.
- private Cache<String, IRI> resolvedIRIs = CacheFactory.createCache(CacheSize);
-
- /**
- * Construct an IRIResolver with base as the current working directory.
- */
- public IRIResolverNormal() {
- this((String)null);
- }
-
- /**
- * Construct an IRIResolver with base determined by the argument URI. If
- * this is relative, it is relative against the current working
- * directory.
- *
- * @param baseStr
- * @throws RiotException
- * If resulting base unparsable.
- */
- public IRIResolverNormal(String baseStr) {
- if ( baseStr == null )
- base = chooseBaseURI();
- else
- base = globalResolver.resolveSilent(baseStr);
- }
-
- public IRIResolverNormal(IRI baseIRI) {
- if ( baseIRI == null )
- baseIRI = chooseBaseURI();
- base = baseIRI;
- }
-
- @Override
- protected IRI getBaseIRI() {
- return base;
- }
-
- @Override
- public IRI resolveSilent(String uriStr) {
- if ( resolvedIRIs == null )
- return resolveSilentNoCache(uriStr);
- else
- return resolveSilentCache(uriStr);
- }
-
- private IRI resolveSilentNoCache(String uriStr) {
- IRI x = IRIResolver.iriFactory().create(uriStr);
- if ( SysRIOT.AbsURINoNormalization ) {
- // Always process "file:", even in strict mode.
- // file: is widely used in irregular forms.
- if ( x.isAbsolute() && ! uriStr.startsWith("file:") )
- return x;
- }
- return base.create(x);
- }
-
- private IRI resolveSilentCache(final String uriStr) {
- Callable<IRI> filler = () -> resolveSilentNoCache(uriStr);
- return resolvedIRIs.getOrFill(uriStr, filler);
- }
- }
-
- /** Thread safe wrapper for an IRIResolver */
- static class IRIResolverSync extends IRIResolver
- {
- private final IRIResolver other;
-
- IRIResolverSync(IRIResolver other) { this.other = other; }
- @Override
- synchronized
- protected IRI getBaseIRI() {
- return other.getBaseIRI();
- }
-
- @Override
- synchronized
- public IRI resolve(String uriStr) {
- return other.resolve(uriStr);
- }
-
- @Override
- synchronized
- public IRI resolveSilent(String uriStr) {
- return other.resolveSilent(uriStr);
- }
- }
+// public static IRI resolve(String relStr, String baseStr) throws RiotException {
+// return exceptions(resolveIRI(relStr, baseStr));
+// }
+//
+// /**
+// * Resolve an IRI against whatever is the base for this process (likely to
+// * be based on the current working directory of this process at the time of
+// * initialization of this class).
+// */
+// public static IRI resolveIRI(String uriStr) {
+// return exceptions(globalResolver.resolve(uriStr));
+// }
+//
+// /**
+// * Resolve a string against a base.
+// * <p>
+// * No exceptions thrown by this method; the application should test the returned
+// * IRI for violations with {@link IRI#hasViolation(boolean)}.
+// */
+// public static IRI resolveIRI(String relStr, String baseStr) {
+// IRI i = iriFactory().create(relStr);
+// if (i.isAbsolute())
+// // removes excess . segments
+// return globalResolver.getBaseIRI().create(i);
+//
+// IRI base = iriFactory().create(baseStr);
+// return base.create(i);
+// }
+//
+// /**
+// * Choose a base URI based on the current directory
+// *
+// * @return String Absolute URI
+// */
+// public static IRI chooseBaseURI() {
+// return globalResolver.getBaseIRI();
+// }
+//
+// // The global resolver may be accessed by multiple threads
+// // Other resolvers are not thread safe.
+//
+//// /**
+//// * Turn a filename into a well-formed file: URL relative to the working
+//// * directory.
+//// *
+//// * @param filename
+//// * @return String The filename as an absolute URL
+//// */
+// static public String resolveFileURL(String filename) throws IRIException {
+// IRI r = globalResolver.resolve(filename);
+// if (!r.getScheme().equalsIgnoreCase("file")) {
+// // Pragmatic hack that copes with "c:"
+// return resolveFileURL("./" + filename);
+// }
+// return r.toString();
+// }
+//
+// /**
+// * Resolve a URI against a base.
+// *
+// * @param relStr
+// * @param baseStr
+// * Can be null if relStr is absolute
+// * @return String An absolute URI
+// * @throws RiotException
+// * If result would not be legal, absolute IRI
+// */
+// static public String resolveString(String relStr, String baseStr) throws RiotException {
+// return exceptions(resolveIRI(relStr, baseStr)).toString();
+// }
+//
+// /**
+// * Resolve a URI against the base for this process. If baseStr is a
+// * relative file IRI then it is first resolved against the current
+// * working directory. If it is an absolute URI, it is normalized.
+// *
+// * @param uriStr
+// * @return String An absolute URI
+// * @throws RiotException
+// * If result would not be legal, absolute IRI
+// */
+// static public String resolveString(String uriStr) throws RiotException {
+// return exceptions(resolveIRI(uriStr)).toString();
+// }
+//
+// /**
+// * Resolve a URI against a base. If baseStr is a relative file IRI
+// * then it is first resolved against the current working directory.
+// * If it is an absolute URI, it is normalized.
+// *
+// * @param uriStr
+// * @return String An absolute URI
+// */
+// static public String resolveStringSilent(String uriStr) throws RiotException {
+// return globalResolver.resolveSilent(uriStr).toString();
+// }
+//
+// public static IRIResolver create() {
+// return new IRIResolverNormal();
+// }
+//
+// public static IRIResolver create(String baseStr) {
+// return new IRIResolverNormal(baseStr);
+// }
+//
+// public static IRIResolver create(IRI baseIRI) {
+// return new IRIResolverNormal(baseIRI);
+// }
+//
+// /** A resolver that does not resolve against a base IRI. */
+// public static IRIResolver createNoResolve() {
+// return new IRIResolverNoOp();
+// }
+//
+// /**
+// * To allow Eyeball to bypass IRI checking (because it's doing its own)
+// */
+// public static void suppressExceptions() {
+// showExceptions = false;
+// }
+//
+// public String getBaseIRIasString() {
+// IRI iri = getBaseIRI();
+// if (iri == null)
+// return null;
+// return iri.toString();
+// }
+//
+// /**
+// * The base of this IRIResolver.
+// *
+// * @return String
+// */
+// protected abstract IRI getBaseIRI();
+//
+// /**
+// * Resolve a relative URI against the base of this IRIResolver
+// * or normalize an absolute URI.
+// *
+// * @param uriStr
+// * @return the resolved IRI
+// * @throws RiotException
+// * If resulting URI would not be legal, absolute IRI
+// */
+// public IRI resolve(String uriStr) {
+// return exceptions(resolveSilent(uriStr));
+// }
+//
+// /**
+// * Create a URI, resolving relative IRIs,
+// * normalize an absolute URI,
+// * but do not throw exception on a bad IRI.
+// *
+// * @param uriStr
+// * @return the resolved IRI
+// * @throws RiotException
+// * If resulting URI would not be legal, absolute IRI
+// */
+// public abstract IRI resolveSilent(String uriStr);
+//
+// /** Resolving relative IRIs, return a string */
+// public String resolveToString(String uriStr) {
+// return resolve(uriStr).toString();
+// }
+//
+// /**
+// * Resolving relative IRIs, return a string, but do not throw exception on
+// * bad a IRI
+// */
+// public String resolveToStringSilent(String uriStr) {
+// return resolveSilent(uriStr).toString();
+// }
+//
+// protected IRIResolver()
+// {}
+//
+// /**
+// * Throw any exceptions resulting from IRI.
+// *
+// * @param iri
+// * @return iri
+// */
+// private static IRI exceptions(IRI iri) {
+// if (!showExceptions)
+// return iri;
+// if (!iri.hasViolation(false))
+// return iri;
+// String msg = iri.violations(false).next().getShortMessage();
+// throw new RiotException(msg);
+// }
+//
+// private static final int CacheSize = 1000;
+//
+// /**
+// * A resolver that does not resolve IRIs against base.
+// * This can generate relative IRIs.
+// **/
+// static class IRIResolverNoOp extends IRIResolver
+// {
+// protected IRIResolverNoOp()
+// {}
+//
+// private Cache<String, IRI> resolvedIRIs = CacheFactory.createCache(CacheSize);
+//
+// @Override
+// protected IRI getBaseIRI() {
+// return null;
+// }
+//
+// @Override
+// public IRI resolveSilent(final String uriStr) {
+// if ( resolvedIRIs == null )
+// return iriFactory().create(uriStr);
+// Callable<IRI> filler = () -> iriFactory().create(uriStr);
+// IRI iri = resolvedIRIs.getOrFill(uriStr, filler);
+// return iri;
+// }
+//
+// @Override
+// public String resolveToString(String uriStr) {
+// return uriStr;
+// }
+// }
+//
+// /** Resolving resolver **/
+// static class IRIResolverNormal extends IRIResolver
+// {
+// final private IRI base;
+// // Not static - contains relative IRIs
+// // Could split into absolute (static, global cached) and relative.
+// private Cache<String, IRI> resolvedIRIs = CacheFactory.createCache(CacheSize);
+//
+// /**
+// * Construct an IRIResolver with base as the current working directory.
+// */
+// public IRIResolverNormal() {
+// this((String)null);
+// }
+//
+// /**
+// * Construct an IRIResolver with base determined by the argument URI. If
+// * this is relative, it is relative against the current working
+// * directory.
+// *
+// * @param baseStr
+// * @throws RiotException
+// * If resulting base unparsable.
+// */
+// public IRIResolverNormal(String baseStr) {
+// if ( baseStr == null )
+// base = chooseBaseURI();
+// else
+// base = globalResolver.resolveSilent(baseStr);
+// }
+//
+// public IRIResolverNormal(IRI baseIRI) {
+// if ( baseIRI == null )
+// baseIRI = chooseBaseURI();
+// base = baseIRI;
+// }
+//
+// @Override
+// protected IRI getBaseIRI() {
+// return base;
+// }
+//
+// @Override
+// public IRI resolveSilent(String uriStr) {
+// if ( resolvedIRIs == null )
+// return resolveSilentNoCache(uriStr);
+// else
+// return resolveSilentCache(uriStr);
+// }
+//
+// private IRI resolveSilentNoCache(String uriStr) {
+// IRI x = IRIResolver.iriFactory().create(uriStr);
+// if ( SysRIOT.AbsURINoNormalization ) {
+// // Always process "file:", even in strict mode.
+// // file: is widely used in irregular forms.
+// if ( x.isAbsolute() && ! uriStr.startsWith("file:") )
+// return x;
+// }
+// return base.create(x);
+// }
+//
+// private IRI resolveSilentCache(final String uriStr) {
+// Callable<IRI> filler = () -> resolveSilentNoCache(uriStr);
+// return resolvedIRIs.getOrFill(uriStr, filler);
+// }
+// }
+//
+// /** Thread safe wrapper for an IRIResolver */
+// static class IRIResolverSync extends IRIResolver
+// {
+// private final IRIResolver other;
+//
+// IRIResolverSync(IRIResolver other) { this.other = other; }
+// @Override
+// synchronized
+// protected IRI getBaseIRI() {
+// return other.getBaseIRI();
+// }
+//
+// @Override
+// synchronized
+// public IRI resolve(String uriStr) {
+// return other.resolve(uriStr);
+// }
+//
+// @Override
+// synchronized
+// public IRI resolveSilent(String uriStr) {
+// return other.resolveSilent(uriStr);
+// }
+// }
Review comment:
Has it been moved to the irix package/module? Could it be deleted?
##########
File path: jena-core/src/main/java/org/apache/jena/irix/IRIx.java
##########
@@ -0,0 +1,194 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.irix;
+
+import java.util.Objects;
+
+/**
+ * Support for RFC3986 IRIs.
+ * <p>
+ * The class {@code IRIx} is an abstraction layer; a provider is need to give an
+ * implementation. A provider is selected at start-up and is not expected to changes
Review comment:
s/to changes/to change
##########
File path: jena-core/src/main/java/org/apache/jena/irix/IRIProvider.java
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.irix;
+
+/**
+ * Provider: an implementation of a factory for IRIs.
+ * This is not an application interface - is the plugin for the provider to jena.
+ *
+ * @see IRIxResolver
+ */
+public interface IRIProvider {
+ /**
+ * Create an IRI, throw {@link IRIException} is the string does not conform to the grammar.
+ */
+ public IRIx create(String iri) throws IRIException;
+
+ /**
+ * Create an IRI, throw {@link IRIException} is the string does not conform to the grammar
Review comment:
s/is/if
##########
File path: jena-core/src/main/java/org/apache/jena/irix/IRIx.java
##########
@@ -0,0 +1,194 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.irix;
+
+import java.util.Objects;
+
+/**
+ * Support for RFC3986 IRIs.
+ * <p>
+ * The class {@code IRIx} is an abstraction layer; a provider is need to give an
+ * implementation. A provider is selected at start-up and is not expected to changes
+ * while the system is running.
+ * <p>
+ * Use {@link IRIs#reference} to check a string is suitable for us in RDF.
+ *
+ * @see IRIxResolver for resolving relative IRIs against a base.
+ * @see IRIs for functions related to IRIs
+ */
+public abstract class IRIx {
+
+ private final String iriString;
+
+ /**
+ * Create an {@link IRIx} without resolving the iri. This operation may throw an
+ * {@link IRIException}.
+ * <p>
+ * See {@link IRIs#resolve(String)} to create an absolute IRI, resolving
+ * against the system base if necessary.
+ * <p>
+ * See {@link IRIs#check(String)} to check a string is an absolute URI and is suitable for use in RDF.
+ * <p>
+ * See {@link IRIs#reference(String)} when the string is an absolute URI and
+ * should not be resolved against local system base (e.g. it was passed in from
+ * outside)to create an {@link IRIx} that is suitable for use in RDF.
+ */
+ static public IRIx create(String iri) throws IRIException {
+ Objects.requireNonNull(iri);
+ return SystemIRIx.getProvider().create(iri);
+ }
+
+ /**
+ * String must have been validated (e.g complies with the grammar of RFC3986).
+ * This constructor does not perform any additional checking.
+ */
+ protected IRIx(String string) {
+ this.iriString = string;
+ }
+
+ /**
+ * An <a href="https://tools.ietf.org/html/rfc3986#section-4.3"><em>absolute URI</em></a>
+ * is one with a URI scheme and without a fragment.
+ * The other components, host (authority), path, and query, are optional.
+ * <p>
+ * absolute-URI = scheme ":" hier-part [ "?" query ]
+ * <p>
+ * Beware of the meaning : {@code http:abc} is an absolute URI - it has only a schema and a path without a root.
+ * <p>
+ * Note that a URI can be both "not absolute" and "not relative", e.g. {@code http://example/path#fragment}.
+ * <p>
+ * See {@linkplain #isReference()} for testing whether a URI is suitable for use in RDF.
+ */
+ public abstract boolean isAbsolute();
+
+ /**
+ * A <a href="https://tools.ietf.org/html/rfc3986#section-4.2"><em>relative
+ * URI</em></a> one without a scheme, and maybe without some of the other parts.
+ * <p>
+ * Often it is just the path part.
+ * <p>
+ * <p>
+ * See {@linkplain #isReference()} for testing whether a URI is suitable for use in RDF.
+ * <p>
+ * Note that a URI can be both "not absolute" and "not relative", e.g. {@code http://example/path#fragment}.
+ */
+ public abstract boolean isRelative();
+
+ /**
+ * An <em>RDF Reference</em> is an URI which has scheme.
+ * If it is hierarchical, it should a non-empty host- authority,
+ * and may have a query component and may have a fragment component.
+ * This not a term in
Review comment:
Include an `is` after `This`?
##########
File path: jena-core/src/main/java/org/apache/jena/irix/IRIx.java
##########
@@ -0,0 +1,194 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.irix;
+
+import java.util.Objects;
+
+/**
+ * Support for RFC3986 IRIs.
+ * <p>
+ * The class {@code IRIx} is an abstraction layer; a provider is need to give an
+ * implementation. A provider is selected at start-up and is not expected to changes
+ * while the system is running.
+ * <p>
+ * Use {@link IRIs#reference} to check a string is suitable for us in RDF.
+ *
+ * @see IRIxResolver for resolving relative IRIs against a base.
+ * @see IRIs for functions related to IRIs
+ */
+public abstract class IRIx {
+
+ private final String iriString;
+
+ /**
+ * Create an {@link IRIx} without resolving the iri. This operation may throw an
+ * {@link IRIException}.
+ * <p>
+ * See {@link IRIs#resolve(String)} to create an absolute IRI, resolving
+ * against the system base if necessary.
+ * <p>
+ * See {@link IRIs#check(String)} to check a string is an absolute URI and is suitable for use in RDF.
+ * <p>
+ * See {@link IRIs#reference(String)} when the string is an absolute URI and
+ * should not be resolved against local system base (e.g. it was passed in from
+ * outside)to create an {@link IRIx} that is suitable for use in RDF.
+ */
+ static public IRIx create(String iri) throws IRIException {
+ Objects.requireNonNull(iri);
+ return SystemIRIx.getProvider().create(iri);
+ }
+
+ /**
+ * String must have been validated (e.g complies with the grammar of RFC3986).
+ * This constructor does not perform any additional checking.
+ */
+ protected IRIx(String string) {
+ this.iriString = string;
+ }
+
+ /**
+ * An <a href="https://tools.ietf.org/html/rfc3986#section-4.3"><em>absolute URI</em></a>
+ * is one with a URI scheme and without a fragment.
+ * The other components, host (authority), path, and query, are optional.
+ * <p>
+ * absolute-URI = scheme ":" hier-part [ "?" query ]
+ * <p>
+ * Beware of the meaning : {@code http:abc} is an absolute URI - it has only a schema and a path without a root.
+ * <p>
+ * Note that a URI can be both "not absolute" and "not relative", e.g. {@code http://example/path#fragment}.
+ * <p>
+ * See {@linkplain #isReference()} for testing whether a URI is suitable for use in RDF.
+ */
+ public abstract boolean isAbsolute();
+
+ /**
+ * A <a href="https://tools.ietf.org/html/rfc3986#section-4.2"><em>relative
+ * URI</em></a> one without a scheme, and maybe without some of the other parts.
+ * <p>
+ * Often it is just the path part.
+ * <p>
+ * <p>
+ * See {@linkplain #isReference()} for testing whether a URI is suitable for use in RDF.
+ * <p>
+ * Note that a URI can be both "not absolute" and "not relative", e.g. {@code http://example/path#fragment}.
+ */
+ public abstract boolean isRelative();
+
+ /**
+ * An <em>RDF Reference</em> is an URI which has scheme.
+ * If it is hierarchical, it should a non-empty host- authority,
Review comment:
s/it should a non-empty host- authority/it should be a non-empty host-authority? (although I think the `-` is not used elsewhere, so just `host authority`?)
##########
File path: jena-core/src/main/java/org/apache/jena/irix/package-info.java
##########
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Support for RFC3986 IRIs.
+ * <p>
+ * The class {@link #IRIx} provides the application abstraction layer. There is an
+ * {@link #IRIProvider} that is the implementation of IRIs providing parsing and
+ * resolution. A provider is selected at start-up and is not expected to changes
+ * while the system is running.
+ * <p>
+ * {@link #IRIxResolver} is the main API. It provides {@link #IRIx} resolution with a
+ * base URI, and policy choices.
+ * <p>
+ * The class {@link #IRIs} providers functions related to IRIs including
+ * {@link IRIs#reference} to check that a string is suitable for us in RDF.
Review comment:
s/for us/for use/
##########
File path: jena-core/src/main/java/org/apache/jena/irix/IRIx.java
##########
@@ -0,0 +1,194 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.irix;
+
+import java.util.Objects;
+
+/**
+ * Support for RFC3986 IRIs.
+ * <p>
+ * The class {@code IRIx} is an abstraction layer; a provider is need to give an
+ * implementation. A provider is selected at start-up and is not expected to changes
+ * while the system is running.
+ * <p>
+ * Use {@link IRIs#reference} to check a string is suitable for us in RDF.
+ *
+ * @see IRIxResolver for resolving relative IRIs against a base.
+ * @see IRIs for functions related to IRIs
+ */
+public abstract class IRIx {
+
+ private final String iriString;
+
+ /**
+ * Create an {@link IRIx} without resolving the iri. This operation may throw an
+ * {@link IRIException}.
+ * <p>
+ * See {@link IRIs#resolve(String)} to create an absolute IRI, resolving
+ * against the system base if necessary.
+ * <p>
+ * See {@link IRIs#check(String)} to check a string is an absolute URI and is suitable for use in RDF.
+ * <p>
+ * See {@link IRIs#reference(String)} when the string is an absolute URI and
+ * should not be resolved against local system base (e.g. it was passed in from
+ * outside)to create an {@link IRIx} that is suitable for use in RDF.
+ */
+ static public IRIx create(String iri) throws IRIException {
+ Objects.requireNonNull(iri);
+ return SystemIRIx.getProvider().create(iri);
+ }
+
+ /**
+ * String must have been validated (e.g complies with the grammar of RFC3986).
+ * This constructor does not perform any additional checking.
+ */
+ protected IRIx(String string) {
+ this.iriString = string;
+ }
+
+ /**
+ * An <a href="https://tools.ietf.org/html/rfc3986#section-4.3"><em>absolute URI</em></a>
+ * is one with a URI scheme and without a fragment.
+ * The other components, host (authority), path, and query, are optional.
+ * <p>
+ * absolute-URI = scheme ":" hier-part [ "?" query ]
+ * <p>
+ * Beware of the meaning : {@code http:abc} is an absolute URI - it has only a schema and a path without a root.
+ * <p>
+ * Note that a URI can be both "not absolute" and "not relative", e.g. {@code http://example/path#fragment}.
+ * <p>
+ * See {@linkplain #isReference()} for testing whether a URI is suitable for use in RDF.
+ */
+ public abstract boolean isAbsolute();
+
+ /**
+ * A <a href="https://tools.ietf.org/html/rfc3986#section-4.2"><em>relative
+ * URI</em></a> one without a scheme, and maybe without some of the other parts.
+ * <p>
+ * Often it is just the path part.
+ * <p>
Review comment:
Unnecessary `<p>`? Unless it produces some extra line space I think.
##########
File path: jena-core/src/main/java/org/apache/jena/irix/package-info.java
##########
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Support for RFC3986 IRIs.
+ * <p>
+ * The class {@link #IRIx} provides the application abstraction layer. There is an
+ * {@link #IRIProvider} that is the implementation of IRIs providing parsing and
+ * resolution. A provider is selected at start-up and is not expected to changes
+ * while the system is running.
+ * <p>
+ * {@link #IRIxResolver} is the main API. It provides {@link #IRIx} resolution with a
+ * base URI, and policy choices.
+ * <p>
+ * The class {@link #IRIs} providers functions related to IRIs including
Review comment:
s/providers/provides ?
##########
File path: jena-core/src/main/java/org/apache/jena/irix/IRIProvider.java
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.irix;
+
+/**
+ * Provider: an implementation of a factory for IRIs.
+ * This is not an application interface - is the plugin for the provider to jena.
+ *
+ * @see IRIxResolver
+ */
+public interface IRIProvider {
+ /**
+ * Create an IRI, throw {@link IRIException} is the string does not conform to the grammar.
Review comment:
s/is/if
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
[GitHub] [jena] afs commented on pull request #910: JENA-2031: IRI provider/functional abstraction
Posted by GitBox <gi...@apache.org>.
afs commented on pull request #910:
URL: https://github.com/apache/jena/pull/910#issuecomment-773391589
JENA-2033 here to avoid a potential merge conflict because the fix is to a class modified by this PR.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
[GitHub] [jena] afs merged pull request #910: JENA-2031: IRI provider/functional abstraction
Posted by GitBox <gi...@apache.org>.
afs merged pull request #910:
URL: https://github.com/apache/jena/pull/910
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
[GitHub] [jena] afs commented on pull request #910: JENA-2031: IRI provider/functional abstraction
Posted by GitBox <gi...@apache.org>.
afs commented on pull request #910:
URL: https://github.com/apache/jena/pull/910#issuecomment-772437775
This is now complete. There is further checking that can be done which is why it'll be "draft" for awhile.
`jena-iri` is still used directly in the XML I/O, `jena-jdbc-core` and cmds for IRI validation. Those can wait if they need changing at all.
Almost inevitably, from going through all the code, reviewing the parser tests, and generally going back to look at old code,
**Change 1**
Bad percent encoding e.g. `http://example/abc%XZdef` is strictly a syntax error in RFC 3986, not merely bad practice. In the changes here, it becomes an error.
There are no warnings for lowercase (upper case is recommended, but not required).
**Change 2**
URN handling: RFC 8141 tightens up the rules on URNs to be urn:NID:NSS, NID is at least 2 alphanumerics, and NSS at least one. This is more restrictive that the previous RFC 2141 which allowed NID to be "X-"
A consequence is that using `urn:NID:` as a prefix is strictly an illegal URN but Jena accepted it.
`urn:x:` was never legal but Jena accepted it and I would not be surprised if it is used in Jena users test data. It was in Jena although now that's all cleaned up and the Jena test suite passes in strict URI mode.
Currently, the default is to run with only light checking of URN specific rules.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
[GitHub] [jena] afs commented on a change in pull request #910: JENA-2031: IRI provider/functional abstraction
Posted by GitBox <gi...@apache.org>.
afs commented on a change in pull request #910:
URL: https://github.com/apache/jena/pull/910#discussion_r571470332
##########
File path: jena-arq/src/main/java/org/apache/jena/riot/system/IRIResolver.java
##########
@@ -129,391 +129,381 @@ private static void printErrorWarning(PrintStream ps, IRIFactory factory, int co
ps.printf("%-40s : E:%-5s W:%-5s\n", x, factory.isError(code), factory.isWarning(code));
}
- /**
- * The current working directory, as a string.
- */
- static private String globalBase = IRILib.filenameToIRI("./");
-
- // The global resolver may be accessed by multiple threads
- // Other resolvers are not thread safe.
-
- private static IRIResolver globalResolver;
- /**
- * The current global resolver based on the working directory
- */
- static {
- IRI cwd;
- try {
- cwd = iriFactory().construct(globalBase);
- } catch (IRIException e) {
- Log.error(IRIResolver.class, "Unexpected IRIException in initializer: " + e.getMessage());
- cwd = iriFactory().create("file:///");
- e.printStackTrace(System.err);
- }
- globalResolver = new IRIResolverSync(IRIResolver.create(cwd));
- }
-
-
-
- // ---- System-wide IRI Factory.
-
- /** The IRI checker setup, focused on parsing and languages.
- * This is a clean version of jena-iri {@link IRIFactory#iriImplementation()}
- * modified to allow unregistered schemes and allow {@code <file:relative>} IRIs.
- *
- * @see IRIFactory
- */
- public static IRIFactory iriFactory() {
- return iriFactoryInst;
- }
-
- // ---- System-wide operations.
-
- /** Check an IRI string (does not resolve it) */
- public static boolean checkIRI(String iriStr) {
- IRI iri = parseIRI(iriStr);
- return iri.hasViolation(false);
- }
-
- /** Check an IRI string (does not resolve it) - throw exception if not good */
- public static void validateIRI(String iriStr) throws IRIException {
- parseIRIex(iriStr);
- }
-
- /** Parse an IRI (does not resolve it) */
- public static IRI parseIRI(String iriStr) {
- return iriFactory().create(iriStr);
- }
-
- /** Parse an IRI (does not resolve it) - throws exception on a bad IRI */
- public static IRI parseIRIex(String iriStr) throws IRIException {
- return iriFactory().construct(iriStr);
- }
-
- /**
- * Resolve a URI against a base. If baseStr is a relative file IRI
- * then it is first resolved against the current working directory.
- *
- * @param relStr
- * @param baseStr
- * Can be null if relStr is absolute
- * @return An absolute URI
- * @throws RiotException
- * If result would not be legal, absolute IRI
- */
- public static IRI resolve(String relStr, String baseStr) throws RiotException {
- return exceptions(resolveIRI(relStr, baseStr));
- }
-
- /**
- * Resolve an IRI against whatever is the base for this process (likely to
- * be based on the current working directory of this process at the time of
- * initialization of this class).
- */
- public static IRI resolveIRI(String uriStr) {
- return exceptions(globalResolver.resolve(uriStr));
- }
-
- /**
- * Resolve a string against a base.
- * <p>
- * No exceptions thrown by this method; the application should test the returned
- * IRI for violations with {@link IRI#hasViolation(boolean)}.
- */
- public static IRI resolveIRI(String relStr, String baseStr) {
- IRI i = iriFactory().create(relStr);
- if (i.isAbsolute())
- // removes excess . segments
- return globalResolver.getBaseIRI().create(i);
-
- IRI base = iriFactory().create(baseStr);
- return base.create(i);
- }
-
- /**
- * Choose a base URI based on the current directory
- *
- * @return String Absolute URI
- */
- public static IRI chooseBaseURI() {
- return globalResolver.getBaseIRI();
- }
-
- // The global resolver may be accessed by multiple threads
- // Other resolvers are not thread safe.
+ // ---- Global System base.
// /**
-// * Turn a filename into a well-formed file: URL relative to the working
-// * directory.
+// * The current working directory, as a string.
+// */
+// static private String globalBase = IRILib.filenameToIRI("./");
+//
+// // The global resolver may be accessed by multiple threads
+// // Other resolvers are not thread safe.
+//
+// private static IRIResolver globalResolver;
+// /**
+// * The current global resolver based on the working directory
+// */
+// static {
+// IRI cwd;
+// try {
+// cwd = iriFactory().construct(globalBase);
+// } catch (IRIException e) {
+// Log.error(IRIResolver.class, "Unexpected IRIException in initializer: " + e.getMessage());
+// cwd = iriFactory().create("file:///");
+// e.printStackTrace(System.err);
+// }
+// globalResolver = new IRIResolverSync(IRIResolver.create(cwd));
+// }
+//
+// // ---- System-wide IRI Factory.
+//
+// // ---- System-wide operations.
+//
+// /** Check an IRI string (does not resolve it) */
+// public static boolean checkIRI(String iriStr) {
+// IRI iri = parseIRI(iriStr);
+// return iri.hasViolation(false);
+// }
+//
+// /** Check an IRI string (does not resolve it) - throw exception if not good */
+// public static void validateIRI(String iriStr) throws IRIException {
+// parseIRIex(iriStr);
+// }
+//
+// /** Parse an IRI (does not resolve it) */
+// public static IRI parseIRI(String iriStr) {
+// return iriFactory().create(iriStr);
+// }
+//
+// /** Parse an IRI (does not resolve it) - throws exception on a bad IRI */
+// public static IRI parseIRIex(String iriStr) throws IRIException {
+// return iriFactory().construct(iriStr);
+// }
+//
+// /**
+// * Resolve a URI against a base. If baseStr is a relative file IRI
+// * then it is first resolved against the current working directory.
// *
-// * @param filename
-// * @return String The filename as an absolute URL
+// * @param relStr
+// * @param baseStr
+// * Can be null if relStr is absolute
+// * @return An absolute URI
+// * @throws RiotException
+// * If result would not be legal, absolute IRI
// */
- static public String resolveFileURL(String filename) throws IRIException {
- IRI r = globalResolver.resolve(filename);
- if (!r.getScheme().equalsIgnoreCase("file")) {
- // Pragmatic hack that copes with "c:"
- return resolveFileURL("./" + filename);
- }
- return r.toString();
- }
-
- /**
- * Resolve a URI against a base.
- *
- * @param relStr
- * @param baseStr
- * Can be null if relStr is absolute
- * @return String An absolute URI
- * @throws RiotException
- * If result would not be legal, absolute IRI
- */
- static public String resolveString(String relStr, String baseStr) throws RiotException {
- return exceptions(resolveIRI(relStr, baseStr)).toString();
- }
-
- /**
- * Resolve a URI against the base for this process. If baseStr is a
- * relative file IRI then it is first resolved against the current
- * working directory. If it is an absolute URI, it is normalized.
- *
- * @param uriStr
- * @return String An absolute URI
- * @throws RiotException
- * If result would not be legal, absolute IRI
- */
- static public String resolveString(String uriStr) throws RiotException {
- return exceptions(resolveIRI(uriStr)).toString();
- }
-
- /**
- * Resolve a URI against a base. If baseStr is a relative file IRI
- * then it is first resolved against the current working directory.
- * If it is an absolute URI, it is normalized.
- *
- * @param uriStr
- * @return String An absolute URI
- */
- static public String resolveStringSilent(String uriStr) throws RiotException {
- return globalResolver.resolveSilent(uriStr).toString();
- }
-
- public static IRIResolver create() {
- return new IRIResolverNormal();
- }
-
- public static IRIResolver create(String baseStr) {
- return new IRIResolverNormal(baseStr);
- }
-
- public static IRIResolver create(IRI baseIRI) {
- return new IRIResolverNormal(baseIRI);
- }
-
- /** A resolver that does not resolv against a base IRI. */
- public static IRIResolver createNoResolve() {
- return new IRIResolverNoOp();
- }
-
- /**
- * To allow Eyeball to bypass IRI checking (because it's doing its own)
- */
- public static void suppressExceptions() {
- showExceptions = false;
- }
-
- public String getBaseIRIasString() {
- IRI iri = getBaseIRI();
- if (iri == null)
- return null;
- return iri.toString();
- }
-
- /**
- * The base of this IRIResolver.
- *
- * @return String
- */
- protected abstract IRI getBaseIRI();
-
- /**
- * Resolve a relative URI against the base of this IRIResolver
- * or normalize an absolute URI.
- *
- * @param uriStr
- * @return the resolved IRI
- * @throws RiotException
- * If resulting URI would not be legal, absolute IRI
- */
- public IRI resolve(String uriStr) {
- return exceptions(resolveSilent(uriStr));
- }
-
- /**
- * Create a URI, resolving relative IRIs,
- * normalize an absolute URI,
- * but do not throw exception on a bad IRI.
- *
- * @param uriStr
- * @return the resolved IRI
- * @throws RiotException
- * If resulting URI would not be legal, absolute IRI
- */
- public abstract IRI resolveSilent(String uriStr);
-
- /** Resolving relative IRIs, return a string */
- public String resolveToString(String uriStr) {
- return resolve(uriStr).toString();
- }
-
- /**
- * Resolving relative IRIs, return a string, but do not throw exception on
- * bad a IRI
- */
- public String resolveToStringSilent(String uriStr) {
- return resolveSilent(uriStr).toString();
- }
-
- protected IRIResolver()
- {}
-
- /**
- * Throw any exceptions resulting from IRI.
- *
- * @param iri
- * @return iri
- */
- private static IRI exceptions(IRI iri) {
- if (!showExceptions)
- return iri;
- if (!iri.hasViolation(false))
- return iri;
- String msg = iri.violations(false).next().getShortMessage();
- throw new RiotException(msg);
- }
-
- private static final int CacheSize = 1000;
-
- /**
- * A resolver that does not resolve IRIs against base.
- * This can generate relative IRIs.
- **/
- static class IRIResolverNoOp extends IRIResolver
- {
- protected IRIResolverNoOp()
- {}
-
- private Cache<String, IRI> resolvedIRIs = CacheFactory.createCache(CacheSize);
-
- @Override
- protected IRI getBaseIRI() {
- return null;
- }
-
- @Override
- public IRI resolveSilent(final String uriStr) {
- if ( resolvedIRIs == null )
- return iriFactory().create(uriStr);
- Callable<IRI> filler = () -> iriFactory().create(uriStr);
- IRI iri = resolvedIRIs.getOrFill(uriStr, filler);
- return iri;
- }
-
- @Override
- public String resolveToString(String uriStr) {
- return uriStr;
- }
- }
-
- /** Resolving resolver **/
- static class IRIResolverNormal extends IRIResolver
- {
- final private IRI base;
- // Not static - contains relative IRIs
- // Could split into absolute (static, global cached) and relative.
- private Cache<String, IRI> resolvedIRIs = CacheFactory.createCache(CacheSize);
-
- /**
- * Construct an IRIResolver with base as the current working directory.
- */
- public IRIResolverNormal() {
- this((String)null);
- }
-
- /**
- * Construct an IRIResolver with base determined by the argument URI. If
- * this is relative, it is relative against the current working
- * directory.
- *
- * @param baseStr
- * @throws RiotException
- * If resulting base unparsable.
- */
- public IRIResolverNormal(String baseStr) {
- if ( baseStr == null )
- base = chooseBaseURI();
- else
- base = globalResolver.resolveSilent(baseStr);
- }
-
- public IRIResolverNormal(IRI baseIRI) {
- if ( baseIRI == null )
- baseIRI = chooseBaseURI();
- base = baseIRI;
- }
-
- @Override
- protected IRI getBaseIRI() {
- return base;
- }
-
- @Override
- public IRI resolveSilent(String uriStr) {
- if ( resolvedIRIs == null )
- return resolveSilentNoCache(uriStr);
- else
- return resolveSilentCache(uriStr);
- }
-
- private IRI resolveSilentNoCache(String uriStr) {
- IRI x = IRIResolver.iriFactory().create(uriStr);
- if ( SysRIOT.AbsURINoNormalization ) {
- // Always process "file:", even in strict mode.
- // file: is widely used in irregular forms.
- if ( x.isAbsolute() && ! uriStr.startsWith("file:") )
- return x;
- }
- return base.create(x);
- }
-
- private IRI resolveSilentCache(final String uriStr) {
- Callable<IRI> filler = () -> resolveSilentNoCache(uriStr);
- return resolvedIRIs.getOrFill(uriStr, filler);
- }
- }
-
- /** Thread safe wrapper for an IRIResolver */
- static class IRIResolverSync extends IRIResolver
- {
- private final IRIResolver other;
-
- IRIResolverSync(IRIResolver other) { this.other = other; }
- @Override
- synchronized
- protected IRI getBaseIRI() {
- return other.getBaseIRI();
- }
-
- @Override
- synchronized
- public IRI resolve(String uriStr) {
- return other.resolve(uriStr);
- }
-
- @Override
- synchronized
- public IRI resolveSilent(String uriStr) {
- return other.resolveSilent(uriStr);
- }
- }
+// public static IRI resolve(String relStr, String baseStr) throws RiotException {
+// return exceptions(resolveIRI(relStr, baseStr));
+// }
+//
+// /**
+// * Resolve an IRI against whatever is the base for this process (likely to
+// * be based on the current working directory of this process at the time of
+// * initialization of this class).
+// */
+// public static IRI resolveIRI(String uriStr) {
+// return exceptions(globalResolver.resolve(uriStr));
+// }
+//
+// /**
+// * Resolve a string against a base.
+// * <p>
+// * No exceptions thrown by this method; the application should test the returned
+// * IRI for violations with {@link IRI#hasViolation(boolean)}.
+// */
+// public static IRI resolveIRI(String relStr, String baseStr) {
+// IRI i = iriFactory().create(relStr);
+// if (i.isAbsolute())
+// // removes excess . segments
+// return globalResolver.getBaseIRI().create(i);
+//
+// IRI base = iriFactory().create(baseStr);
+// return base.create(i);
+// }
+//
+// /**
+// * Choose a base URI based on the current directory
+// *
+// * @return String Absolute URI
+// */
+// public static IRI chooseBaseURI() {
+// return globalResolver.getBaseIRI();
+// }
+//
+// // The global resolver may be accessed by multiple threads
+// // Other resolvers are not thread safe.
+//
+//// /**
+//// * Turn a filename into a well-formed file: URL relative to the working
+//// * directory.
+//// *
+//// * @param filename
+//// * @return String The filename as an absolute URL
+//// */
+// static public String resolveFileURL(String filename) throws IRIException {
+// IRI r = globalResolver.resolve(filename);
+// if (!r.getScheme().equalsIgnoreCase("file")) {
+// // Pragmatic hack that copes with "c:"
+// return resolveFileURL("./" + filename);
+// }
+// return r.toString();
+// }
+//
+// /**
+// * Resolve a URI against a base.
+// *
+// * @param relStr
+// * @param baseStr
+// * Can be null if relStr is absolute
+// * @return String An absolute URI
+// * @throws RiotException
+// * If result would not be legal, absolute IRI
+// */
+// static public String resolveString(String relStr, String baseStr) throws RiotException {
+// return exceptions(resolveIRI(relStr, baseStr)).toString();
+// }
+//
+// /**
+// * Resolve a URI against the base for this process. If baseStr is a
+// * relative file IRI then it is first resolved against the current
+// * working directory. If it is an absolute URI, it is normalized.
+// *
+// * @param uriStr
+// * @return String An absolute URI
+// * @throws RiotException
+// * If result would not be legal, absolute IRI
+// */
+// static public String resolveString(String uriStr) throws RiotException {
+// return exceptions(resolveIRI(uriStr)).toString();
+// }
+//
+// /**
+// * Resolve a URI against a base. If baseStr is a relative file IRI
+// * then it is first resolved against the current working directory.
+// * If it is an absolute URI, it is normalized.
+// *
+// * @param uriStr
+// * @return String An absolute URI
+// */
+// static public String resolveStringSilent(String uriStr) throws RiotException {
+// return globalResolver.resolveSilent(uriStr).toString();
+// }
+//
+// public static IRIResolver create() {
+// return new IRIResolverNormal();
+// }
+//
+// public static IRIResolver create(String baseStr) {
+// return new IRIResolverNormal(baseStr);
+// }
+//
+// public static IRIResolver create(IRI baseIRI) {
+// return new IRIResolverNormal(baseIRI);
+// }
+//
+// /** A resolver that does not resolve against a base IRI. */
+// public static IRIResolver createNoResolve() {
+// return new IRIResolverNoOp();
+// }
+//
+// /**
+// * To allow Eyeball to bypass IRI checking (because it's doing its own)
+// */
+// public static void suppressExceptions() {
+// showExceptions = false;
+// }
+//
+// public String getBaseIRIasString() {
+// IRI iri = getBaseIRI();
+// if (iri == null)
+// return null;
+// return iri.toString();
+// }
+//
+// /**
+// * The base of this IRIResolver.
+// *
+// * @return String
+// */
+// protected abstract IRI getBaseIRI();
+//
+// /**
+// * Resolve a relative URI against the base of this IRIResolver
+// * or normalize an absolute URI.
+// *
+// * @param uriStr
+// * @return the resolved IRI
+// * @throws RiotException
+// * If resulting URI would not be legal, absolute IRI
+// */
+// public IRI resolve(String uriStr) {
+// return exceptions(resolveSilent(uriStr));
+// }
+//
+// /**
+// * Create a URI, resolving relative IRIs,
+// * normalize an absolute URI,
+// * but do not throw exception on a bad IRI.
+// *
+// * @param uriStr
+// * @return the resolved IRI
+// * @throws RiotException
+// * If resulting URI would not be legal, absolute IRI
+// */
+// public abstract IRI resolveSilent(String uriStr);
+//
+// /** Resolving relative IRIs, return a string */
+// public String resolveToString(String uriStr) {
+// return resolve(uriStr).toString();
+// }
+//
+// /**
+// * Resolving relative IRIs, return a string, but do not throw exception on
+// * bad a IRI
+// */
+// public String resolveToStringSilent(String uriStr) {
+// return resolveSilent(uriStr).toString();
+// }
+//
+// protected IRIResolver()
+// {}
+//
+// /**
+// * Throw any exceptions resulting from IRI.
+// *
+// * @param iri
+// * @return iri
+// */
+// private static IRI exceptions(IRI iri) {
+// if (!showExceptions)
+// return iri;
+// if (!iri.hasViolation(false))
+// return iri;
+// String msg = iri.violations(false).next().getShortMessage();
+// throw new RiotException(msg);
+// }
+//
+// private static final int CacheSize = 1000;
+//
+// /**
+// * A resolver that does not resolve IRIs against base.
+// * This can generate relative IRIs.
+// **/
+// static class IRIResolverNoOp extends IRIResolver
+// {
+// protected IRIResolverNoOp()
+// {}
+//
+// private Cache<String, IRI> resolvedIRIs = CacheFactory.createCache(CacheSize);
+//
+// @Override
+// protected IRI getBaseIRI() {
+// return null;
+// }
+//
+// @Override
+// public IRI resolveSilent(final String uriStr) {
+// if ( resolvedIRIs == null )
+// return iriFactory().create(uriStr);
+// Callable<IRI> filler = () -> iriFactory().create(uriStr);
+// IRI iri = resolvedIRIs.getOrFill(uriStr, filler);
+// return iri;
+// }
+//
+// @Override
+// public String resolveToString(String uriStr) {
+// return uriStr;
+// }
+// }
+//
+// /** Resolving resolver **/
+// static class IRIResolverNormal extends IRIResolver
+// {
+// final private IRI base;
+// // Not static - contains relative IRIs
+// // Could split into absolute (static, global cached) and relative.
+// private Cache<String, IRI> resolvedIRIs = CacheFactory.createCache(CacheSize);
+//
+// /**
+// * Construct an IRIResolver with base as the current working directory.
+// */
+// public IRIResolverNormal() {
+// this((String)null);
+// }
+//
+// /**
+// * Construct an IRIResolver with base determined by the argument URI. If
+// * this is relative, it is relative against the current working
+// * directory.
+// *
+// * @param baseStr
+// * @throws RiotException
+// * If resulting base unparsable.
+// */
+// public IRIResolverNormal(String baseStr) {
+// if ( baseStr == null )
+// base = chooseBaseURI();
+// else
+// base = globalResolver.resolveSilent(baseStr);
+// }
+//
+// public IRIResolverNormal(IRI baseIRI) {
+// if ( baseIRI == null )
+// baseIRI = chooseBaseURI();
+// base = baseIRI;
+// }
+//
+// @Override
+// protected IRI getBaseIRI() {
+// return base;
+// }
+//
+// @Override
+// public IRI resolveSilent(String uriStr) {
+// if ( resolvedIRIs == null )
+// return resolveSilentNoCache(uriStr);
+// else
+// return resolveSilentCache(uriStr);
+// }
+//
+// private IRI resolveSilentNoCache(String uriStr) {
+// IRI x = IRIResolver.iriFactory().create(uriStr);
+// if ( SysRIOT.AbsURINoNormalization ) {
+// // Always process "file:", even in strict mode.
+// // file: is widely used in irregular forms.
+// if ( x.isAbsolute() && ! uriStr.startsWith("file:") )
+// return x;
+// }
+// return base.create(x);
+// }
+//
+// private IRI resolveSilentCache(final String uriStr) {
+// Callable<IRI> filler = () -> resolveSilentNoCache(uriStr);
+// return resolvedIRIs.getOrFill(uriStr, filler);
+// }
+// }
+//
+// /** Thread safe wrapper for an IRIResolver */
+// static class IRIResolverSync extends IRIResolver
+// {
+// private final IRIResolver other;
+//
+// IRIResolverSync(IRIResolver other) { this.other = other; }
+// @Override
+// synchronized
+// protected IRI getBaseIRI() {
+// return other.getBaseIRI();
+// }
+//
+// @Override
+// synchronized
+// public IRI resolve(String uriStr) {
+// return other.resolve(uriStr);
+// }
+//
+// @Override
+// synchronized
+// public IRI resolveSilent(String uriStr) {
+// return other.resolveSilent(uriStr);
+// }
+// }
Review comment:
This is the old code largely not used but there are still a few places using jena-iri IRI directly based on the IRIFactory defined in this class. These need tracking down and individually checking - jena-iri is better at warnings about IRIs than the future replacement.
The commented methods are a temporary way someone is (unexpected) using IRIREsolver and can restore their code easily. Hopefully, that won't happen!
There is a balance - to give the new code as much time in the default branch as possible (or pushing out the release date), the task of chasing down every detail isn't completed but is a manageable length now.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
[GitHub] [jena] afs commented on pull request #910: JENA-2031: IRI provider/functional abstraction
Posted by GitBox <gi...@apache.org>.
afs commented on pull request #910:
URL: https://github.com/apache/jena/pull/910#issuecomment-772439425
Here is a list of links:
URI: https://tools.ietf.org/html/rfc3986
HTTP: https://tools.ietf.org/html/rfc7230
URN: https://tools.ietf.org/html/rfc8141
UUID: https://tools.ietf.org/html/rfc4122 (as urn:uuid:)
DID: https://www.w3.org/TR/did-core/
file: https://tools.ietf.org/html/rfc8089#section-2
URI scheme registry: https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml
URN namespace registry: https://www.iana.org/assignments/urn-namespaces/urn-namespaces.xhtml
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
[GitHub] [jena] afs edited a comment on pull request #910: JENA-2031: IRI provider/functional abstraction
Posted by GitBox <gi...@apache.org>.
afs edited a comment on pull request #910:
URL: https://github.com/apache/jena/pull/910#issuecomment-772437775
This is now complete. There is further checking that can be done which is why it'll be "draft" for awhile.
`jena-iri` is still used directly in the XML I/O, `jena-jdbc-core` and cmds for IRI validation. Those can wait if they need changing at all.
Almost inevitably, from going through all the code, reviewing the parser tests, and generally going back to look at old code,
Only http, urn and file URIs have scheme specific checking.
**Change 1**
Bad percent encoding e.g. `http://example/abc%XZdef` is strictly a syntax error in RFC 3986, not merely bad practice. In the changes here, it becomes an error.
There are no warnings for lowercase (upper case is recommended, but not required).
**Change 2**
URN handling: RFC 8141 tightens up the rules on URNs to be urn:NID:NSS, NID is at least 2 alphanumerics, and NSS at least one. This is more restrictive that the previous RFC 2141 which allowed NID to be "X-"
A consequence is that using `urn:NID:` as a prefix is strictly an illegal URN but Jena accepted it.
`urn:x:` was never legal but Jena accepted it and I would not be surprised if it is used in Jena users test data. It was in Jena although now that's all cleaned up and the Jena test suite passes in strict URI mode.
Currently, the default is to run with only light checking of URN specific rules.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
[GitHub] [jena] afs commented on pull request #910: JENA-2031: IRI provider/functional abstraction
Posted by GitBox <gi...@apache.org>.
afs commented on pull request #910:
URL: https://github.com/apache/jena/pull/910#issuecomment-771096772
This is an unfinished draft.
See the package "irix" (this is a temporary location).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
[GitHub] [jena] afs commented on pull request #910: JENA-2031: IRI provider/functional abstraction
Posted by GitBox <gi...@apache.org>.
afs commented on pull request #910:
URL: https://github.com/apache/jena/pull/910#issuecomment-772559654
Performance: pure parsing costs. (light test)
Test: Running "riot" with 4 BSBM 25 million .nt.gz in one run of the program (the argument being the first time warms the JVM; in fact the numbers don't show any effect). File has been used previously so in the file system cache.
Jena 3.17.0 and Jena+thisPR are within 0.5% of each other which is less than the timing variance.
Jena+PR with the [new IRI parser](https://github.com/afs/iri4ld/) is at least 12% faster. I'm surprised it's measurable.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
[GitHub] [jena] afs commented on pull request #910: JENA-2031: IRI provider/functional abstraction
Posted by GitBox <gi...@apache.org>.
afs commented on pull request #910:
URL: https://github.com/apache/jena/pull/910#issuecomment-773391589
JENA-2033 here to avoid a potential merge conflict because the fix is to a class modified by this PR.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
[GitHub] [jena] rvesse commented on pull request #910: JENA-2031: IRI provider/functional abstraction
Posted by GitBox <gi...@apache.org>.
rvesse commented on pull request #910:
URL: https://github.com/apache/jena/pull/910#issuecomment-771497623
The basic interface looks fine as far as I'm able to pick it out amongst the swathe of related changes
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org