Example usage for java.net URI getScheme

List of usage examples for java.net URI getScheme

Introduction

In this page you can find the example usage for java.net URI getScheme.

Prototype

public String getScheme() 

Source Link

Document

Returns the scheme component of this URI.

Usage

From source file:Main.java

/**
 * Given an endpoint, calculate the corresponding BrowserID audience.
 * <p>/*from w  w  w . j a  v  a2 s  .  c o m*/
 * This is the domain, in web parlance.
 *
 * @param serverURI endpoint.
 * @return BrowserID audience.
 * @throws URISyntaxException
 */
public static String getAudienceForURL(String serverURI) throws URISyntaxException {
    URI uri = new URI(serverURI);
    return new URI(uri.getScheme(), null, uri.getHost(), uri.getPort(), null, null, null).toString();
}

From source file:Main.java

public static int getEffectivePort(URI uri) {
    return getEffectivePort(uri.getScheme(), uri.getPort());
}

From source file:Main.java

/**
 * Return true if the given string can be parsed as a URI and
 * begins with a URI scheme (e.g. "http://something"), false otherwise.
 *
 * @param uriString/*from   w  ww.ja  va 2 s .  c  o m*/
 * @throws NullPointerException If uriString is null.
 * @return
 */
public static boolean isAbsoluteUri(String uriString) {
    try {
        URI uri = new URI(uriString);
        return uri.getScheme() != null;
    } catch (URISyntaxException ex) {
        return false;
    }
}

From source file:com.jayway.restassured.internal.UriValidator.java

/**
 * Checks if the <code>potentialUri</code> is a URI.
 *
 * @param potentialUri The URI to check.
 * @return <code>true</code> if it is a URI, <code>false</code> otherwise.
 *///from ww w.  j av  a 2  s .com
public static boolean isUri(String potentialUri) {
    if (StringUtils.isBlank(potentialUri)) {
        return false;
    }

    try {
        URI uri = new URI(potentialUri);
        return uri.getScheme() != null && uri.getHost() != null;
    } catch (URISyntaxException e) {
        return false;
    }
}

From source file:com.spotify.docker.client.UnixConnectionSocketFactory.java

public static URI sanitizeUri(final URI uri) {
    if (uri.getScheme().equals("unix")) {
        return URI.create("unix://localhost:80");
    } else {//ww w  .  j a v a2  s  . co m
        return uri;
    }
}

From source file:Main.java

/**
 * Test to see if the URI is of the iRODS scheme "irods://".
 * //from w  w  w . j av a2s . c  o m
 * @param irodsURI
 *            {@link URI} to check
 * @return <code>boolean</code> which is <code>true</code> if this is the
 *         iRODS URI scheme.
 */
public static boolean isIRODSURIScheme(final URI irodsURI) {

    boolean isURI = false;
    String uriScheme = irodsURI.getScheme();
    if (uriScheme != null && uriScheme.equals("irods")) {
        isURI = true;
    }
    return isURI;
}

From source file:Main.java

public static void printURIDetails(URI uri) {
    System.out.println("URI:" + uri);
    System.out.println("Normalized:" + uri.normalize());
    String parts = "[Scheme=" + uri.getScheme() + ", Authority=" + uri.getAuthority() + ", Path="
            + uri.getPath() + ", Query:" + uri.getQuery() + ", Fragment:" + uri.getFragment() + "]";
    System.out.println(parts);/* w  ww.j  a va2  s  .  c  o m*/
    System.out.println();
}

From source file:io.lavagna.config.DataSourceConfig.java

private static String scheme(URI uri) {
    return "postgres".equals(uri.getScheme()) ? "jdbc:postgresql" : uri.getScheme();
}

From source file:Main.java

public static boolean isURI(String str) {

    if (str.indexOf(':') == -1)
        return false;
    str = str.toLowerCase(Locale.ENGLISH).trim();

    if (!str.startsWith("http://") && !str.startsWith("https://") && !str.startsWith("ftp://"))
        return false;

    try {//from  w  ww .  j  a  v a  2  s .  c om

        URI uri = new URI(str);
        String proto = uri.getScheme();

        if (proto == null)
            return false;

        if (proto.equals("http") || proto.equals("https") || proto.equals("ftp")) {

            if (uri.getHost() == null)
                return false;

            String path = uri.getPath();
            if (path != null) {

                int len = path.length();
                for (int i = 0; i < len; i++) {

                    if ("?<>:*|\"".indexOf(path.charAt(i)) > -1)
                        return false;
                }
            }
        }

        return true;
    } catch (Exception ex) {

        return false;
    }
}

From source file:io.gravitee.gateway.standalone.DynamicRoutingGatewayTest.java

private static URI create(URI uri, int port) {
    try {/*from  ww w . ja v a 2 s  .c  o  m*/
        return new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), port, uri.getPath(), uri.getQuery(),
                uri.getFragment());
    } catch (URISyntaxException e) {
        return uri;
    }
}