URI getFragment - 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 getFragment method.

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:getFragment, getHost, getPort, getQuery, getScheme
	protected String name;
	protected Level level;
	protected Level effectiveLevel;
 
	protected URI createUriWithPath(final IPath path) throws URISyntaxException {
		return new URI(baseLocation.getScheme(), baseLocation.getUserInfo(),
				baseLocation.getHost(), baseLocation.getPort(),
				path.toString(), baseLocation.getQuery(),
				baseLocation.getFragment());
	} 
 
	public JSONObject toJSON() throws URISyntaxException {
		return jsonSerializer.serialize(this, DEFAULT_RESOURCE_SHAPE);
	} 
 
	@PropertyDescription(name = ProtocolConstants.KEY_NAME) 
	public String getName() {
		return name;
	} 
 
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:getFragment, getHost, getPath, getPort, getQuery
   * @param defaultPort if none is given 
   * @return URI 
   */ 
  public static URI getCanonicalUri(URI uri, int defaultPort) {
    // skip if there is no authority, ie. "file" scheme or relative uri 
    String host = uri.getHost();
    if (host == null) {
      return uri;
    } 
    String fqHost = canonicalizeHost(host);
    int port = uri.getPort();
    // short out if already canonical with a port 
    if (host.equals(fqHost) && port != -1) {
      return uri;
    } 
    // reconstruct the uri with the canonical host and port 
    try { 
      uri = new URI(uri.getScheme(), uri.getUserInfo(),
          fqHost, (port == -1) ? defaultPort : port,
          uri.getPath(), uri.getQuery(), uri.getFragment());

8
CodeRank
This code example shows how to use the following methods:getFragment, getQuery, resolve
        assertEquals(null, uri.getHost());
        assertEquals(-1, uri.getPort());
    } 
 
    public void testRelativePathOnQuery() throws Exception { 
        URI base = new URI("http://host/file?query/x");
        URI uri = base.resolve("another");
        assertEquals("http://host/another", uri.toString());
        assertEquals("/another", uri.getPath());
        assertEquals(null, uri.getQuery());
        assertEquals(null, uri.getFragment());
    } 
 
    public void testRelativeFragmentOnQuery() throws Exception { 
        URI base = new URI("http://host/file?query/x#fragment");
        URI uri = base.resolve("#another");
        assertEquals("http://host/file?query/x#another", uri.toString());
        assertEquals("/file", uri.getPath());
        assertEquals("query/x", uri.getQuery());
        assertEquals("another", uri.getFragment());
7
CodeRank
This code example shows how to use the following methods:getFragment, getHost, getPath, getPort, getRawQuery
 
		try { 
 
			// TODO: there is some duplication with UriUtils here. Probably unavoidable as long as this 
			// method signature uses URI not String. 
			String query = uri.getRawQuery(); // Don't decode anything here
			String queryFragment = resource.getTokenName() + "=" + URLEncoder.encode(accessToken.getValue(), "UTF-8");
			if (query == null) {
				query = queryFragment;
			} 
			else { 
				query = query + "&" + queryFragment;
			} 
 
			// first form the URI without query and fragment parts, so that it doesn't re-encode some query string chars 
			// (SECOAUTH-90) 
			URI update = new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), uri.getPath(), null,
					null); 
			// now add the encoded query string and the then fragment 
			StringBuffer sb = new StringBuffer(update.toString());

7
CodeRank
This code example shows how to use the following methods:getFragment, getHost, getPort, getQuery, getScheme
	protected boolean isAppend;
	protected boolean isPrudent;
	protected boolean isStarted;
 
	protected URI createUriWithPath(final IPath path) throws URISyntaxException {
		return new URI(baseLocation.getScheme(), baseLocation.getUserInfo(),
				baseLocation.getHost(), baseLocation.getPort(),
				path.toString(), baseLocation.getQuery(),
				baseLocation.getFragment());
	} 
 
	public JSONObject toJSON() throws URISyntaxException {
		return jsonSerializer.serialize(this, DEFAULT_RESOURCE_SHAPE);
	} 
 
	@PropertyDescription(name = ProtocolConstants.KEY_NAME) 
	public String getName() {
		return name;
	} 
 
8
CodeRank
This code example shows how to use the following methods:getFragment, getHost, getPort, getQuery, getScheme
		} 
		return null; 
	} 
 
	private URI createUriWithPath(final IPath path) throws URISyntaxException {
		return new URI(baseLocation.getScheme(), baseLocation.getUserInfo(), baseLocation.getHost(), baseLocation.getPort(), path.toString(), baseLocation.getQuery(), baseLocation.getFragment());
	} 
 
	public JSONObject toJSON(Entry<IPath, File> entry, URI aBaseLocation) throws IOException, URISyntaxException {
		id = Activator.LOCATION_FILE_SERVLET + '/' + entry.getKey().toString();
		name = entry.getKey().lastSegment();
		db = FileRepositoryBuilder.create(entry.getValue());
		this.baseLocation = aBaseLocation;
		return toJSON(); 
	} 
} 
7
CodeRank
This code example shows how to use the following methods:getFragment, getScheme, getSchemeSpecificPart
		createFile(fProject, "folder1/abc.h");
		createFile(fProject, "folder2/abC.h");
 
		URI uri= file.getLocationURI();
		IPath path= file.getLocation();
		IFile[] files= ResourceLookup.findFilesForLocationURI(uri);
		assertEquals(1, files.length);
		files= ResourceLookup.findFilesForLocation(path);
		assertEquals(1, files.length);
 
		if (new File("a").equals(new File("A"))) {
			URI upperCase= new URI(uri.getScheme(), uri.getSchemeSpecificPart().toUpperCase(), uri.getFragment());
			IPath upperCasePath= new Path(path.toString().toUpperCase());
			files= ResourceLookup.findFilesForLocationURI(upperCase);
			assertEquals(1, files.length);
			files= ResourceLookup.findFilesForLocation(upperCasePath);
			assertEquals(1, files.length);
		}		 
	} 
	 
7
CodeRank
getFragment Method Overview
Returns the decoded fragment component of this URI.
See Code Examples for other Java 8 URI Methods: