Example usage for java.net URI getPath

List of usage examples for java.net URI getPath

Introduction

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

Prototype

public String getPath() 

Source Link

Document

Returns the decoded path component of this URI.

Usage

From source file:com.ibm.jaggr.core.impl.deps.DepUtils.java

/**
 * Removes URIs containing duplicate and non-orthogonal paths so that the
 * collection contains only unique and non-overlapping paths.
 *
 * @param uris collection of URIs//from  w w  w .j a  v  a2 s .  co  m
 *
 * @return a new collection with redundant paths removed
 */
static public Collection<URI> removeRedundantPaths(Collection<URI> uris) {
    List<URI> result = new ArrayList<URI>();
    for (URI uri : uris) {
        String path = uri.getPath();
        if (!path.endsWith("/")) { //$NON-NLS-1$
            path += "/"; //$NON-NLS-1$
        }
        boolean addIt = true;
        for (int i = 0; i < result.size(); i++) {
            URI testUri = result.get(i);
            if (!StringUtils.equals(testUri.getScheme(), uri.getScheme())
                    || !StringUtils.equals(testUri.getHost(), uri.getHost())
                    || testUri.getPort() != uri.getPort()) {
                continue;
            }
            String test = testUri.getPath();
            if (!test.endsWith("/")) { //$NON-NLS-1$
                test += "/"; //$NON-NLS-1$
            }
            if (path.equals(test) || path.startsWith(test)) {
                addIt = false;
                break;
            } else if (test.startsWith(path)) {
                result.remove(i);
            }
        }
        if (addIt)
            result.add(uri);
    }
    // Now copy the trimmed list back to the original
    return result;
}

From source file:com.yahoo.ycsb.bulk.hbase.RangePartitioner.java

/**
 * Sets the hdfs file name to use, containing a newline separated list of
 * Base64 encoded split points that represent ranges for partitioning
 *//*from  ww w  .jav a 2  s . co m*/
public static void setSplitFile(JobContext job, String file) {
    URI uri = new Path(file).toUri();
    DistributedCache.addCacheFile(uri, job.getConfiguration());
    job.getConfiguration().set(CUTFILE_KEY, uri.getPath());
}

From source file:kr.ac.kaist.wala.hybridroid.callgraph.AndroidHybridAnalysisScope.java

/**
 * Make AnalysisScope for Android hybrid application. If you want to use
 * DROIDEL as front-end, use setUpDroidelAnalysisScope method instead of
 * this./*w w  w . j a v a 2  s  . c  o  m*/
 * 
 * @param classpath
 *            the target apk file uri.
 * @param htmls
 *            JavaScript files contained in the scope.
 * @param exclusions
 *            the exclusion file.
 * @param androidLib
 *            the Android framework directory uri.
 * @return AnalysisScope for Android hybrid application.
 * @throws IOException
 */
public static AndroidHybridAnalysisScope setUpAndroidHybridAnalysisScope(String dir, URI classpath,
        Set<URL> htmls, String exclusions, URI... androidLib) throws IOException {
    AndroidHybridAnalysisScope scope;

    scope = new AndroidHybridAnalysisScope();

    File exclusionsFile = new File(exclusions);
    InputStream fs = exclusionsFile.exists() ? new FileInputStream(exclusionsFile)
            : AndroidHybridAppModel.class.getResourceAsStream(exclusions);
    scope.setExclusions(new FileOfClasses(fs));

    scope.setLoaderImpl(ClassLoaderReference.Primordial, "com.ibm.wala.dalvik.classLoader.WDexClassLoaderImpl");

    for (URI al : androidLib) {
        if (al.getPath().endsWith(".dex"))
            scope.addToScope(ClassLoaderReference.Primordial, DexFileModule.make(new File(al)));
        else if (al.getPath().endsWith(".jar"))
            scope.addToScope(ClassLoaderReference.Primordial, new JarFileModule(new JarFile(new File(al))));
        else
            throw new InternalError("Android library must be either dex or jar file: " + al.getPath());
    }

    scope.setLoaderImpl(ClassLoaderReference.Application,
            "com.ibm.wala.dalvik.classLoader.WDexClassLoaderImpl");

    scope.addToScope(ClassLoaderReference.Application, DexFileModule.make(new File(classpath)));

    if (!htmls.isEmpty())
        scope = setUpJsAnalysisScope(dir, scope, htmls);

    fs.close();

    return scope;
}

From source file:com.ibm.jaggr.core.util.PathUtil.java

public static URI appendToPath(URI uri, String append) throws URISyntaxException {
    return new URI(uri.getScheme(), uri.getAuthority(), uri.getPath() + append, uri.getQuery(),
            uri.getFragment());//www  . j a v a  2s. c o m
}

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());
    return builder;
}

From source file:de.tudarmstadt.ukp.dkpro.keyphrases.bookindexing.evaluation.phrasematch.PhraseMatchEvaluator.java

/**
 * @param jcas The jcas itself// w  w  w .jav  a 2  s  . co m
 * @return the document basename from the parsed document-URI-path.
 * @throws AnalysisEngineProcessException An analysis engine processing exception
 */
private static String getDocumentBaseName(JCas jcas) throws AnalysisEngineProcessException {
    try {
        URI uri = new URI(DocumentMetaData.get(jcas).getDocumentUri());
        return FilenameUtils.getBaseName(uri.getPath());
    } catch (URISyntaxException e) {
        throw new AnalysisEngineProcessException(e);
    }
}

From source file:org.gradle.caching.http.internal.HttpBuildCache.java

/**
 * Create a safe URI from the given one by stripping out user info.
 *
 * @param uri Original URI//from w  ww.  ja va2  s  . com
 * @return a new URI with no user info
 */
private static URI safeUri(URI uri) {
    try {
        return new URI(uri.getScheme(), null, uri.getHost(), uri.getPort(), uri.getPath(), uri.getQuery(),
                uri.getFragment());
    } catch (URISyntaxException e) {
        throw UncheckedException.throwAsUncheckedException(e);
    }
}

From source file:com.ibm.jaggr.core.util.PathUtil.java

public static URI stripJsExtension(URI value) throws URISyntaxException {
    if (value == null) {
        return null;
    }/*from   w ww .  j av  a2 s.  c om*/
    return value.getPath().endsWith(".js") ? //$NON-NLS-1$
            new URI(value.getScheme(), value.getAuthority(),
                    value.getPath().substring(0, value.getPath().length() - 3), value.getQuery(),
                    value.getFragment())
            : value;
}

From source file:com.marklogic.mapreduce.utilities.URIUtil.java

public static String getPathFromURI(DocumentURI uri) {
    String uriStr = uri.getUri();
    try {/*from  ww w.  j  ava 2 s .c o m*/
        URI child = new URI(uriStr);
        String childPath;
        if (child.isOpaque()) {
            childPath = child.getSchemeSpecificPart();
        } else {
            childPath = child.getPath();
        }
        return childPath;
    } catch (Exception ex) {
        LOG.warn("Error parsing URI " + uriStr + ".");
        return uriStr;
    }
}

From source file:com.splunk.shuttl.archiver.archive.ArchiveConfiguration.java

private static URI getChildToArchivingRoot(URI archivingRoot, String childNameToArchivingRoot) {
    if (archivingRoot != null) {
        String rootName = FilenameUtils.getName(archivingRoot.getPath());
        return archivingRoot.resolve(rootName + "/" + childNameToArchivingRoot);
    } else {// w  w  w  .jav a 2 s  . c om
        return null;
    }
}