Example usage for java.net URI toString

List of usage examples for java.net URI toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns the content of this URI as a string.

Usage

From source file:Main.java

public static Document load(URI uri) {
    return load(new InputSource(uri.toString()));
}

From source file:Main.java

/**
 * Resolves a reference starting with a query string.
 *
 * @param baseURI the base URI/*w  w w. ja va2  s .  c  o  m*/
 * @param reference the URI reference starting with a query string
 * @return the resulting URI
 */
private static URI resolveReferenceStartingWithQueryString(final URI baseURI, final URI reference) {
    String baseUri = baseURI.toString();
    baseUri = baseUri.indexOf('?') > -1 ? baseUri.substring(0, baseUri.indexOf('?')) : baseUri;
    return URI.create(baseUri + reference.toString());
}

From source file:com.czy.core.orm.config.mybatis.SpringBootVFS.java

private static String preserveSubpackageName(final URI uri, final String rootPath) {
    final String uriStr = uri.toString();
    final int start = uriStr.indexOf(rootPath);
    return uriStr.substring(start, uriStr.length());
}

From source file:com.github.mybatis.repository.autoconfig.SpringBootVFS.java

private static String preserveSubpackageName(final URI uri, final String rootPath) {
    final String uriStr = uri.toString();
    final int start = uriStr.indexOf(rootPath);
    return uriStr.substring(start);
}

From source file:com.blackducksoftware.integration.jira.common.HubUrlParser.java

public static String getRelativeUrl(final String url) throws HubIntegrationException {
    if (url == null) {
        return null;
    }//from w  ww .j av  a2 s .  c om
    try {
        final String baseUrl = getBaseUrl(url);
        final URI baseUri = new URI(baseUrl);
        final URI origUri = new URI(url);
        final URI relativeUri = baseUri.relativize(origUri);
        return relativeUri.toString();
    } catch (URISyntaxException e) {
        throw new HubIntegrationException("Invalid URI syntax exception on " + url + ": " + e.getMessage());
    }
}

From source file:edu.jhu.pha.vospace.node.VospaceId.java

/**
 * Check whether the specified identifier is valid
 * @param id The identifier to check/*w w  w .  ja va2 s.co  m*/
 * @return whether the identifier is valid or not
 */
private static boolean validId(URI id) {
    Matcher m = VOS_PATTERN.matcher(id.toString());
    return m.matches();
}

From source file:piecework.util.ContentUtility.java

public static boolean validateRemoteLocation(Set<String> acceptableRegularExpressions, URI uri) {
    String location = uri.toString();
    if (acceptableRegularExpressions != null && !acceptableRegularExpressions.isEmpty()) {
        for (String acceptableRegularExpression : acceptableRegularExpressions) {
            Pattern pattern = Pattern.compile(acceptableRegularExpression);
            if (pattern.matcher(location).matches())
                return true;
        }/*from  www.j  a v  a 2s. com*/
    }
    return false;
}

From source file:org.openlmis.fulfillment.service.request.RequestHelper.java

/**
 * Split the given {@link RequestParameters} into smaller chunks.
 *///from  w  w w.  ja  v a  2  s  .c  o  m
public static URI[] splitRequest(String url, RequestParameters queryParams, int maxUrlLength) {
    RequestParameters safeQueryParams = RequestParameters.init().setAll(queryParams);
    URI uri = createUri(url, safeQueryParams);

    if (uri.toString().length() > maxUrlLength) {
        Pair<RequestParameters, RequestParameters> split = safeQueryParams.split();

        if (null != split.getLeft() && null != split.getRight()) {
            URI[] left = splitRequest(url, split.getLeft(), maxUrlLength);
            URI[] right = splitRequest(url, split.getRight(), maxUrlLength);

            return Stream.concat(Arrays.stream(left), Arrays.stream(right)).distinct().toArray(URI[]::new);
        }
    }

    return new URI[] { uri };
}

From source file:de.mpg.imeji.presentation.util.UrlHelper.java

public static boolean isValidURI(URI uri) {
    try {/*from  ww w .ja v  a2 s .com*/
        HttpClient client = new HttpClient();
        GetMethod method = new GetMethod(uri.toString());
        client.executeMethod(method);
        return true;
    } catch (Exception e) {
        BeanHelper.error(((SessionBean) BeanHelper.getSessionBean(SessionBean.class)).getMessage("error")
                + " (Non valid URL): " + e);
    }
    return false;
}

From source file:com.blackducksoftware.integration.hub.util.HubUrlParser.java

public static String getRelativeUrl(final String url) throws URISyntaxException {
    if (url == null) {
        return null;
    }/* w  ww. j av  a 2 s  .  co m*/
    final String baseUrl = getBaseUrl(url);
    final URI baseUri = new URI(baseUrl);
    final URI origUri = new URI(url);
    final URI relativeUri = baseUri.relativize(origUri);
    return relativeUri.toString();
}