Refine search
private URI createUri(UriComponents uriComponents) { try { // Avoid further encoding (in the case of strictEncoding=true) return new URI(uriComponents.toUriString()); } catch (URISyntaxException ex) { throw new IllegalStateException("Could not create URI object: " + ex.getMessage(), ex); } }
@Override public URI toUri() { try { return new URI(getScheme(), this.ssp, getFragment()); } catch (URISyntaxException ex) { throw new IllegalStateException("Could not create URI object: " + ex.getMessage(), ex); } }
private String getHost(String url) { URI uri; try { uri = new URI(url); } catch (URISyntaxException e) { throw new IllegalStateException(e.getMessage()); } return uri.getHost(); }
/** * Returns the URI formed by parsing {@code uri}. This method behaves * identically to the string constructor but throws a different exception * on failure. The constructor fails with a checked {@link * URISyntaxException}; this method fails with an unchecked {@link * IllegalArgumentException}. */ public static URI create(String uri) { try { return new URI(uri); } catch (URISyntaxException e) { throw new IllegalArgumentException(e.getMessage()); } }
private URI constructURIFromString(String value) { try { return new URI(value); } catch (URISyntaxException e) { throw new ParameterException(e.getMessage(), e); } } }
private URI createUri(UriComponents uriComponents) { try { // Avoid further encoding (in the case of strictEncoding=true) return new URI(uriComponents.toUriString()); } catch (URISyntaxException ex) { throw new IllegalStateException("Could not create URI object: " + ex.getMessage(), ex); } }
/** * Create a new {@code UrlResource} based on a URI specification. * <p>The given parts will automatically get encoded if necessary. * @param protocol the URL protocol to use (e.g. "jar" or "file" - without colon); * also known as "scheme" * @param location the location (e.g. the file path within that protocol); * also known as "scheme-specific part" * @param fragment the fragment within that location (e.g. anchor on an HTML page, * as following after a "#" separator) * @throws MalformedURLException if the given URL specification is not valid * @see java.net.URI#URI(String, String, String) */ public UrlResource(String protocol, String location, @Nullable String fragment) throws MalformedURLException { try { this.uri = new URI(protocol, location, fragment); this.url = this.uri.toURL(); this.cleanedUrl = getCleanedUrl(this.url, this.uri.toString()); } catch (URISyntaxException ex) { MalformedURLException exToThrow = new MalformedURLException(ex.getMessage()); exToThrow.initCause(ex); throw exToThrow; } }
public URI getUri(final String name, final String defaultValue) { try { return getUri(name, new URI(defaultValue)); } catch (final URISyntaxException e) { throw new IllegalArgumentException(e.getMessage()); } }
public Builder add( String key, String uri, Precedence precedence ) { try { return add( key, new URI( uri ), precedence ); } catch ( URISyntaxException e ) { throw new InvalidSettingException( String.format( "Unable to construct bolt discoverable URI using '%s' as uri: " + "%s", uri, e.getMessage() ), e ); } }
public Builder add( String key, String scheme, String hostname, int port, Precedence precedence ) { try { return add( key, new URI( scheme, null, hostname, port, null, null, null ), precedence ); } catch ( URISyntaxException e ) { throw new InvalidSettingException( String.format( "Unable to construct bolt discoverable URI using '%s' as hostname: " + "%s", hostname, e.getMessage() ), e ); } }
static URI stripPathFromUri(URI uri) { try { return new URI( uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), null, uri.getQuery(), uri.getFragment()); } catch (URISyntaxException e) { throw new IllegalArgumentException(e.getMessage()); } }
public URI valueOf(String s) throws InvalidValueException { if (s.equals("")) return null; try { return new URI(s); } catch (URISyntaxException ex) { throw new InvalidValueException(ex.getMessage(), ex); } }
@Override public URI toUri() { try { return new URI(getScheme(), this.ssp, getFragment()); } catch (URISyntaxException ex) { throw new IllegalStateException("Could not create URI object: " + ex.getMessage(), ex); } }
@Override public void start(final Listener listener) { if (shutdown) { return; } List<EquivalentAddressGroup> equivalentAddressGroups = Lists.newArrayList(); for (String each : endpoints) { try { URI uri = new URI(each.trim()); if (!Strings.isNullOrEmpty(uri.getAuthority()) && SCHEMAS.matcher(uri.getScheme()).matches()) { InetSocketAddress inetSocketAddress = new InetSocketAddress(uri.getHost(), uri.getPort()); equivalentAddressGroups.add(new EquivalentAddressGroup(inetSocketAddress)); } } catch (final URISyntaxException ex) { listener.onError(Status.INVALID_ARGUMENT); log.warn("Ignored illegal endpoint, %s", ex.getMessage()); } } listener.onAddresses(equivalentAddressGroups, Attributes.EMPTY); }
private URI getUri(final String path) { final URI url; try { if (HTTP_ABS_URL.matcher(path).find()) { url = new URI(path); } else { if (StringUtils.isEmpty(getBaseUrl())) { throw new IllegalStateException("API baseUrl is not resolved yet, call setBaseUrl or resolveBaseUrl before sending requests with relative path."); } url = new URI(baseUrl + path); } } catch (final URISyntaxException e) { throw new IllegalArgumentException(e.getMessage()); } return url; }
private void setDockerHostAddressProperty(DockerAccessContext dockerAccessContext, String dockerUrl) throws MojoFailureException { Properties props = dockerAccessContext.getProjectProperties(); if (props.getProperty("docker.host.address") == null) { final String host; try { URI uri = new URI(dockerUrl); if (uri.getHost() == null && (uri.getScheme().equals("unix") || uri.getScheme().equals("npipe"))) { host = "localhost"; } else { host = uri.getHost(); } } catch (URISyntaxException e) { throw new MojoFailureException("Cannot parse " + dockerUrl + " as URI: " + e.getMessage(), e); } props.setProperty("docker.host.address", host == null ? "" : host); } }
try { final WebsocketClientEndpoint clientEndPoint = new WebsocketClientEndpoint(new URI("wss://real.okcoin.cn:10440/websocket/okcoinapi")); System.err.println("InterruptedException exception: " + ex.getMessage()); } catch (URISyntaxException ex) { System.err.println("URISyntaxException exception: " + ex.getMessage());
/** * Create a new {@code UrlResource} based on a URI specification. * <p>The given parts will automatically get encoded if necessary. * @param protocol the URL protocol to use (e.g. "jar" or "file" - without colon); * also known as "scheme" * @param location the location (e.g. the file path within that protocol); * also known as "scheme-specific part" * @param fragment the fragment within that location (e.g. anchor on an HTML page, * as following after a "#" separator) * @throws MalformedURLException if the given URL specification is not valid * @see java.net.URI#URI(String, String, String) */ public UrlResource(String protocol, String location, @Nullable String fragment) throws MalformedURLException { try { this.uri = new URI(protocol, location, fragment); this.url = this.uri.toURL(); this.cleanedUrl = getCleanedUrl(this.url, this.uri.toString()); } catch (URISyntaxException ex) { MalformedURLException exToThrow = new MalformedURLException(ex.getMessage()); exToThrow.initCause(ex); throw exToThrow; } }
/** * Container to hold AWS EC2 Instance info. * @param id if of the instance * @param uri uri to access this instance */ public EC2ServiceInstance(String id, URI uri) { this.id = id; String userInfo = uri.getUserInfo(); if (StringUtils.isNotEmpty(userInfo)) { try { this.uri = new URI(uri.getScheme(), null, uri.getHost(), uri.getPort(), uri.getPath(), uri.getQuery(), uri.getFragment()); this.metadata = ConvertibleValues.of(Collections.singletonMap( HttpHeaders.AUTHORIZATION_INFO, userInfo )); } catch (URISyntaxException e) { throw new IllegalStateException("ServiceInstance URI is invalid: " + e.getMessage(), e); } } else { this.uri = uri; } }
/** * Returns the uri representation of the value. If the value is null, then the default value is * returned. If the value isn't a uri, then a IllegalArgumentException will be thrown. */ 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 + "'"); } }