/** * The document fragment, without a preceeding '#' * * @param fragment * @return this URIBuilder instance, for method chaining. * @throws URISyntaxException if the given value contains illegal characters. */ public URIBuilder setFragment(String fragment) throws URISyntaxException { this.base = new URI(base.getScheme(), base.getUserInfo(), base.getHost(), base.getPort(), base.getPath(), base.getQuery(), fragment); return this; }
private static URI checkMetastoreUri(URI uri) { requireNonNull(uri, "metastoreUri is null"); String scheme = uri.getScheme(); checkArgument(!isNullOrEmpty(scheme), "metastoreUri scheme is missing: %s", uri); checkArgument(scheme.equals("thrift"), "metastoreUri scheme must be thrift: %s", uri); checkArgument(uri.getHost() != null, "metastoreUri host is missing: %s", uri); checkArgument(uri.getPort() != -1, "metastoreUri port is missing: %s", uri); return uri; } }
protected InetSocketAddress parseSocketAddress(final String addressString) { final InetSocketAddress address; try { final URI u = new URI(addressString); address = new InetSocketAddress(u.getHost(), u.getPort()); } catch (URISyntaxException e) { throw new IllegalArgumentException("Bad address: " + addressString, e); } return address; }
public static <P> P setData(URI uri, P obj, Map<String, String> query) throws Exception { synchronized (beanUtils) { beanUtils.setProperty(obj, "host", uri.getHost()); beanUtils.setProperty(obj, "port", uri.getPort()); beanUtils.setProperty(obj, "userInfo", uri.getUserInfo()); beanUtils.populate(obj, query); } return obj; }
protected String hostInfoForCommandline() { try { URI uri = new URI(url); if (uri.getUserInfo() != null) { //(String scheme, String userInfo, String host, int port, String path, String query, String fragment) uri = new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), null, null, null); } return uri.toString(); } catch (URISyntaxException e) { // In subversion we may have a file path that is not actually a URL return url; } }
public Builder overrideAbsolutesFromRequest( URI requestUri ) { // Find all default entries with absolute URIs and replace the corresponding host name entries with the one from the request uri. List<URIEntry> defaultEntries = entries.stream().filter( e -> e.uri.isAbsolute() && e.precedence == LOWEST ).collect( Collectors.toList() ); for ( URIEntry entry : defaultEntries ) { add( entry.key, entry.uri.getScheme(), requestUri.getHost(), entry.uri.getPort(), LOW ); } return this; }
private static URI parseDriverUrl(String url) throws SQLException { URI uri; try { uri = new URI(url.substring(JDBC_URL_START.length())); } catch (URISyntaxException e) { throw new SQLException("Invalid JDBC URL: " + url, e); } if (isNullOrEmpty(uri.getHost())) { throw new SQLException("No host specified: " + url); } if (uri.getPort() == -1) { throw new SQLException("No port number specified: " + url); } if ((uri.getPort() < 1) || (uri.getPort() > 65535)) { throw new SQLException("Invalid port number: " + url); } return uri; }
public StaticHiveCluster(List<URI> metastoreUris, String metastoreUsername, HiveMetastoreClientFactory clientFactory) { requireNonNull(metastoreUris, "metastoreUris is null"); checkArgument(!metastoreUris.isEmpty(), "metastoreUris must specify at least one URI"); this.addresses = metastoreUris.stream() .map(StaticHiveCluster::checkMetastoreUri) .map(uri -> HostAndPort.fromParts(uri.getHost(), uri.getPort())) .collect(toList()); this.metastoreUsername = metastoreUsername; this.clientFactory = requireNonNull(clientFactory, "clientFactory is null"); }
public static boolean compare(InetSocketAddress entryAddr, URI addr) { if (((entryAddr.getHostName() != null && entryAddr.getHostName().equals(trimIpv6Brackets(addr.getHost()))) || entryAddr.getAddress().getHostAddress().equals(trimIpv6Brackets(addr.getHost()))) && entryAddr.getPort() == addr.getPort()) { return true; } return false; }
private Bootstrap getBootstrap(URI uri) { boolean isSecure = (uri.getPort() == 443 || "https".equalsIgnoreCase(uri.getScheme())); if (isSecure) { return buildBootstrap(uri, true); } else { Bootstrap bootstrap = this.bootstrap; if (bootstrap == null) { bootstrap = buildBootstrap(uri, false); this.bootstrap = bootstrap; } return bootstrap; } }
/** * Set the URI scheme, AKA the 'protocol.' e.g. * <code>setScheme('https')</code> * * @throws URISyntaxException if the given scheme contains illegal characters. */ public URIBuilder setScheme(String scheme) throws URISyntaxException { this.base = new URI(scheme, base.getUserInfo(), base.getHost(), base.getPort(), base.getPath(), base.getQuery(), base.getFragment()); return this; }
/** * Instruct REST Assured to connect to a proxy using a URI. * * @param uri The URI of the proxy */ public static void proxy(URI uri) { if (uri == null) { throw new IllegalArgumentException("Proxy URI cannot be null"); } proxy(new ProxySpecification(uri.getHost(), uri.getPort(), uri.getScheme())); }
public static boolean compare(InetSocketAddress entryAddr, URI addr) { if (((entryAddr.getHostName() != null && entryAddr.getHostName().equals(trimIpv6Brackets(addr.getHost()))) || entryAddr.getAddress().getHostAddress().equals(trimIpv6Brackets(addr.getHost()))) && entryAddr.getPort() == addr.getPort()) { return true; } return false; }