Constructs a {@link URI} that matches this pattern from the given options.

@param options a map of variable and
@return a {@link URI} that matches this pattern
@throws IllegalArgumentException if the URI cannot be constructed
518974
public URI construct(Map<String, String> options) {
    // make a copy that can be modified
    Map<String, String> uriData = Maps.newLinkedHashMap(options);
    try {
      // scheme should always be present, but default if necessary
      String scheme = defaults.get(SCHEME);
      if (uriData.containsKey(SCHEME)) {
        scheme = uriData.remove(SCHEME);
      }

      StringBuilder builder = new StringBuilder();
      builder.append(scheme).append(":");

      if (!pattern.isOpaque()) {
        // Build the URI(String,String,String,int,String,String,String)
        StringBuilder authBuilder = new StringBuilder();
        String user = constructUserInfo(uriData, defaults);
        String host = removeNonDefault(HOST, uriData, defaults);
        int port = constructPort(uriData, defaults);
        if (user != null) {
          authBuilder.append(user).append("@");
        }
        if (host != null) {
          authBuilder.append(host);
        }
        if (port >= 0) {
          authBuilder.append(":").append(port);
        }
        String auth = authBuilder.toString();
        if (!auth.isEmpty()) {
          builder.append("//").append(auth);
        }
      }

      builder.append(constructPath(uriData, patternPath));

      String query = constructQuery(uriData, defaults);
      if (query != null) {
        builder.append("?").append(query);
      }

      return new URI(builder.toString());

    } catch (URISyntaxException ex) {
      throw new IllegalArgumentException("Could not build URI", ex);
    }
  }
336158
private URI getBaseURI(URI configKey) throws URISyntaxException {
    return new URI(configKey.getScheme(), configKey.getAuthority(), null, configKey.getQuery(), configKey.getFragment());
  }
236322
public URI baseURL() {
        StringBuilder b = new StringBuilder()
                .append(protocol())
                .append(host())
                .append(":")
                .append(port())
                .append("/")
                .append(versionPrefix())
                .append("/");
        try {
            return new URI(b.toString());
        } catch (URISyntaxException e) {
            throw new IllegalArgumentException("Unable to construct a base URL for the API", e);
        }
    }
378701
private static URI toUri(final URL u) {

        try {
            return u.toURI();
        } catch (URISyntaxException e) {
            throw new IllegalArgumentException("Could not convert URL "+u+" to uri",e);
        }
    }
945432
public static URI create(Path pathToVault, String... pathComponentsInsideVault) {
		try {
			return new URI(URI_SCHEME, pathToVault.toUri().toString(), "/" + String.join("/", pathComponentsInsideVault), null, null);
		} catch (URISyntaxException e) {
			throw new IllegalArgumentException("Can not create URI from given input", e);
		}
	}
413599
private URI checkURI(String uri)
  {
    try
    {
      return new URI(Preconditions.checkNotNull(uri).trim());
    } catch (URISyntaxException e)
    {
      parser.getReport().message(MessageId.RSC_020, parser.getLocation(), uri);
      return null;
    }
  }
591130
public UrlMappingInfo match(String uri) {
        for (Pattern pattern : patterns) {
            Matcher m = pattern.matcher(uri);
            if (m.matches()) {
                UrlMappingInfo urlInfo = createUrlMappingInfo(uri, m);
                if (urlInfo != null) {
                    return urlInfo;
                }
            }
        }
        return null;
    }
165365
protected String initializeURI(URL url, String servicePrefix) {
        if ( url == null ) {
            throw new IllegalArgumentException( "The url may not be empty or null." );
        }
        try {
            url.toURI();
        } catch ( URISyntaxException urise ) {
            throw new IllegalArgumentException(
                    "URL (" + url.toExternalForm() + ") is incorrectly formatted: " + urise.getMessage(), urise );
        }

        String urlString = url.toExternalForm();
        if ( !urlString.endsWith( "/" ) ) {
            urlString += "/";
        }
        urlString += "services/"+servicePrefix + "/server";

        URL serverPlusServicePrefixUrl;
        try {
            serverPlusServicePrefixUrl = new URL( urlString );
        } catch ( MalformedURLException murle ) {
            throw new IllegalArgumentException(
                    "URL (" + url.toExternalForm() + ") is incorrectly formatted: " + murle.getMessage(), murle );
        }

        return urlString;
    }
1154878
private Path createPath(PathUri uri) {

    PathProvider provider = getProvider(uri);
    if (provider == null) {
      if (uri.getSchemePrefix() == null) {
        return Paths.get(uri.getPath());
      } else {
        try {
          return Paths.get(new URI(uri.getUri()));
        } catch (URISyntaxException e) {
          throw new ResourceUriUndefinedException(e, uri.getUri());
        }
      }
    }
    return provider.createResource(uri);
  }
224543
static URI parseURI(final String string) {
		try {
			return string != null ? new URI(string) : null;
		} catch (URISyntaxException e) {
			throw new IllegalArgumentException(format(
				"Invalid URI value: %s.", string
			));
		}
	}
1100772
public URI addAPIKey(String uri) {
        try {
            final URIBuilder builder = new URIBuilder(uri);
            if (apiAccessKey != null) {
                builder.setParameter("key", apiAccessKey);
            }
            return builder.build();
        } catch (URISyntaxException e) {
            throw new RedmineInternalError(e);
        }
    }
820188
public static URI uri(AbstractConfig config, String key) {
    final String value = config.getString(key);
    return uri(key, value);
  }
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;
	}
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;
    }
562110
public static URL url(final String url) {
        if (url == null) {
            return null;
        }
        try {
            if (url.startsWith("classpath:")) {
                return new URL(null, url, new ClasspathURLStreamHandler());
            }
            return new URL(url);
        } catch (final MalformedURLException ex) {
            throw new IllegalArgumentException("Invalid URL: " + url, ex);
        }
    }
284180
public URI forURL(URI uri) {
        QueryStringEncoder encoder = new QueryStringEncoder(uri.toString());
        for (Map.Entry<String, Object> e : params.entrySet()) {
            encoder.addParam(e.getKey(), String.valueOf(e.getValue()));
        }
        try {
            return encoder.toUri();
        } catch (URISyntaxException e) {
            throw new IllegalArgumentException("Cannot construct a query string from the given params. " +
                    "An invalid parameter was used.");
        }
    }
683865
public Configuration setOptions(Option... options) {
        return Configuration.builder().jsonProvider(jsonProvider).mappingProvider(mappingProvider).options(options).evaluationListener(evaluationListeners).build();
    }