org.dellroad.msrp.MsrpUriComparator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of msrp4j Show documentation
Show all versions of msrp4j Show documentation
msrp4j is a Java library for the MSRP protocol defined by RFC 4975.
/*
* Copyright (C) 2014 Archie L. Cobbs. All rights reserved.
*/
package org.dellroad.msrp;
import java.net.URI;
import java.util.Comparator;
/**
* Compares MRSP URI's for equality according to RFC 4579, Section 6.1.
*/
public final class MsrpUriComparator implements Comparator {
public static final MsrpUriComparator INSTANCE = new MsrpUriComparator();
private MsrpUriComparator() {
}
@Override
public int compare(MsrpUri msrp1, MsrpUri msrp2) {
final URI uri1 = msrp1.getUri();
final URI uri2 = msrp2.getUri();
int diff = uri1.getScheme().toLowerCase().compareTo(uri2.getScheme().toLowerCase());
if (diff != 0)
return diff;
diff = uri1.getHost().toLowerCase().compareTo(uri2.getHost().toLowerCase());
if (diff != 0)
return diff;
diff = Integer.compare(uri1.getPort(), uri2.getPort());
if (diff != 0)
return diff;
diff = msrp1.getSessionId().compareTo(msrp2.getSessionId());
if (diff != 0)
return diff;
diff = msrp1.getTransport().compareTo(msrp2.getTransport());
if (diff != 0)
return diff;
return 0;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy