List of usage examples for java.net URI getScheme
public String getScheme()
From source file:at.bitfire.davdroid.URIUtils.java
public static URI ensureTrailingSlash(URI href) { if (!href.getPath().endsWith("/")) { try {//w w w . j a va 2 s .c o m URI newURI = new URI(href.getScheme(), href.getAuthority(), href.getPath() + "/", null, null); Log.d(TAG, "Appended trailing slash to collection " + href + " -> " + newURI); href = newURI; } catch (URISyntaxException e) { } } return href; }
From source file:piecework.util.ContentUtility.java
public static boolean validateScheme(URI uri, Set<String> validSchemes) throws PieceworkException { String scheme = uri.getScheme(); return StringUtils.isNotEmpty(scheme) && validSchemes != null && validSchemes.contains(scheme); }
From source file:com.cloudera.nav.plugin.client.writer.MetadataWriterFactory.java
/** * Return lower cased metadata parent uri scheme. If null then empty * string is returned (for easier string comparisons). * * @param config// w ww. j a v a 2s . c om * @return */ @VisibleForTesting static String getScheme(PluginConfigurations config) { URI uri = config.getMetadataParentUri(); String scheme = uri.getScheme(); return scheme == null ? "" : scheme.toLowerCase(); }
From source file:com.netdimensions.client.Client.java
private static AuthScope authScope(final URI url) { return new AuthScope(url.getHost(), url.getPort() == -1 ? defaultPort(url.getScheme()) : url.getPort()); }
From source file:org.mule.tools.rhinodo.impl.NodeModuleImplBuilder.java
public static NodeModuleImpl fromJarOrFile(Class<?> klass, String rootDirectory, String destDir) { //TODO Add validation URI root = getRoot(klass, rootDirectory); if ("jar".equals(root.getScheme())) { return fromJar(klass, rootDirectory, destDir); }/*from ww w . j ava 2 s . c o m*/ return extractFromPackageJson(root); }
From source file:Main.java
/** * This method returns an absolute URI using the given type * and namespace. If the type is already an absolute URI, it * is returned unchanged./* w w w .ja v a 2 s .co m*/ * * @param type The type * @param namespace The namespace * * @return An absolute URI */ public static String convertTypeToURI(String type, String namespace) { if (type == null || type.equals("")) return null; URI absolute; try { absolute = new URI(type); } catch (URISyntaxException e) { return namespace + type; } if (absolute.getScheme() == null) { return namespace + type; } // may be already an absolute URI return type; }
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]); }/* www . j a va 2s . com*/ return base.resolve(location); }
From source file:com.google.mr4c.content.ContentFactories.java
public static ContentFactory getContentFactory(URI uri) { return getContentFactory(uri.getScheme()); }
From source file:co.cask.cdap.internal.app.runtime.LocalizationUtils.java
/** * Returns a local {@link File} for the specified {@link LocalizeResource}. If the specified {@link LocalizeResource} * points to a local file already, it simply returns a {@link File} object for it. If it is not local, then the * method will try to download the resource to a local temporary file and return it. * * @param resource the {@link LocalizeResource} for which a local file is requested * @param tempDir the {@link File directory} to download the file to if it is a remote file * @return a local {@link File} for the specified resource *///from w ww . j ava 2s .c o m private static File getFileToLocalize(LocalizeResource resource, File tempDir) throws IOException { URI uri = resource.getURI(); if ("file".equals(uri.getScheme())) { // Local file. Just return a File object for the file. return new File(uri.getPath()); } URL url = uri.toURL(); String name = new File(uri.getPath()).getName(); File tempFile = new File(tempDir, name); Files.copy(Resources.newInputStreamSupplier(url), tempFile); return tempFile; }
From source file:org.lightcouch.URIBuilder.java
public static URIBuilder buildUri(URI uri) { URIBuilder builder = URIBuilder.buildUri().scheme(uri.getScheme()).host(uri.getHost()).port(uri.getPort()) .path(uri.getPath());// ww w.j a v a 2 s. c om return builder; }