# HG changeset patch # User prappo # Date 1523271912 -3600 # Node ID 9adc63b7f4d80f5e93661d0d2d35c0725b4951a0 # Parent a0929d5dd63f020ade98de85880c885af60e8ce0 http-client-branch: review comment - fixed weird formatting (sparse, with extra new lines) of code snippets in WebSocket diff -r a0929d5dd63f -r 9adc63b7f4d8 src/java.net.http/share/classes/java/net/http/WebSocket.java --- a/src/java.net.http/share/classes/java/net/http/WebSocket.java Fri Apr 06 22:11:44 2018 +0100 +++ b/src/java.net.http/share/classes/java/net/http/WebSocket.java Mon Apr 09 12:05:12 2018 +0100 @@ -249,10 +249,7 @@ * typically used to make a request for more invocations. * * @implSpec The default implementation is equivalent to: - * - *
{@code - * webSocket.request(1); - * }+ *
{@code webSocket.request(1); }* * @param webSocket * the WebSocket that has been connected @@ -268,11 +265,8 @@ * this {@code CompletionStage} has completed. * * @implSpec The default implementation is equivalent to: - * - *
{@code - * webSocket.request(1); - * return null; - * }+ *
{@code webSocket.request(1); + * return null; }* * @implNote The {@code data} is always a legal UTF-16 sequence. * @@ -306,11 +300,8 @@ * this {@code CompletionStage} has completed. * * @implSpec The default implementation is equivalent to: - * - *
{@code - * webSocket.request(1); - * return null; - * }+ *
{@code webSocket.request(1); + * return null; }* * @param webSocket * the WebSocket on which the data has been received @@ -347,11 +338,8 @@ * this {@code CompletionStage} has completed. * * @implSpec The default implementation is equivalent to: - * - *
{@code - * webSocket.request(1); - * return null; - * }+ *
{@code webSocket.request(1); + * return null; }* * @param webSocket * the WebSocket on which the message has been received @@ -381,11 +369,8 @@ * this {@code CompletionStage} has completed. * * @implSpec The default implementation is equivalent to: - * - *
{@code - * webSocket.request(1); - * return null; - * }+ *
{@code webSocket.request(1); + * return null; }* * @param webSocket * the WebSocket on which the message has been received @@ -428,14 +413,12 @@ *
To specify a custom closure code or reason code the * {@code sendClose} method may be invoked from inside the * {@code onClose} invocation: - *
{@code - * public CompletionStage> onClose(WebSocket webSocket, - * int statusCode, - * String reason) { - * webSocket.sendClose(CUSTOM_STATUS_CODE, CUSTOM_REASON); - * return new CompletableFuture+ *(); - * } - * }
{@code public CompletionStage> onClose(WebSocket webSocket, + * int statusCode, + * String reason) { + * webSocket.sendClose(CUSTOM_STATUS_CODE, CUSTOM_REASON); + * return new CompletableFuture* * @implSpec The default implementation of this method returns * {@code null}, indicating that the output should be closed @@ -614,7 +597,7 @@ * if {@code statusCode} is illegal, or * if {@code reason} is illegal *(); + * } }
Unless the {@code CompletableFuture} returned from this method @@ -628,13 +611,11 @@ * * @apiNote Use the provided integer constant {@link #NORMAL_CLOSURE} as a * status code and an empty string as a reason in a typical case: - *
{@code - * CompletableFuture+ *webSocket = ... - * webSocket.thenCompose(ws -> ws.sendText("Hello, ", false)) - * .thenCompose(ws -> ws.sendText("world!", true)) - * .thenCompose(ws -> ws.sendClose(WebSocket.NORMAL_CLOSURE, "")) - * .join(); - * }
{@code CompletableFuture* * The {@code sendClose} method does not close this WebSocket's input. It * merely closes this WebSocket's output by sending a Close message. To @@ -672,24 +653,23 @@ *webSocket = ... + * webSocket.thenCompose(ws -> ws.sendText("Hello, ", false)) + * .thenCompose(ws -> ws.sendText("world!", true)) + * .thenCompose(ws -> ws.sendClose(WebSocket.NORMAL_CLOSURE, "")) + * .join(); }
Here is an example of a listener that requests invocations, one at a * time, until a complete message has been accumulated, and then processes * the result: - *
WebSocket.Listener listener = new WebSocket.Listener() { + ** * @param n * the number of invocations{@code WebSocket.Listener listener = new WebSocket.Listener() { * - * StringBuilder text = new StringBuilder(); + * StringBuilder text = new StringBuilder(); * - * @Override - * public CompletionStage<?> onText(WebSocket webSocket, - * CharSequence message, - * boolean last) { - * text.append(message); - * if (last) { - * processCompleteTextMessage(text); - * text = new StringBuilder(); + * public CompletionStage> onText(WebSocket webSocket, + * CharSequence message, + * boolean last) { + * text.append(message); + * if (last) { + * processCompleteTextMessage(text); + * text = new StringBuilder(); + * } + * webSocket.request(1); + * return null; * } - * webSocket.request(1); - * return null; - * } * ... - * }+ * } }