URI getPath - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for URI getPath method.

This code example shows how to use the following methods:getHost, getPath, getPort, getUserInfo
		    new GenericObjectPoolConfig()); 
	} 
    } 
 
    public JedisPool(final URI uri) {
	String h = uri.getHost();
	int port = uri.getPort();
	String password = uri.getUserInfo().split(":", 2)[1];
	int database = Integer.parseInt(uri.getPath().split("/", 2)[1]);
	this.internalPool = new GenericObjectPool<Jedis>(new JedisFactory(h,
		port, Protocol.DEFAULT_TIMEOUT, password, database, null),
		new GenericObjectPoolConfig()); 
    } 
 
    public JedisPool(final GenericObjectPoolConfig poolConfig,
	    final String host, int port, int timeout, final String password) {
	this(poolConfig, host, port, timeout, password,
		Protocol.DEFAULT_DATABASE, null); 
    } 
 
9
CodeRank
This code example shows how to use the following methods:getHost, getPath, getPort, getQuery
		assertEquals("Invalid method", HttpMethod.POST, request.getMethod());
	} 
 
	@Test
	public void getURI() throws Exception {
		URI uri = new URI("http://example.com/path?query");
		mockRequest.setServerName(uri.getHost());
		mockRequest.setServerPort(uri.getPort());
		mockRequest.setRequestURI(uri.getPath());
		mockRequest.setQueryString(uri.getQuery());
		assertEquals("Invalid uri", uri, request.getURI());
	} 
 
	@Test
	public void getContentType() throws Exception {
		HttpHeaders headers = request.getHeaders();
		assertNotNull("No HttpHeaders returned", headers);
 
		MediaType expected = MediaType.parseMediaType(mockFile.getContentType());
		MediaType actual = headers.getContentType();
8
CodeRank
This code example shows how to use the following methods:getAuthority, getPath, toString
        ctx.revokeUriPermission(Uri.parse(rootUri), Intent.FLAG_GRANT_READ_URI_PERMISSION);
    } 
     
    public static File fileFromUri(Uri uri) throws IllegalArgumentException
    { 
        String authority = uri.getAuthority();
        if(isCorrectAuthority(authority))
            return new File(PATH_PREFIX + authority + uri.getPath());
        else throw new IllegalArgumentException("Unknown URI authority: " + authority);
    } 
     
    @Override 
    public ParcelFileDescriptor openFile(Uri uri, String mode)
        throws FileNotFoundException, SecurityException 
    { 
        Logger.T(TAG, "Opening content: " + uri);
         
        if(mode.compareTo("r") != 0)
        { 
            throw new SecurityException("Unacceptable openFile mode: " + mode);

8
CodeRank
This code example shows how to use the following methods:getPath, getPort, getScheme
 
        if (uri == null) {
            throw new IllegalArgumentException(LocalizationMessages.ERROR_CONTAINER_URI_NULL());
        } 
 
        final String scheme = uri.getScheme();
        if (!scheme.equalsIgnoreCase("http") && !scheme.equalsIgnoreCase("https")) {
            throw new IllegalArgumentException(LocalizationMessages.ERROR_CONTAINER_URI_SCHEME_UNKNOWN(uri));
        } 
 
        final String path = uri.getPath();
        if (path == null) {
            throw new IllegalArgumentException(LocalizationMessages.ERROR_CONTAINER_URI_PATH_NULL(uri));
        } else if (path.length() == 0) {
            throw new IllegalArgumentException(LocalizationMessages.ERROR_CONTAINER_URI_PATH_EMPTY(uri));
        } else if (path.charAt(0) != '/') {
            throw new IllegalArgumentException(LocalizationMessages.ERROR_CONTAINER_URI_PATH_START(uri));
        } 
 
        final int port = (uri.getPort() == -1) ? 80 : uri.getPort();

8
CodeRank
This code example shows how to use the following methods:getPath, getScheme, toString
		InputStream stream = openInputStream( context, uri );
		if ( null == stream ) {
			return null; 
		} 
		 
		int orientation = ExifUtils.getExifOrientation( context, uri );
 
		Bitmap bitmap = null;
		int[] imageSize = new int[2];
		final boolean decoded = decodeImageBounds( stream, imageSize );
		IOUtils.closeSilently( stream );
 
		if ( decoded ) {
			int sampleSize;
			if( maxW < 0 || maxH < 0 ) {
				sampleSize = 1;
			} else { 
				sampleSize = computeSampleSize( imageSize[0], imageSize[1], (int) ( maxW * 1.2 ), (int) ( maxH * 1.2 ), orientation );
			} 
 

8
CodeRank
This code example shows how to use the following methods:getFragment, getHost, getPath, getPort, getQuery
  public BaseResource(String uri, boolean rewrite) throws URISyntaxException {
    this(new URI(uri), rewrite);
  } 
 
  public BaseResource(URI uri, boolean rewrite) {
    if (rewrite && uri.getHost().equals("localhost")) {
      // Rewrite localhost URIs to refer to the special Android emulator loopback passthrough interface. 
      Log.d(LOG_TAG, "Rewriting " + uri + " to point to 10.0.2.2.");
      try { 
        this.uri = new URI(uri.getScheme(), uri.getUserInfo(), "10.0.2.2", uri.getPort(), uri.getPath(), uri.getQuery(), uri.getFragment());
      } catch (URISyntaxException e) {
        Log.e(LOG_TAG, "Got error rewriting URI for Android emulator.", e);
      } 
    } else { 
      this.uri = uri;
    } 
  } 
 
  public URI getURI() {
    return this.uri;
8
CodeRank
This code example shows how to use the following methods:getFragment, getHost, getPath, getPort, getQuery
        List<URI> uris = resolveURIs(baseURI, hrefs);
        return filterNonDirectChilds(baseURI, uris);
    } 
 
    private URI addTrailingSlashes(URI uri) throws IOException, URISyntaxException {
        if(uri.getPath() == null){
            uri = new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), "/", uri.getQuery(), uri.getFragment());
        }else if (!uri.getPath().endsWith("/") && !uri.getPath().endsWith(".html")) {
            uri = new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), uri.getPath() + "/", uri.getQuery(), uri.getFragment());
 
        } 
        return uri;
    } 
 
    private List<String> filterNonDirectChilds(URI baseURI, List<URI> inputURIs) throws MalformedURLException {
        final int baseURIPort = baseURI.getPort();
        final String baseURIHost = baseURI.getHost();
        final String baseURIScheme = baseURI.getScheme();
 
        List<String> uris = new ArrayList<String>();
8
CodeRank
This code example shows how to use the following methods:getPath
   * @throws IOException 
   */ 
  @Deprecated 
  public static FileStatus getFileStatus(Configuration conf, URI cache)
    throws IOException { 
    FileSystem fileSystem = FileSystem.get(cache, conf);
    return fileSystem.getFileStatus(new Path(cache.getPath()));
  } 
 
  /** 
   * Returns mtime of a given cache file on hdfs. Internal to MapReduce. 
   * @param conf configuration 
   * @param cache cache file 
   * @return mtime of a given cache file on hdfs 
   * @throws IOException 
   */ 
  @Deprecated 
  public static long getTimestamp(Configuration conf, URI cache)
    throws IOException { 
    return getFileStatus(conf, cache).getModificationTime();
8
CodeRank
This code example shows how to use the following methods:getFragment, getHost, getPath, getPort, getQuery
 
	/** 
	 * Sets the absolute location of the contents of this project. 
	 */ 
	public void setContentLocation(URI contentURI) {
		if (contentURI.getUserInfo() == null) {
			contentLocation = contentURI;
		} else { 
			try { 
				//strip out credential information 
				contentLocation = new URI(contentURI.getScheme(), null, contentURI.getHost(), contentURI.getPort(), contentURI.getPath(), contentURI.getQuery(), contentURI.getFragment());
			} catch (URISyntaxException e) {
				//should never happen because we are stripping info from a valid URI 
				throw new RuntimeException(e);
			} 
		} 
	} 
	 
	/** 
	 * Sets the workspace id of the workspace that owns this project. 
8
CodeRank
This code example shows how to use the following methods:getPath
  } 
   
  private static void waitForLogRollInSharedDir(MiniDFSCluster cluster,
      long startTxId) throws Exception {
    URI sharedUri = cluster.getSharedEditsDir(0, 1);
    File sharedDir = new File(sharedUri.getPath(), "current");
    final File expectedLog = new File(sharedDir,
        NNStorage.getInProgressEditsFileName(startTxId));
     
    GenericTestUtils.waitFor(new Supplier<Boolean>() {
      @Override 
      public Boolean get() {
        return expectedLog.exists();
      } 
    }, 100, 10000); 
  } 
} 
8
CodeRank

Related URI getPath Questions & Answers:

getPath Method Overview
Returns the decoded path component of this URI.
See Code Examples for other Java 8 URI Methods: