
org.everit.json.schema.loader.Uri Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of org.everit.json.schema Show documentation
Show all versions of org.everit.json.schema Show documentation
This is a fork of the implementation of the JSON Schema Core Draft v4 specification built with the org.json API which also supports internationalization
The newest version!
package org.everit.json.schema.loader;
import static java.util.Objects.requireNonNull;
import java.net.URI;
import java.net.URISyntaxException;
class Uri {
static Uri parse(String str) throws URISyntaxException {
URI rawUri = new URI(str);
int poundIdx = str.indexOf('#');
String fragment;
URI toBeQueried;
if (poundIdx == -1) {
toBeQueried = rawUri;
fragment = "";
} else {
fragment = str.substring(poundIdx);
toBeQueried = new URI(str.substring(0, poundIdx));
}
return new Uri(toBeQueried, fragment);
}
URI toBeQueried;
String fragment;
private Uri(URI toBeQueried, String fragment) {
this.toBeQueried = requireNonNull(toBeQueried, "toBeQueried cannot be null");
this.fragment = requireNonNull(fragment, "fragment cannot be null");
}
URI asJavaURI() {
try {
return new URI(toBeQueried + fragment);
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy