/** * @see java.lang.Object#equals(Object) */ @Override public boolean equals(Object o) { if (o == null) { return false; } if (o == this) { return true; } if (!(o instanceof AuthScope)) { return super.equals(o); } AuthScope that = (AuthScope) o; return LangUtils.equals(this.host, that.host) && this.port == that.port && LangUtils.equals(this.realm, that.realm) && LangUtils.equals(this.scheme, that.scheme); }
/** * Compares this route to another. * * @param obj the object to compare with * * @return <code>true</code> if the argument is the same route, * <code>false</code> */ @Override public final boolean equals(Object obj) { if (this == obj) return true; if (obj instanceof HttpRoute) { HttpRoute that = (HttpRoute) obj; return // Do the cheapest tests first (this.secure == that.secure) && (this.tunnelled == that.tunnelled) && (this.layered == that.layered) && LangUtils.equals(this.targetHost, that.targetHost) && LangUtils.equals(this.localAddress, that.localAddress) && LangUtils.equals(this.proxyChain, that.proxyChain); } else { return false; } }
/** * Compares this tracked route to another. * * @param o the object to compare with * * @return <code>true</code> if the argument is the same tracked route, * <code>false</code> */ @Override public final boolean equals(Object o) { if (o == this) return true; if (!(o instanceof RouteTracker)) return false; RouteTracker that = (RouteTracker) o; return // Do the cheapest checks first (this.connected == that.connected) && (this.secure == that.secure) && (this.tunnelled == that.tunnelled) && (this.layered == that.layered) && LangUtils.equals(this.targetHost, that.targetHost) && LangUtils.equals(this.localAddress, that.localAddress) && LangUtils.equals(this.proxyChain, that.proxyChain); }
/** * Generates a hash code for this tracked route. * Route trackers are modifiable and should therefore not be used * as lookup keys. Use {@link #toRoute toRoute} to obtain an * unmodifiable representation of the tracked route. * * @return the hash code */ @Override public final int hashCode() { int hash = LangUtils.HASH_SEED; hash = LangUtils.hashCode(hash, this.targetHost); hash = LangUtils.hashCode(hash, this.localAddress); if (this.proxyChain != null) { for (int i = 0; i < this.proxyChain.length; i++) { hash = LangUtils.hashCode(hash, this.proxyChain[i]); } } hash = LangUtils.hashCode(hash, this.connected); hash = LangUtils.hashCode(hash, this.secure); hash = LangUtils.hashCode(hash, this.tunnelled); hash = LangUtils.hashCode(hash, this.layered); return hash; }
synchronized HttpClientConnection getConnection(final HttpRoute route, final Object state) { Asserts.check(!this.isShutdown.get(), "Connection manager has been shut down"); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Get connection for route " + route); } Asserts.check(!this.leased, "Connection is still allocated"); if (!LangUtils.equals(this.route, route) || !LangUtils.equals(this.state, state)) { closeConnection(); } this.route = route; this.state = state; checkExpiry(); if (this.conn == null) { this.conn = this.connFactory.create(route, this.connConfig); } this.leased = true; return this.conn; }
/** * @see java.lang.Object#equals(Object) */ @Override public boolean equals(final Object o) { if (o == null) { return false; } if (o == this) { return true; } if (!(o instanceof AuthScope)) { return super.equals(o); } final AuthScope that = (AuthScope) o; return LangUtils.equals(this.host, that.host) && this.port == that.port && LangUtils.equals(this.realm, that.realm) && LangUtils.equals(this.scheme, that.scheme); }
synchronized HttpClientConnection getConnection(final HttpRoute route, final Object state) { Asserts.check(!this.isShutdown.get(), "Connection manager has been shut down"); if (this.log.isDebugEnabled()) { this.log.debug("Get connection for route " + route); } Asserts.check(!this.leased, "Connection is still allocated"); if (!LangUtils.equals(this.route, route) || !LangUtils.equals(this.state, state)) { closeConnection(); } this.route = route; this.state = state; checkExpiry(); if (this.conn == null) { this.conn = this.connFactory.create(route, this.connConfig); } this.leased = true; return this.conn; }
/** * Compares this route to another. * * @param obj the object to compare with * * @return {@code true} if the argument is the same route, * {@code false} */ @Override public final boolean equals(final Object obj) { if (this == obj) { return true; } if (obj instanceof HttpRoute) { final HttpRoute that = (HttpRoute) obj; return // Do the cheapest tests first (this.secure == that.secure) && (this.tunnelled == that.tunnelled) && (this.layered == that.layered) && LangUtils.equals(this.targetHost, that.targetHost) && LangUtils.equals(this.localAddress, that.localAddress) && LangUtils.equals(this.proxyChain, that.proxyChain); } else { return false; } }
/** * Generates a hash code for this route. * * @return the hash code */ @Override public final int hashCode() { int hash = LangUtils.HASH_SEED; hash = LangUtils.hashCode(hash, this.targetHost); hash = LangUtils.hashCode(hash, this.localAddress); if (this.proxyChain != null) { for (final HttpHost element : this.proxyChain) { hash = LangUtils.hashCode(hash, element); } } hash = LangUtils.hashCode(hash, this.secure); hash = LangUtils.hashCode(hash, this.tunnelled); hash = LangUtils.hashCode(hash, this.layered); return hash; }
/** * Compares this tracked route to another. * * @param o the object to compare with * * @return {@code true} if the argument is the same tracked route, * {@code false} */ @Override public final boolean equals(final Object o) { if (o == this) { return true; } if (!(o instanceof RouteTracker)) { return false; } final RouteTracker that = (RouteTracker) o; return // Do the cheapest checks first (this.connected == that.connected) && (this.secure == that.secure) && (this.tunnelled == that.tunnelled) && (this.layered == that.layered) && LangUtils.equals(this.targetHost, that.targetHost) && LangUtils.equals(this.localAddress, that.localAddress) && LangUtils.equals(this.proxyChain, that.proxyChain); }
/** * Generates a hash code for this tracked route. * Route trackers are modifiable and should therefore not be used * as lookup keys. Use {@link #toRoute toRoute} to obtain an * unmodifiable representation of the tracked route. * * @return the hash code */ @Override public final int hashCode() { int hash = LangUtils.HASH_SEED; hash = LangUtils.hashCode(hash, this.targetHost); hash = LangUtils.hashCode(hash, this.localAddress); if (this.proxyChain != null) { for (final HttpHost element : this.proxyChain) { hash = LangUtils.hashCode(hash, element); } } hash = LangUtils.hashCode(hash, this.connected); hash = LangUtils.hashCode(hash, this.secure); hash = LangUtils.hashCode(hash, this.tunnelled); hash = LangUtils.hashCode(hash, this.layered); return hash; }
@Test public void testCloneBasicRequests() throws Exception { final HttpGet httpget = new HttpGet("http://host/path"); httpget.addHeader("h1", "this header"); httpget.addHeader("h2", "that header"); httpget.addHeader("h3", "all sorts of headers"); final HttpGet clone = (HttpGet) httpget.clone(); Assert.assertEquals(httpget.getMethod(), clone.getMethod()); Assert.assertEquals(httpget.getURI(), clone.getURI()); final Header[] headers1 = httpget.getAllHeaders(); final Header[] headers2 = clone.getAllHeaders(); Assert.assertTrue(LangUtils.equals(headers1, headers2)); }
@Test public void testCloneEntityEnclosingRequests() throws Exception { final HttpPost httppost = new HttpPost("http://host/path"); httppost.addHeader("h1", "this header"); httppost.addHeader("h2", "that header"); httppost.addHeader("h3", "all sorts of headers"); HttpPost clone = (HttpPost) httppost.clone(); Assert.assertEquals(httppost.getMethod(), clone.getMethod()); Assert.assertEquals(httppost.getURI(), clone.getURI()); final Header[] headers1 = httppost.getAllHeaders(); final Header[] headers2 = clone.getAllHeaders(); Assert.assertTrue(LangUtils.equals(headers1, headers2)); Assert.assertNull(clone.getEntity()); final StringEntity e1 = new StringEntity("stuff"); httppost.setEntity(e1); clone = (HttpPost) httppost.clone(); Assert.assertTrue(clone.getEntity() instanceof StringEntity); Assert.assertFalse(clone.getEntity().equals(e1)); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o instanceof BasicUserPrincipal) { BasicUserPrincipal that = (BasicUserPrincipal) o; if (LangUtils.equals(this.username, that.username)) { return true; } } return false; }
@Override public int hashCode() { int hash = LangUtils.HASH_SEED; hash = LangUtils.hashCode(hash, this.principal); hash = LangUtils.hashCode(hash, this.workstation); return hash; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o instanceof NTCredentials) { NTCredentials that = (NTCredentials) o; if (LangUtils.equals(this.principal, that.principal) && LangUtils.equals(this.workstation, that.workstation)) { return true; } } return false; }
@Override public int hashCode() { int hash = LangUtils.HASH_SEED; hash = LangUtils.hashCode(hash, this.username); hash = LangUtils.hashCode(hash, this.domain); return hash; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o instanceof NTUserPrincipal) { NTUserPrincipal that = (NTUserPrincipal) o; if (LangUtils.equals(this.username, that.username) && LangUtils.equals(this.domain, that.domain)) { return true; } } return false; }
/** * Tests if the authentication scopes match. * * @return the match factor. Negative value signifies no match. * Non-negative signifies a match. The greater the returned value * the closer the match. */ public int match(final AuthScope that) { int factor = 0; if (LangUtils.equals(this.scheme, that.scheme)) { factor += 1; } else { if (this.scheme != ANY_SCHEME && that.scheme != ANY_SCHEME) { return -1; } } if (LangUtils.equals(this.realm, that.realm)) { factor += 2; } else { if (this.realm != ANY_REALM && that.realm != ANY_REALM) { return -1; } } if (this.port == that.port) { factor += 4; } else { if (this.port != ANY_PORT && that.port != ANY_PORT) { return -1; } } if (LangUtils.equals(this.host, that.host)) { factor += 8; } else { if (this.host != ANY_HOST && that.host != ANY_HOST) { return -1; } } return factor; }
/** * @see java.lang.Object#hashCode() */ @Override public int hashCode() { int hash = LangUtils.HASH_SEED; hash = LangUtils.hashCode(hash, this.host); hash = LangUtils.hashCode(hash, this.port); hash = LangUtils.hashCode(hash, this.realm); hash = LangUtils.hashCode(hash, this.scheme); return hash; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o instanceof UsernamePasswordCredentials) { UsernamePasswordCredentials that = (UsernamePasswordCredentials) o; if (LangUtils.equals(this.principal, that.principal)) { return true; } } return false; }
/** * Generates a hash code for this route. * * @return the hash code */ @Override public final int hashCode() { int hash = LangUtils.HASH_SEED; hash = LangUtils.hashCode(hash, this.targetHost); hash = LangUtils.hashCode(hash, this.localAddress); for (int i = 0; i < this.proxyChain.length; i++) { hash = LangUtils.hashCode(hash, this.proxyChain[i]); } hash = LangUtils.hashCode(hash, this.secure); hash = LangUtils.hashCode(hash, this.tunnelled); hash = LangUtils.hashCode(hash, this.layered); return hash; }
@Override public int hashCode() { int hash = LangUtils.HASH_SEED; hash = LangUtils.hashCode(hash, this.defaultPort); hash = LangUtils.hashCode(hash, this.name); hash = LangUtils.hashCode(hash, this.layered); return hash; }
@Override public boolean equals(final Object object) { if (this == object) return true; if (object instanceof HeaderElement) { BasicHeaderElement that = (BasicHeaderElement) object; return this.name.equals(that.name) && LangUtils.equals(this.value, that.value) && LangUtils.equals(this.parameters, that.parameters); } else { return false; } }
@Override public int hashCode() { int hash = LangUtils.HASH_SEED; hash = LangUtils.hashCode(hash, this.name); hash = LangUtils.hashCode(hash, this.value); for (int i = 0; i < this.parameters.length; i++) { hash = LangUtils.hashCode(hash, this.parameters[i]); } return hash; }
@Override public boolean equals(final Object object) { if (this == object) return true; if (object instanceof NameValuePair) { BasicNameValuePair that = (BasicNameValuePair) object; return this.name.equals(that.name) && LangUtils.equals(this.value, that.value); } else { return false; } }
@Override public int hashCode() { int hash = LangUtils.HASH_SEED; hash = LangUtils.hashCode(hash, this.name); hash = LangUtils.hashCode(hash, this.value); return hash; }
/** * @see java.lang.Object#hashCode() */ @Override public int hashCode() { int hash = LangUtils.HASH_SEED; hash = LangUtils.hashCode(hash, this.lcHostname); hash = LangUtils.hashCode(hash, this.port); hash = LangUtils.hashCode(hash, this.schemeName); return hash; }
@Override public boolean equals(Object o) { if (o == null) return false; if (this == o) return true; if (o instanceof DiadocCredentials) { DiadocCredentials that = (DiadocCredentials) o; if (LangUtils.equals(this.principal, that.principal) && LangUtils.equals(this.authToken, that.authToken)) { return true; } } return false; }
@Override public boolean equals(final Object o) { if (this == o) { return true; } if (o instanceof BasicUserPrincipal) { final BasicUserPrincipal that = (BasicUserPrincipal) o; if (LangUtils.equals(this.username, that.username)) { return true; } } return false; }
@Override public boolean equals(final Object o) { if (this == o) { return true; } if (o instanceof NTCredentials) { final NTCredentials that = (NTCredentials) o; if (LangUtils.equals(this.principal, that.principal) && LangUtils.equals(this.workstation, that.workstation)) { return true; } } return false; }
@Override public boolean equals(final Object o) { if (this == o) { return true; } if (o instanceof NTUserPrincipal) { final NTUserPrincipal that = (NTUserPrincipal) o; if (LangUtils.equals(this.username, that.username) && LangUtils.equals(this.domain, that.domain)) { return true; } } return false; }
@Override public boolean equals(final Object o) { if (this == o) { return true; } if (o instanceof UsernamePasswordCredentials) { final UsernamePasswordCredentials that = (UsernamePasswordCredentials) o; if (LangUtils.equals(this.principal, that.principal)) { return true; } } return false; }