public function equals($otherUrl, $opt = self::SCHEME | self::HOST | self::PORT | self::CREDENTIALS | self::PATH | self::QUERY | self::FRAGMENT)
	{
		if ($otherUrl instanceof Url) {
			$url = $otherUrl;
		} else if (is_string($otherUrl)) {
			$url = new Url($otherUrl);
		} else {
			throw new InvalidUrlException();
		}
		$scheme = ($opt & self::SCHEME) === self::SCHEME;
		$host = ($opt & self::HOST) === self::HOST;
		$port = ($opt & self::PORT) === self::PORT;
		$creds = ($opt & self::CREDENTIALS) === self::CREDENTIALS;
		$path = ($opt & self::PATH) === self::PATH;
		$query = ($opt & self::QUERY) === self::QUERY;
		$fragment = ($opt & self::FRAGMENT) === self::FRAGMENT;
		if ($scheme && ! $this->scheme->equals($url->scheme)) {
			return false;
		}
		if ($host && ! $this->host->equals($url->host)) {
			return false;
		}
		if ($port && ! $this->port->equals($url->port)) {
			return false;
		}
		if ($creds && ! $this->credentials->equals($url->credentials)) {
			return false;
		}
		if ($path && ! $this->path->equals($url->path)) {
			return false;
		}
		if ($query && ! $this->query->equals($url->query)) {
			return false;
		}
		if ($fragment && ! $this->fragment->equals($url->fragment)) {
			return false;
		}
		return true;
	}