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:cool.pandora.modeller.ui.handlers.iiif.PatchResourceHandler.java

private static String getDestinationURI(final URI resourceContainer, final String filename) {
    return resourceContainer.toString() + "/" + filename;
}

From source file:com.github.thesmartenergy.sparql.generate.jena.engine.CSVW.java

@BeforeClass
public static void setUpClass() throws Exception {
    LOG = Logger.getLogger(CSVW.class);
    LOG.debug(CSVW.class.getName());
    examplePath = CSVW.class.getResource("/csvw");
    exampleDir = new File(examplePath.toURI());

    // read location-mapping
    URI confUri = exampleDir.toURI().resolve("configuration.ttl");
    Model conf = RDFDataMgr.loadModel(confUri.toString());

    // initialize file manager
    fileManager = FileManager.makeGlobal();
    Locator loc = new LocatorFile(exampleDir.toURI().getPath());
    LocationMapper mapper = new LocationMapper(conf);
    fileManager.addLocator(loc);// ww  w. ja  v  a 2 s  .  c o m
    fileManager.setLocationMapper(mapper);
}

From source file:com.seajas.search.utilities.web.WebFeeds.java

/**
 * Ensures a usable {@code feed}./*from www .ja  v a2s .  c  o m*/
 *
 * @param feed the subject.
 * @param link the content location.
 * @throws FeedException if all correction attempts fail.
 */
public static void validate(SyndFeed feed, URI link) throws FeedException {
    if (feed.getUri() == null)
        feed.setUri(link.toString());
    if (feed.getLink() == null)
        feed.setLink(link.toString());

    if (feed.getFeedType() == null) {
        logger.debug("Defaulting to RSS 2.0 spec.");
        feed.setFeedType("rss_2.0");
    }

    if (feed.getTitleEx() == null)
        feed.setTitle("Feed");
    if (feed.getDescriptionEx() == null)
        feed.setDescription("Feed content");

    for (Object entry : feed.getEntries())
        validateEntry((SyndEntry) entry, feed);
}

From source file:com.vmware.identity.openidconnect.common.CommonUtils.java

public static boolean isValidUri(URI uri) {
    Validate.notNull(uri, "uri");

    String[] schemes = { "https" };
    UrlValidator urlValidator = new UrlValidator(schemes);
    return urlValidator.isValid(uri.toString());
}

From source file:Main.java

/**
 * Create URL using base URI.// ww  w.ja va 2  s  .  c om
 * 
 * @param url a URL string.
 * @param baseURI a base url string to assist in creating a URL.
 * @return newly created URL.
 * @throws MalformedURLException if a malformed URL has occurred.
 */
public static URL createURL(String url, String baseURI) throws MalformedURLException {
    URL returnURL = null;
    URI uri = null;
    try {
        returnURL = new URL(url);
        uri = new URI(url);
        uri = uri.normalize();
        returnURL = new URL(uri.toString());
    }

    catch (Exception mue) {
        int i = baseURI.lastIndexOf('/');
        int j = baseURI.lastIndexOf('\\');
        if (j > i)
            i = j;
        try {
            uri = new URI(baseURI.substring(0, i + 1) + url);
            uri = uri.normalize();
            returnURL = uri.toURL();
        } catch (Exception e) {
            return new URL(baseURI.substring(0, i + 1) + url);
        }
    }
    return returnURL;
}

From source file:UriUtils.java

/**
 * Returns the parent of the specified URI.
 * <p/>//from   w  w  w  . jav  a 2 s .  c o m
 * For example, applying this method to the URI &quot;<tt>http://www.site.com/articles/article.html</tt>&quot; will
 * return the URI for &quot;<tt>http://www.site.com/articles/</tt>&quot;.
 *
 * @param uri The URI for which to return the parent.
 * @return The parent of the specified URI.
 * @throws IllegalArgumentException <ul> <li>The URI cannot be null></li> <li>Can't resolve parent for the specified
 *                                  URI.</li> </ul>
 */
public static URI getParent(final URI uri) throws IllegalArgumentException {
    if (uri == null)
        throw new IllegalArgumentException("The URI cannot be null.");

    final String path = uri.toString();
    final int finalSeparator = Math.max(path.lastIndexOf('/'), path.lastIndexOf('\\'));
    final int extension = path.lastIndexOf('.');
    if (extension > finalSeparator)
        try {
            // Extract all but final segment
            return new URI(path.substring(0, finalSeparator + 1)).normalize();
        } catch (URISyntaxException e) {
            throw new IllegalArgumentException("Can't resolve parent for the specified URI.", e);
        }
    else
        return uri.resolve(up);
}

From source file:Neo4JDataExporter.java

public static void addProperty(URI nodeUri, String propertyName, String propertyValue) {

    String propertyUri = nodeUri.toString() + "/properties/" + propertyName;
    // http://localhost:7474/db/data/node/{node_id}/properties/{property_name}

    WebResource resource = Client.create().resource(propertyUri);
    ClientResponse response = resource.accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON)
            .entity("\"" + propertyValue + "\"").put(ClientResponse.class);

    System.out.println(String.format("PUT to [%s], status code [%d]", propertyUri, response.getStatus()));
    response.close();// w  w w .  j  ava  2 s.co  m
}

From source file:com.github.thesmartenergy.sparql.generate.jena.engine.TestBase.java

static void setUpClass(Class clazz) throws Exception {
    LOG = Logger.getLogger(clazz);
    LOG.debug(clazz.getName());// ww  w. jav a  2  s .  c  o m
    String dir = clazz.getSimpleName();
    dir = Character.toLowerCase(dir.charAt(0)) + (dir.length() > 1 ? dir.substring(1) : "");
    examplePath = clazz.getResource("/" + dir);

    exampleDir = new File(examplePath.toURI());

    // read location-mapping
    URI confUri = exampleDir.toURI().resolve("configuration.ttl");
    Model conf = RDFDataMgr.loadModel(confUri.toString());

    // initialize file manager
    fileManager = FileManager.makeGlobal();
    Locator loc = new LocatorFile(exampleDir.toURI().getPath());
    LocationMapper mapper = new LocationMapper(conf);
    fileManager.addLocator(loc);
    fileManager.setLocationMapper(mapper);
}

From source file:bpelg.packaging.ode.util.BgSchemaCollection.java

protected static URI resolve(URI base, String location) {
    if ("jar".equals(base.getScheme())) {
        String str = base.toString();
        String[] parts = str.split("!");
        parts[1] = URI.create(parts[1]).resolve(location).toString();
        return URI.create(parts[0] + "!" + parts[1]);
    }//from w  w w .  j ava 2 s  . co m
    return base.resolve(location);
}

From source file:com.stefanbrenner.droplet.model.internal.Configuration.java

public static void setWathFolder(final URI watchFolderURI) {
    Configuration.PREFS.put(Configuration.CONF_WATCH_FOLDER_URI, watchFolderURI.toString());
}