Skip to content

Commit 4bd20b1

Browse files
committed
IRI3986: Remove legacyCompatibility; tidy code
1 parent 28150fa commit 4bd20b1

File tree

4 files changed

+6
-40
lines changed

4 files changed

+6
-40
lines changed

jena-iri3986/src/main/java/org/apache/jena/rfc3986/AlgRelativizeIRI.java

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,10 @@
2222
import java.util.StringJoiner;
2323

2424
/**
25-
* More algorithms on IRI3986's.
26-
* The various forms of relativizing IRIs.
25+
* More relativization algorithms on IRI3986's.
2726
*/
2827
public class AlgRelativizeIRI {
2928

30-
// For compatibility with jena-iri ...
31-
// relativeScheme: when only the scheme with no "//", then NETWORK does not abbreviate.
32-
// Strict, illegal because if there is a scheme, there must be //
33-
/*package*/ static final boolean legacyCompatibility = false;
34-
3529
/**
3630
* Calculate a "same scheme" relative URI, if possible.
3731
* <p>
@@ -43,8 +37,7 @@ public static IRI3986 relativeScheme(IRI base, IRI target) {
4337
return null;
4438
if ( ! Objects.equals(base.scheme(), target.scheme()) )
4539
return null;
46-
if ( legacyCompatibility && ! base.hasAuthority() && base.path().isEmpty() )
47-
return IRI3986.build(null, "", target.path(), target.query(), target.fragment());
40+
// No scheme.
4841
return IRI3986.build(null, target.authority(), target.path(), target.query(), target.fragment());
4942
}
5043

@@ -65,18 +58,6 @@ public static IRI3986 relativeResource(IRI base, IRI target) {
6558
return IRI3986.build(null, null, target.path(), target.query(), target.fragment());
6659
}
6760

68-
/**
69-
* Calculate a relative URI as a absolute path, if possible.
70-
* <p>
71-
* That is, the IRIs have the same scheme and authority.
72-
* The base does not have a query string.
73-
* The relative URI is the path, query and fragment of the target.
74-
*/
75-
public static IRI3986 relativeAbsolutePath(IRI base, IRI target) {
76-
// Same as relativeLocalResource, using jena-iri naming.
77-
return relativeResource(base, target);
78-
}
79-
8061
/**
8162
* Calculate a "same document" relative URI, if possible.
8263
* <p>
@@ -138,23 +119,11 @@ public static IRI3986 relativePath(IRI base, IRI target) {
138119
return IRI3986.build(null, null, x, target.query(), target.fragment());
139120
}
140121

141-
if ( legacyCompatibility ) {
142-
// Same path, no target query.
143-
// This would be just a #frag which is "same document".
144-
// For compatibility with jena-iri ...
145-
String pathRel = lastSegment(targetPath);
146-
if ( pathRel.isEmpty() )
147-
pathRel = ".";
148-
return IRI3986.build(null, null, pathRel, null, target.fragment());
149-
} else {
150-
String pathRel = targetPath.endsWith("/") ?
151-
// Both "" and "." are possible when the two paths end "/".
152-
"." : "";
153-
return IRI3986.build(null, null, pathRel, null, target.fragment());
154-
}
122+
// Both "" and "." are possible when the two paths end "/".
123+
String pathRel = targetPath.endsWith("/") ? "." : "";
124+
return IRI3986.build(null, null, pathRel, null, target.fragment());
155125
}
156126

157-
158127
String relPath = relativeChildPath(basePath, targetPath);
159128
if ( relPath == null )
160129
return null;

jena-iri3986/src/main/java/org/apache/jena/rfc3986/AlgResolveIRI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import java.util.Objects;
2222
import java.util.StringJoiner;
2323

24-
/** Algorithms for IRIs : resolution */
24+
/** Algorithms for IRIs : resolution and relativize (reverse of resolution). */
2525
public class AlgResolveIRI {
2626

2727
/**

jena-iri3986/src/main/java/org/apache/jena/rfc3986/ParseDNS.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ private void parse(boolean allowPercentEncoding) {
135135
// Must have one or more labels.
136136
error("No subdomains.");
137137

138-
139138
List<Integer> dots = new ArrayList<>(4);
140139

141140
while (p < end) {
@@ -148,7 +147,6 @@ private void parse(boolean allowPercentEncoding) {
148147
// Separator dots
149148
dots.add(p-1);
150149
}
151-
//System.out.println("Dots: "+dots);
152150
}
153151

154152
// <label> ::= <letter> [ [ <ldh-str> ] <let-dig> ]

jena-iri3986/src/test/java/org/apache/jena/rfc3986/TestNormalize.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,4 @@ private void testNormalize(String input, String expected) {
5555
String s = iri2.toString();
5656
assertEquals(expected, s);
5757
}
58-
5958
}

0 commit comments

Comments
 (0)