Creates a Uri object which corresponds to the URI string.
 
    This method can accept partial URIs, but it will leave missing
    members of the Uri unset.
353536
def parse_uri(uri_string):
    
    parts = urlparse.urlparse(uri_string)
    uri = Uri()
    if parts[0]:
      uri.scheme = parts[0]
    if parts[1]:
      host_parts = parts[1].split(':')
      if host_parts[0]:
        uri.host = host_parts[0]
      if len(host_parts) > 1:
        uri.port = int(host_parts[1])
    if parts[2]:
      uri.path = parts[2]
    if parts[4]:
      param_pairs = parts[4].split('&')
      for pair in param_pairs:
        pair_parts = pair.split('=')
        if len(pair_parts) > 1:
          uri.query[urllib.unquote_plus(pair_parts[0])] = (
              urllib.unquote_plus(pair_parts[1]))
        elif len(pair_parts) == 1:
          uri.query[urllib.unquote_plus(pair_parts[0])] = None
    return uri
100529
public ConverterServerBuilder baseUri(String baseUri) {
        checkNotNull(baseUri);
        this.baseUri = URI.create(baseUri);
        return this;
    }
273737
def build_uri(orig_uriparts, kwargs):
    
    uriparts = []
    for uripart in orig_uriparts:
        # If this part matches a keyword argument (starting with _), use
        # the supplied value. Otherwise, just use the part.
        if uripart.startswith("_"):
            part = (str(kwargs.pop(uripart, uripart)))
        else:
            part = uripart
        uriparts.append(part)
    uri = '/'.join(uriparts)

    # If an id kwarg is present and there is no id to fill in in
    # the list of uriparts, assume the id goes at the end.
    id = kwargs.pop('id', None)
    if id:
        uri += "/%s" % (id)

    return uri
95163
private static URI createUriFromName(String name) {
        if (name == null) {
            throw new NullPointerException("name");
        }
        try {
            return new URI(name);
        } catch (final URISyntaxException e) {
            throw new IllegalArgumentException("Invalid name: " + name, e);
        }
    }
301139
public static function createFromString (string $uri)
    {
        $parts = parse_url($uri);
        $scheme = isset($parts['scheme']) ? $parts['scheme'] : '';
        $user = isset($parts['user']) ? $parts['user'] : '';
        $pass = isset($parts['pass']) ? $parts['pass'] : '';
        $host = isset($parts['host']) ? $parts['host'] : '';
        $port = isset($parts['port']) ? $parts['port'] : null;
        $path = isset($parts['path']) ? $parts['path'] : '';
        $query = isset($parts['query']) ? $parts['query'] : '';
        $fragment = isset($parts['fragment']) ? $parts['fragment'] : '';

        return new \Resilient\Http\Uri($scheme, $host, $port, $path, $query, $fragment, $user, $pass);
    }
610777
public static URI create(String input) {
        if (isFile(input) || isURL(input)) {
            return URI.create(input);
        } else {
            return Paths.get(input).toUri();
        }
    }
112750
def normalize_uri(u: URI) -> URIRef:
    
    return u if isinstance(u, URIRef) else URIRef(str(u))
135453
protected String toBaseURI(String uri) {
    LoaEnum loa = LoaEnum.parse(uri);
    if (loa != null && loa.isSignatureMessageUri()) {
      return LoaEnum.minusSigMessage(loa).getUri();
    }
    return uri;
  }
816638
def deserialize_uri(value):
    
    if isinstance(value, BNode):
        return value
    if isinstance(value, URIRef):
        return value
    if not value:
        return None
    if not isinstance(value, basestring):
        raise ValueError("Cannot create URI from {0} of type {1}".format(value, value.__class__))
    if value.startswith("_:"):
        return BNode(value[2:])
    return URIRef(value)
783668
public static UriBuilder fromUri(String uri) {
        if (uri == null)
            throw new IllegalArgumentException("Uri cannot be null");

        final UriBuilder builder = newInstance();
        builder.uri(Uri.create(uri));
        return builder;
    }
266889
@Override
    URI getURI() {
        try {
            return new URI(URLPathEncoder.normalizeURLPath(getZipFilePath()));
        } catch (final URISyntaxException e) {
            throw new IllegalArgumentException("Could not form URI: " + e);
        }
    }
21076
private URI decodeHarURI(URI rawURI, Configuration conf) throws IOException {
    String tmpAuth = rawURI.getAuthority();
    //we are using the default file
    //system in the config
    //so create a underlying uri and
    //return it
    if (tmpAuth == null) {
      //create a path
      return FileSystem.getDefaultUri(conf);
    }
    String host = rawURI.getHost();
    String[] str = host.split("-", 2);
    if (str[0] == null) {
      throw new IOException("URI: " + rawURI + " is an invalid Har URI.");
    }
    String underLyingScheme = str[0];
    String underLyingHost = (str.length > 1)? str[1]:null;
    int underLyingPort = rawURI.getPort();
    String auth = (underLyingHost == null && underLyingPort == -1)?
                  null:(underLyingHost+":"+underLyingPort);
    URI tmp = null;
    if (rawURI.getQuery() != null) {
      // query component not allowed
      throw new IOException("query component in Path not supported  " + rawURI);
    }
    try {
      tmp = new URI(underLyingScheme, auth, rawURI.getPath(),
            rawURI.getQuery(), rawURI.getFragment());
    } catch (URISyntaxException e) {
        // do nothing should not happen
    }
    return tmp;
  }
382802
public static function createFromString($uri = ''): self
    {
        $components = UriString::parse($uri);

        return new self(
            $components['scheme'],
            $components['user'],
            $components['pass'],
            $components['host'],
            $components['port'],
            $components['path'],
            $components['query'],
            $components['fragment']
        );
    }
624513
public static URI toURI(String uri) throws URISyntaxException {
		final URI u = new URI(uri);
		// Inspired by ZeroMQ
		String adr = u.getAuthority();
		if (adr == null) {
			adr = u.getPath();
		}
		if (adr != null && adr.endsWith(":*")) { //$NON-NLS-1$
			return new URI(u.getScheme(), u.getUserInfo(), adr.substring(0, adr.length() - 2), -1, null, u.getQuery(),
					u.getFragment());
		}
		return u;
	}
41714
private UriTuple parseUriTuple(String uri, Map<String, String[]> params) throws UnsupportedEncodingException {

		String requestUri = null;
		String queryString = "";  // default
		
		final int queryStringBegin = uri.indexOf("?");
		if (queryStringBegin == -1) {
			// Simple case -- no querystring
			requestUri = uri;
		} else {
			// Complex case -- uri+querystring
			requestUri = uri.substring(0, queryStringBegin);
			queryString = uri.substring(queryStringBegin);  // will already contain the '?' character
		}
		
		// Inject requestUri params
		for (Map.Entry<String, String[]> y : params.entrySet()) {
			final String token = "{" + y.getKey() + "}";
			final String[] values = y.getValue();
			switch (values.length) {
				case 0:
					// Strange -- I guess we omit it?
					while(requestUri.contains(token)) {
						// Don't use String.replaceAll b/c token looks like an illegal regex
						requestUri = requestUri.replace(token, "");
					}
					break;
				case 1:
					// This is healthy & normal
					final String inject = URLEncoder.encode(values[0], "UTF-8");
					while(requestUri.contains(token)) {
						// Don't use String.replaceAll b/c token looks like an illegal regex
						requestUri = requestUri.replace(token, inject);
					}
					break;
				default:
					// OOPS! --  can't have more than 1 value for a requestUri token
					final String msg = "Can't support multiple values for non-querystring URI token:  " + token;
					throw new IllegalArgumentException(msg);
			}
		}
		
		// Inject queryString params
		for (Map.Entry<String, String[]> y : params.entrySet()) {
			final String paramName = y.getKey();
			final String token = "{" + paramName + "}";
			if (queryString.contains(token)) {
				final StringBuilder value = new StringBuilder();
				for (String s : y.getValue()) {
					final String inject = URLEncoder.encode(s, "UTF-8");
					value.append(value.length() != 0 ? "&" : "");
					value.append(paramName).append("=").append(inject);
				}
				queryString = queryString.replace(token, value);
			}
		}
		
		// Split into contextName+uri
		final int contextSeparatorPos = requestUri.indexOf("/", 1);  // A valid input starts with a slash, followed by the contextName
		final String contextName = requestUri.substring(0, contextSeparatorPos);  // Includes leading '/'
		requestUri = requestUri.substring(contextSeparatorPos);  // Includes leading '/'

		return new UriTuple(contextName, requestUri + queryString);
		
	}
1304141
public URI getUri(final String name) {
    if (containsKey(name)) {
      try {
        return new URI(get(name));
      } catch (final URISyntaxException e) {
        throw new IllegalArgumentException(e.getMessage());
      }
    } else {
      throw new UndefinedPropertyException("Missing required property '" + name
          + "'");
    }
  }
544198
public void setURI(URI uri) throws URIException {

        if (uri.getScheme() == null || uri.getScheme().equals("")) {
            mUri = new URI(HTTP + "://" + getHeader(HOST) + "/" + mUri.toString(), true);
            
        } else {
            mUri = uri;
        }

        if (uri.getScheme().equalsIgnoreCase(HTTPS)) {
            mIsSecure = true;
            
        } else {
            mIsSecure = false;
        }

        setHostPort(mUri.getPort());
    }