URI getPort - 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 getPort 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, getPort, getUserInfo
 
    public  Context getRemoteContext() throws Exception {
        final Properties env = new Properties();
        env.put(Context.INITIAL_CONTEXT_FACTORY, org.jboss.naming.remote.client.InitialContextFactory.class.getName());
        URI webUri = managementClient.getWebUri();
        URI namingUri = new URI("http-remoting", webUri.getUserInfo(), webUri.getHost(), webUri.getPort(), "", "" ,"");
        env.put(Context.PROVIDER_URL, namingUri.toString());
        env.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");
        env.put("jboss.naming.client.security.callback.handler.class", CallbackHandler.class.getName());
        return new InitialContext(env);
    } 
 
    @Test 
    public void testRemoteLookup() throws Exception { 
        Context context = null;
        try { 
            context = getRemoteContext();
            assertEquals("TestValue", context.lookup("test"));
        } finally { 
            if (context != null)
8
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:getHost, getPort
        if (host == null) {
            String referrer = request.getHeader("referer");
            if (referrer != null) {
                URI url;
                try { 
                    url = new URI(referrer);
                    int port = url.getPort();
                    host = url.getHost() + ((port > -1) ? ":" + url.getPort() : "");
                } catch (URISyntaxException e) {
                    throw new RuntimeException("referrer '" + referrer + "' can't be parsed as a URL");
                } 
            } else { 
                throw new RuntimeException("neither the 'host' nor 'referer' headers were present in the HTTP response, I can't determine what URL OpenRefine is listening to.");
            } 
        } 
        return "http://" + host + "/command/core/authorize/" + provider.getHost();
    } 
} 
8
CodeRank
This code example shows how to use the following methods:getHost, getPort
    AndroidHttpClient client = null;
 
    try { 
      Log.w("MmsSender", "Sending MMS1 of length: " + (mms != null ? mms.length : "null"));
      client                 = constructHttpClient(context, parameters);
      URI targetUrl          = new URI(parameters.getMmsc());
      HttpHost target        = new HttpHost(targetUrl.getHost(), targetUrl.getPort(), HttpHost.DEFAULT_SCHEME_NAME);
      HttpPost request       = new HttpPost(parameters.getMmsc());
      ByteArrayEntity entity = new ByteArrayEntity(mms);
 
      entity.setContentType("application/vnd.wap.mms-message");
 
      request.setEntity(entity);
      request.setParams(client.getParams());
      request.addHeader("Accept", "*/*, application/vnd.wap.mms-message, application/vnd.wap.sic");
//      request.addHeader("x-wap-profile", "http://www.htcmms.com.tw/Android/Common/nexusone/ua-profile.xml"); 
      request.addHeader("x-wap-profile", "http://www.google.com/oha/rdf/ua-profile-kila.xml");
      HttpResponse response = client.execute(target, request);
      StatusLine status     = response.getStatusLine();
 
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:getAuthority, getPort, getRawPath, getScheme
            throw new OAuthMessageSignerException(e);
        } 
    } 
 
    public String normalizeRequestUrl() throws URISyntaxException {
        URI uri = new URI(request.getRequestUrl());
        String scheme = uri.getScheme().toLowerCase();
        String authority = uri.getAuthority().toLowerCase();
        boolean dropPort = (scheme.equals("http") && uri.getPort() == 80)
                || (scheme.equals("https") && uri.getPort() == 443);
        if (dropPort) {
            // find the last : in the authority 
            int index = authority.lastIndexOf(":");
            if (index >= 0) {
                authority = authority.substring(0, index);
            } 
        } 
        String path = uri.getRawPath();
        if (path == null || path.length() <= 0) {
            path = "/"; // conforms to RFC 2616 section 3.2.2

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: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

Related URI getPort Questions & Answers:

getPort Method Overview
Returns the port number of this URI.
See Code Examples for other Java 8 URI Methods: