下面列出了java.net.URI#hashCode ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
static void eq0(URI u, URI v) throws URISyntaxException {
testCount++;
if (!u.equals(v))
throw new RuntimeException("Not equal: " + u + " " + v);
int uh = u.hashCode();
int vh = v.hashCode();
if (uh != vh)
throw new RuntimeException("Hash codes not equal: "
+ u + " " + Integer.toHexString(uh) + " "
+ v + " " + Integer.toHexString(vh));
out.println();
out.println(u + " == " + v
+ " [" + Integer.toHexString(uh) + "]");
}
static void eq0(URI u, URI v) throws URISyntaxException {
testCount++;
if (!u.equals(v))
throw new RuntimeException("Not equal: " + u + " " + v);
int uh = u.hashCode();
int vh = v.hashCode();
if (uh != vh)
throw new RuntimeException("Hash codes not equal: "
+ u + " " + Integer.toHexString(uh) + " "
+ v + " " + Integer.toHexString(vh));
out.println();
out.println(u + " == " + v
+ " [" + Integer.toHexString(uh) + "]");
}
static void eq0(URI u, URI v) throws URISyntaxException {
testCount++;
if (!u.equals(v))
throw new RuntimeException("Not equal: " + u + " " + v);
int uh = u.hashCode();
int vh = v.hashCode();
if (uh != vh)
throw new RuntimeException("Hash codes not equal: "
+ u + " " + Integer.toHexString(uh) + " "
+ v + " " + Integer.toHexString(vh));
out.println();
out.println(u + " == " + v
+ " [" + Integer.toHexString(uh) + "]");
}
private PeerAddress getPeerAddress(final String address) throws URISyntaxException, UnknownHostException {
final URI uri = new URI("btc://" + address);
final String host = uri.getHost();
if (host == null)
throw new UnknownHostException(address);
final NetworkData networkData = mService.getNetwork();
final int port = uri.getPort() == -1 ? networkData.getNetworkParameters().getPort() : uri.getPort();
if (!isProxyEnabled() && !getTorEnabled())
return new PeerAddress(networkData.getNetworkParameters(), InetAddress.getByName(host), port);
return new PeerAddress(networkData.getNetworkParameters(), host, port) {
@Override
public InetSocketAddress toSocketAddress() {
return InetSocketAddress.createUnresolved(host, port);
}
@Override
public String toString() {
return String.format("%s:%s", host, port);
}
@Override
public int hashCode() {
return uri.hashCode();
}
};
}
static void eq0(URI u, URI v) throws URISyntaxException {
testCount++;
if (!u.equals(v))
throw new RuntimeException("Not equal: " + u + " " + v);
int uh = u.hashCode();
int vh = v.hashCode();
if (uh != vh)
throw new RuntimeException("Hash codes not equal: "
+ u + " " + Integer.toHexString(uh) + " "
+ v + " " + Integer.toHexString(vh));
out.println();
out.println(u + " == " + v
+ " [" + Integer.toHexString(uh) + "]");
}
static void eq0(URI u, URI v) throws URISyntaxException {
testCount++;
if (!u.equals(v))
throw new RuntimeException("Not equal: " + u + " " + v);
int uh = u.hashCode();
int vh = v.hashCode();
if (uh != vh)
throw new RuntimeException("Hash codes not equal: "
+ u + " " + Integer.toHexString(uh) + " "
+ v + " " + Integer.toHexString(vh));
out.println();
out.println(u + " == " + v
+ " [" + Integer.toHexString(uh) + "]");
}
static void eq0(URI u, URI v) throws URISyntaxException {
testCount++;
if (!u.equals(v))
throw new RuntimeException("Not equal: " + u + " " + v);
int uh = u.hashCode();
int vh = v.hashCode();
if (uh != vh)
throw new RuntimeException("Hash codes not equal: "
+ u + " " + Integer.toHexString(uh) + " "
+ v + " " + Integer.toHexString(vh));
out.println();
out.println(u + " == " + v
+ " [" + Integer.toHexString(uh) + "]");
}
static void eq0(URI u, URI v) throws URISyntaxException {
testCount++;
if (!u.equals(v))
throw new RuntimeException("Not equal: " + u + " " + v);
int uh = u.hashCode();
int vh = v.hashCode();
if (uh != vh)
throw new RuntimeException("Hash codes not equal: "
+ u + " " + Integer.toHexString(uh) + " "
+ v + " " + Integer.toHexString(vh));
out.println();
out.println(u + " == " + v
+ " [" + Integer.toHexString(uh) + "]");
}
static void eq0(URI u, URI v) throws URISyntaxException {
testCount++;
if (!u.equals(v))
throw new RuntimeException("Not equal: " + u + " " + v);
int uh = u.hashCode();
int vh = v.hashCode();
if (uh != vh)
throw new RuntimeException("Hash codes not equal: "
+ u + " " + Integer.toHexString(uh) + " "
+ v + " " + Integer.toHexString(vh));
out.println();
out.println(u + " == " + v
+ " [" + Integer.toHexString(uh) + "]");
}
static void eq0(URI u, URI v) throws URISyntaxException {
testCount++;
if (!u.equals(v))
throw new RuntimeException("Not equal: " + u + " " + v);
int uh = u.hashCode();
int vh = v.hashCode();
if (uh != vh)
throw new RuntimeException("Hash codes not equal: "
+ u + " " + Integer.toHexString(uh) + " "
+ v + " " + Integer.toHexString(vh));
out.println();
out.println(u + " == " + v
+ " [" + Integer.toHexString(uh) + "]");
}
static void eq0(URI u, URI v) throws URISyntaxException {
testCount++;
if (!u.equals(v))
throw new RuntimeException("Not equal: " + u + " " + v);
int uh = u.hashCode();
int vh = v.hashCode();
if (uh != vh)
throw new RuntimeException("Hash codes not equal: "
+ u + " " + Integer.toHexString(uh) + " "
+ v + " " + Integer.toHexString(vh));
out.println();
out.println(u + " == " + v
+ " [" + Integer.toHexString(uh) + "]");
}
static void eq0(URI u, URI v) throws URISyntaxException {
testCount++;
if (!u.equals(v))
throw new RuntimeException("Not equal: " + u + " " + v);
int uh = u.hashCode();
int vh = v.hashCode();
if (uh != vh)
throw new RuntimeException("Hash codes not equal: "
+ u + " " + Integer.toHexString(uh) + " "
+ v + " " + Integer.toHexString(vh));
out.println();
out.println(u + " == " + v
+ " [" + Integer.toHexString(uh) + "]");
}
private PeerAddress getPeerAddress(final String address) throws URISyntaxException, UnknownHostException {
final URI uri = new URI("btc://" + address);
final String host = uri.getHost();
if (host == null)
throw new UnknownHostException(address);
final int port = uri.getPort() == -1? mService.getNetworkParameters().getPort() : uri.getPort();
if (!mService.isProxyEnabled())
return new PeerAddress(mService.getNetworkParameters(), InetAddress.getByName(host), port);
return new PeerAddress(mService.getNetworkParameters(), host, port) {
@Override
public InetSocketAddress toSocketAddress() {
return InetSocketAddress.createUnresolved(host, port);
}
@Override
public String toString() {
return String.format("%s:%s", host, port);
}
@Override
public int hashCode() {
return uri.hashCode();
}
};
}
static void eq0(URI u, URI v) throws URISyntaxException {
testCount++;
if (!u.equals(v))
throw new RuntimeException("Not equal: " + u + " " + v);
int uh = u.hashCode();
int vh = v.hashCode();
if (uh != vh)
throw new RuntimeException("Hash codes not equal: "
+ u + " " + Integer.toHexString(uh) + " "
+ v + " " + Integer.toHexString(vh));
out.println();
out.println(u + " == " + v
+ " [" + Integer.toHexString(uh) + "]");
}
static void eq0(URI u, URI v) throws URISyntaxException {
testCount++;
if (!u.equals(v))
throw new RuntimeException("Not equal: " + u + " " + v);
int uh = u.hashCode();
int vh = v.hashCode();
if (uh != vh)
throw new RuntimeException("Hash codes not equal: "
+ u + " " + Integer.toHexString(uh) + " "
+ v + " " + Integer.toHexString(vh));
out.println();
out.println(u + " == " + v
+ " [" + Integer.toHexString(uh) + "]");
}
LdapEntry(final String simpleName, final String distinguishedName, final URI referralURI) {
this.simpleName = simpleName;
this.distinguishedName = distinguishedName;
this.referralURI = referralURI;
hashCode = (simpleName == null ? 7 : simpleName.hashCode())
* (distinguishedName == null ? 31 : distinguishedName.hashCode()
* (referralURI == null ? 37 : referralURI.hashCode()));
}
public Key(final URI uri, final String accept) {
this.uri = uri;
this.accept = accept;
int result = uri.hashCode();
result = 31 * result + (accept != null ? accept.hashCode() : 0);
this.hash = result;
}
public int buildHash() {
int locationsHash = 0;
for (final URI location : this.locations) {
locationsHash += location.hashCode();
}
return locationsHash;
}
@Override
public int hashCode() {
URI thisURI = this.getUri();
return (thisURI == null ? super.hashCode() : thisURI.hashCode());
}