in activemq-cpp/src/main/decaf/net/URI.cpp [367:463]
bool URI::equals( const URI& uri ) const {
if ((uri.uri.getFragment() == "" && this->uri.getFragment() != "") ||
(uri.uri.getFragment() != "" && this->uri.getFragment() == "")) {
return false;
} else if (uri.uri.getFragment() != "" && this->uri.getFragment() != "") {
if (!equalsHexCaseInsensitive(uri.uri.getFragment(), this->uri.getFragment())) {
return false;
}
}
if ((uri.uri.getScheme() == "" && this->uri.getScheme() != "") ||
(uri.uri.getScheme() != "" && this->uri.getScheme() == "")) {
return false;
} else if (uri.uri.getScheme() != "" && this->uri.getScheme() != "") {
if (StringUtils::compareIgnoreCase(uri.uri.getScheme().c_str(), this->uri.getScheme().c_str()) != 0) {
return false;
}
}
if (uri.uri.isOpaque() && this->uri.isOpaque()) {
return equalsHexCaseInsensitive(
uri.uri.getSchemeSpecificPart(), this->uri.getSchemeSpecificPart());
} else if (!uri.uri.isOpaque() && !this->uri.isOpaque()) {
if (!equalsHexCaseInsensitive(this->uri.getPath(), uri.uri.getPath())) {
return false;
}
if ((uri.uri.getQuery() != "" && this->uri.getQuery() == "") ||
(uri.uri.getQuery() == "" && this->uri.getQuery() != "")) {
return false;
} else if(uri.uri.getQuery() != "" && this->uri.getQuery() != "") {
if (!equalsHexCaseInsensitive(uri.uri.getQuery(), this->uri.getQuery())) {
return false;
}
}
if( ( uri.uri.getAuthority() != "" && this->uri.getAuthority() == "" ) ||
( uri.uri.getAuthority() == "" && this->uri.getAuthority() != "" ) ) {
return false;
} else if (uri.uri.getAuthority() != "" && this->uri.getAuthority() != "") {
if ((uri.uri.getHost() != "" && this->uri.getHost() == "") ||
(uri.uri.getHost() == "" && this->uri.getHost() != "")) {
return false;
} else if (uri.uri.getHost() == "" && this->uri.getHost() == "") {
// both are registry based, so compare the whole authority
return equalsHexCaseInsensitive(
uri.uri.getAuthority(), this->uri.getAuthority());
} else { // uri.host != "" && host != "", so server-based
if (StringUtils::compareIgnoreCase(uri.uri.getHost().c_str(), this->uri.getHost().c_str()) != 0) {
return false;
}
if (this->uri.getPort() != uri.uri.getPort()) {
return false;
}
if ((uri.uri.getUserInfo() != "" && this->uri.getUserInfo() == "") ||
(uri.uri.getUserInfo() == "" && this->uri.getUserInfo() != "")) {
return false;
} else if (uri.uri.getUserInfo() != "" && this->uri.getUserInfo() != "") {
return equalsHexCaseInsensitive(this->uri.getUserInfo(), uri.uri.getUserInfo());
} else {
return true;
}
}
} else {
// no authority
return true;
}
} else {
// one is opaque, the other hierarchical
return false;
}
}