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

io.deephaven.uri.RemoteQueryScopeUri Maven / Gradle / Ivy

There is a newer version: 0.36.1
Show newest version
/**
 * Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending
 */
package io.deephaven.uri;

import java.net.URI;
import java.util.regex.Matcher;

class RemoteQueryScopeUri {

    static boolean isWellFormed(URI uri) {
        return RemoteUri.isValidScheme(uri.getScheme())
                && UriHelper.isRemotePath(uri)
                && QueryScopeUri.PATH_PATTERN.matcher(uri.getPath()).matches();
    }

    static RemoteUri of(URI uri) {
        if (!isWellFormed(uri)) {
            throw new IllegalArgumentException();
        }
        final Matcher matcher = QueryScopeUri.PATH_PATTERN.matcher(uri.getPath());
        if (!matcher.matches()) {
            throw new IllegalStateException();
        }
        final String variableName = matcher.group(1);
        final QueryScopeUri queryScopeUri = QueryScopeUri.of(variableName);
        return RemoteUri.of(DeephavenTarget.from(uri), queryScopeUri);
    }

    static String toString(DeephavenTarget target, QueryScopeUri uri) {
        return String.format("%s/%s/%s", target, QueryScopeUri.SCOPE, uri.variableName());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy