All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dimajix.shaded.everit.schema.loader.Uri Maven / Gradle / Ivy

There is a newer version: 1.2.0-synapse3.3-spark3.3-hadoop3.3
Show newest version
package com.dimajix.shaded.everit.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 - 2024 Weber Informatics LLC | Privacy Policy