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:com.ocrix.ppc.commons.Validator.java

/**
 * Validates an URI, if it is not valid then throws IllegalArgumentException
 * /* www  .  j  a va2 s  . c  om*/
 * @param uri
 *            to be validated
 */
public static void validateURI(URI uri) {
    UrlValidator urlValidator = new UrlValidator();
    if (!urlValidator.isValid(uri.toString()))
        throw new IllegalArgumentException("Please check a provided URI [ " + uri + " ]");
}

From source file:xworker.app.model.tree.http.HttpExtjsJsonTreeModelActions.java

@SuppressWarnings("unchecked")
public static void checkImageUrl(Map<String, Object> node, URI root) {
    String iconPath = (String) node.get("icon");
    if (iconPath != null && !"".equals(iconPath)) {
        URI iconUri = root.resolve(iconPath);
        node.put("icon", iconUri.toString());
    }//from   w w w  .  j  av a 2  s  . c  om

    List<Map<String, Object>> childs = (List<Map<String, Object>>) node.get("childs");
    if (childs != null) {
        checkImageUrl(childs, root);
    }
}

From source file:de.elomagic.carafile.client.CaraFileUtils.java

/**
 * Creates an URI from a base URI and given path elements.
 * <p/>/*ww w.j ava  2 s  .  c o m*/
 * Path elements will be encoded when required.
 *
 * @param base {@link URI} base
 * @param pathElements Valid base URI path elements.
 * @return An URI
 * @throws java.io.UnsupportedEncodingException Thrown when pathElements includes unsupported characters
 */
public static URI buildURI(final URI base, final String... pathElements) throws UnsupportedEncodingException {
    String s = base.toString();

    for (String value : pathElements) {
        if (!s.endsWith("/")) {
            s += "/";
        }

        s += URLEncoder.encode(value, "utf-8");
        ;
    }

    try {
        return new URI(s);
    } catch (URISyntaxException ex) {
        throw new IllegalArgumentException(
                "Unable to build URI. base=" + base + ";values=" + Arrays.toString(pathElements));
    }
}

From source file:Main.java

public static final String dereference(String idRef) {
    URI uri = URI.create(idRef);
    String part = uri.getSchemeSpecificPart();
    if (part != null && part.length() > 0) {
        throw new UnsupportedOperationException(
                "modlur does not support external sources (" + uri.toString() + ")");
    }/*from w  ww  . j  a v  a 2 s .  c  o  m*/
    return uri.getFragment();
}

From source file:cn.hi321.browser.weave.client.WeaveUtil.java

public static String toString(URI uri) {
    checkNull(uri);/*from ww w.j a  v a2 s  .co m*/
    String retval = uri == null ? null : uri.toString();
    checkNull(retval);
    return retval;
}

From source file:enrichment.Disambiguate.java

static ArrayList<String> getAllCreators(URI resource)
        throws URISyntaxException, ClientProtocolException, IOException {
    System.out.print("\nCreators=" + resource.toString());
    ArrayList<String> al = new ArrayList<String>();
    List<NameValuePair> qparams = new ArrayList<NameValuePair>();
    String query = "CONSTRUCT {  <" + resource + "> <http://purl.org/dc/elements/1.1/creator> ?o } WHERE { <"
            + resource + "> <http://purl.org/dc/elements/1.1/creator> ?o } ";

    qparams.add(new BasicNameValuePair("query", query));
    URLEncodedUtils.format(qparams, "UTF-8");
    URI uri = URIUtils.createURI("http", "test.lobid.org", -1, "/sparql/",
            URLEncodedUtils.format(qparams, "UTF-8"), null);
    HttpGet httpget = new HttpGet(uri);
    HttpClient httpclient = new DefaultHttpClient();
    httpget.addHeader("Accept", "text/plain");
    HttpResponse response = httpclient.execute(httpget);
    HttpEntity entity = response.getEntity();
    if (entity != null) {
        BufferedReader br = new BufferedReader(new InputStreamReader(entity.getContent()));
        String s;/*from w w  w .  ja v  a 2s . c  o  m*/
        while ((s = br.readLine()) != null) {
            s = s.split(" ")[2]; // getting object
            al.add(s);
        }
    }
    return al;
}

From source file:com.kolich.havalo.client.service.HavaloAbstractService.java

/**
 * Checks if the given URI is non-null, and if it's a complete endpoint
 * URI that already starts with "https://" or "http://".
 * @param uri/*from  w  ww. j a  v  a  2s  .c  om*/
 * @return
 */
private static final boolean isComplete(final URI uri) {
    return uri != null && (uri.toString().startsWith(HTTPS) || uri.toString().startsWith(HTTP));
}

From source file:com.vmware.identity.openidconnect.protocol.URIUtils.java

public static URI appendFragmentParameters(URI uri, Map<String, String> parameters) {
    Validate.notNull(uri, "uri");
    Validate.notNull(parameters, "parameters");

    URI uriWithQuery = appendQueryParameters(uri, parameters);
    String uriWithFragmentString = uriWithQuery.toString().replace('?', '#');
    try {// ww  w .  jav  a2  s .  co  m
        return URIUtils.parseURI(uriWithFragmentString);
    } catch (ParseException e) {
        throw new IllegalArgumentException("failed to convert uri query string to fragment", e);
    }
}

From source file:com.jtstand.swing.Main.java

public static URI resolve(String uristr) {
    File curdirrel = new File(".");
    File curdir = new File(curdirrel.getAbsolutePath());
    URI cururi = curdir.toURI().normalize();
    log.trace("URI of the current directory: " + cururi.toString());
    return resolve(uristr, cururi);
}

From source file:Neo4JDataExporter.java

private static void addMetadataToProperty(URI relationshipUri, String name, String value)
        throws URISyntaxException {
    URI propertyUri = new URI(relationshipUri.toString() + "/properties");
    String entity = toJsonNameValuePairCollection(name, value);
    WebResource resource = Client.create().resource(propertyUri);
    ClientResponse response = resource.accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON)
            .entity(entity).put(ClientResponse.class);

    System.out.println(/*w  w  w.  j av  a2 s  .com*/
            String.format("PUT [%s] to [%s], status code [%d]", entity, propertyUri, response.getStatus()));
    response.close();
}