APIdia Launch Partner
Top Fields Constructors Methods
jdk.internal.net.http.websocket

public final Class BuilderImpl

extends Object
implements Builder
Class Inheritance
All Implemented Interfaces
java.net.http.WebSocket.Builder
Imports
java.net.http.HttpClient, .WebSocket, .WebSocket.Builder, .WebSocket.Listener, jdk.internal.net.http.common.Pair, java.net.ProxySelector, .URI, java.time.Duration, java.util.Collection, .ArrayList, .List, .Optional, java.util.concurrent.CompletableFuture

Field Summary

Modifier and TypeField and Description
private final HttpClient
private final Collection<Pair<String, String>>
private WebSocket.Listener
private final Optional<ProxySelector>
private final Collection<String>
private Duration
private URI

Constructor Summary

AccessConstructor and Description
public
BuilderImpl(HttpClient client, ProxySelector proxySelector)

private
BuilderImpl(HttpClient client, URI uri, WebSocket.Listener listener, Optional<ProxySelector> proxySelector, Collection<Pair<String, String>> headers, Collection<String> subprotocols, Duration timeout)

Method Summary

Modifier and TypeMethod and Description
public CompletableFuture<WebSocket>
buildAsync(URI uri, WebSocket.Listener listener)

Implements java.net.http.WebSocket.Builder.buildAsync.

Builds a WebSocket connected to the given URI and associated with the given Listener.

public WebSocket.Builder
connectTimeout(Duration timeout)

Implements java.net.http.WebSocket.Builder.connectTimeout.

Sets a timeout for establishing a WebSocket connection.

pack-priv HttpClient
pack-priv Duration
pack-priv Collection<Pair<String, String>>
pack-priv WebSocket.Listener
pack-priv Optional<ProxySelector>
pack-priv Collection<String>
pack-priv URI
public WebSocket.Builder
header(String name, String value)

Implements java.net.http.WebSocket.Builder.header.

Adds the given name-value pair to the list of additional HTTP headers sent during the opening handshake.

private BuilderImpl
public WebSocket.Builder
subprotocols(String mostPreferred, String... lesserPreferred)

Implements java.net.http.WebSocket.Builder.subprotocols.

Sets a request for the given subprotocols.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

clientback to summary
private final HttpClient client
headersback to summary
private final Collection<Pair<String, String>> headers
listenerback to summary
private WebSocket.Listener listener
proxySelectorback to summary
private final Optional<ProxySelector> proxySelector
subprotocolsback to summary
private final Collection<String> subprotocols
timeoutback to summary
private Duration timeout
uriback to summary
private URI uri

Constructor Detail

BuilderImplback to summary
public BuilderImpl(HttpClient client, ProxySelector proxySelector)
BuilderImplback to summary
private BuilderImpl(HttpClient client, URI uri, WebSocket.Listener listener, Optional<ProxySelector> proxySelector, Collection<Pair<String, String>> headers, Collection<String> subprotocols, Duration timeout)

Method Detail

buildAsyncback to summary
public CompletableFuture<WebSocket> buildAsync(URI uri, WebSocket.Listener listener)

Implements java.net.http.WebSocket.Builder.buildAsync.

Doc from java.net.http.WebSocket.Builder.buildAsync.

Builds a WebSocket connected to the given URI and associated with the given Listener.

Returns a CompletableFuture which will either complete normally with the resulting WebSocket or complete exceptionally with one of the following errors:

Annotations
@Override
connectTimeoutback to summary
public WebSocket.Builder connectTimeout(Duration timeout)

Implements java.net.http.WebSocket.Builder.connectTimeout.

Doc from java.net.http.WebSocket.Builder.connectTimeout.

Sets a timeout for establishing a WebSocket connection.

If the connection is not established within the specified duration then building of the WebSocket will fail with HttpTimeoutException. If this method is not invoked then the infinite timeout is assumed.

Annotations
@Override
getClientback to summary
pack-priv HttpClient getClient()
getConnectTimeoutback to summary
pack-priv Duration getConnectTimeout()
getHeadersback to summary
pack-priv Collection<Pair<String, String>> getHeaders()
getListenerback to summary
pack-priv WebSocket.Listener getListener()
getProxySelectorback to summary
pack-priv Optional<ProxySelector> getProxySelector()
getSubprotocolsback to summary
pack-priv Collection<String> getSubprotocols()
getUriback to summary
pack-priv URI getUri()
headerback to summary
public WebSocket.Builder header(String name, String value)

Implements java.net.http.WebSocket.Builder.header.

Doc from java.net.http.WebSocket.Builder.header.

Adds the given name-value pair to the list of additional HTTP headers sent during the opening handshake.

Headers defined in the WebSocket Protocol are illegal. If this method is not invoked, no additional HTTP headers will be sent.

Annotations
@Override
immutableCopyback to summary
private BuilderImpl immutableCopy()
subprotocolsback to summary
public WebSocket.Builder subprotocols(String mostPreferred, String... lesserPreferred)

Implements java.net.http.WebSocket.Builder.subprotocols.

Doc from java.net.http.WebSocket.Builder.subprotocols.

Sets a request for the given subprotocols.

After the WebSocket has been built, the actual subprotocol can be queried through WebSocket.getSubprotocol().

Subprotocols are specified in the order of preference. The most preferred subprotocol is specified first. If there are any additional subprotocols they are enumerated from the most preferred to the least preferred.

Subprotocols not conforming to the syntax of subprotocol identifiers are illegal. If this method is not invoked then no subprotocols will be requested.

Annotations
@Override