Java Code Examples for java.net.URI#hashCode()

The following examples show how to use java.net.URI#hashCode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Test.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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) + "]");
}
 
Example 2
Source File: ServerMetaData.java    From tomee with Apache License 2.0 5 votes vote down vote up
public int buildHash() {
    int locationsHash = 0;
    for (final URI location : this.locations) {
        locationsHash += location.hashCode();
    }
    return locationsHash;
}
 
Example 3
Source File: Key.java    From cxf with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 4
Source File: LdapEntry.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
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()));
}
 
Example 5
Source File: Test.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
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) + "]");
}
 
Example 6
Source File: Test.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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) + "]");
}
 
Example 7
Source File: SPV.java    From GreenBits with GNU General Public License v3.0 5 votes vote down vote up
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();
        }
    };
}
 
Example 8
Source File: Test.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
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) + "]");
}
 
Example 9
Source File: Test.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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) + "]");
}
 
Example 10
Source File: Test.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
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) + "]");
}
 
Example 11
Source File: Test.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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) + "]");
}
 
Example 12
Source File: Test.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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) + "]");
}
 
Example 13
Source File: Test.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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) + "]");
}
 
Example 14
Source File: Test.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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) + "]");
}
 
Example 15
Source File: Test.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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) + "]");
}
 
Example 16
Source File: SPV.java    From green_android with GNU General Public License v3.0 5 votes vote down vote up
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();
               }
    };
}
 
Example 17
Source File: Test.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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) + "]");
}
 
Example 18
Source File: Test.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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) + "]");
}
 
Example 19
Source File: IdentifierImpl.java    From XACML with MIT License 4 votes vote down vote up
@Override
public int hashCode() {
	URI thisURI	= this.getUri();
	return (thisURI == null ? super.hashCode() : thisURI.hashCode());
}