// Headers: must match according to their definition.
if(a.getHeaderNames().hasNext() && !b.getHeaderNames().hasNext()) return false;
if(!a.getHeaderNames().hasNext() && b.getHeaderNames().hasNext()) return false;
if(a.getHeaderNames().hasNext() && b.getHeaderNames().hasNext()) {
HeaderFactory headerFactory = null;
try {
headerFactory = SipFactory.getInstance().createHeaderFactory();
} catch (PeerUnavailableException e) {
Debug.logError("Cannot get the header factory to parse the header of the sip uris to compare", e);
return false;
}
for (Iterator i = a.getHeaderNames(); i.hasNext();) {
String hname = (String) i.next();
String h1 = a.getHeader(hname);
String h2 = b.getHeader(hname);
if(h1 == null && h2 != null) return false;
if(h2 == null && h1 != null) return false;
// The following check should not be needed but we add it for findbugs.
if(h1 == null && h2 == null) continue;
try {
Header header1 = headerFactory.createHeader(hname, RFC2396UrlDecoder.decode(h1));
Header header2 = headerFactory.createHeader(hname, RFC2396UrlDecoder.decode(h2));
// those present in both must match according to the equals method of the corresponding header
if (!header1.equals(header2)) return false;
} catch (ParseException e) {
Debug.logError("Cannot parse one of the header of the sip uris to compare " + a + " " + b, e);
return false;