Skip to content

Commit

Permalink
Remove 'get' prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
trustin committed Jan 17, 2013
1 parent eacc474 commit 4472fe9
Show file tree
Hide file tree
Showing 37 changed files with 124 additions and 128 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*/
public abstract class WebSocketClientHandshaker {

private final URI webSocketUrl;
private final URI uri;

private final WebSocketVersion version;

Expand All @@ -45,7 +45,7 @@ public abstract class WebSocketClientHandshaker {
/**
* Base constructor
*
* @param webSocketUrl
* @param uri
* URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be
* sent to this URL.
* @param version
Expand All @@ -57,9 +57,9 @@ public abstract class WebSocketClientHandshaker {
* @param maxFramePayloadLength
* Maximum length of a frame's payload
*/
protected WebSocketClientHandshaker(URI webSocketUrl, WebSocketVersion version, String subprotocol,
protected WebSocketClientHandshaker(URI uri, WebSocketVersion version, String subprotocol,
HttpHeaders customHeaders, int maxFramePayloadLength) {
this.webSocketUrl = webSocketUrl;
this.uri = uri;
this.version = version;
expectedSubprotocol = subprotocol;
this.customHeaders = customHeaders;
Expand All @@ -69,21 +69,21 @@ protected WebSocketClientHandshaker(URI webSocketUrl, WebSocketVersion version,
/**
* Returns the URI to the web socket. e.g. "ws://myhost.com/path"
*/
public URI getWebSocketUrl() {
return webSocketUrl;
public URI uri() {
return uri;
}

/**
* Version of the web socket specification that is being used
*/
public WebSocketVersion getVersion() {
public WebSocketVersion version() {
return version;
}

/**
* Returns the max length for any frame's payload
*/
public int getMaxFramePayloadLength() {
public int maxFramePayloadLength() {
return maxFramePayloadLength;
}

Expand All @@ -101,15 +101,15 @@ protected void setHandshakeComplete() {
/**
* Returns the CSV of requested subprotocol(s) sent to the server as specified in the constructor
*/
public String getExpectedSubprotocol() {
public String expectedSubprotocol() {
return expectedSubprotocol;
}

/**
* Returns the subprotocol response sent by the server. Only available after end of handshake.
* Null if no subprotocol was requested or confirmed by the server.
*/
public String getActualSubprotocol() {
public String actualSubprotocol() {
return actualSubprotocol;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public ChannelFuture handshake(Channel channel, final ChannelPromise promise) {
expectedChallengeResponseBytes = WebSocketUtil.md5(challenge);

// Get path
URI wsURL = getWebSocketUrl();
URI wsURL = uri();
String path = wsURL.getPath();
if (wsURL.getQuery() != null && !wsURL.getQuery().isEmpty()) {
path = wsURL.getPath() + '?' + wsURL.getQuery();
Expand Down Expand Up @@ -159,7 +159,7 @@ public ChannelFuture handshake(Channel channel, final ChannelPromise promise) {
.add(Names.SEC_WEBSOCKET_KEY1, key1)
.add(Names.SEC_WEBSOCKET_KEY2, key2);

String expectedSubprotocol = getExpectedSubprotocol();
String expectedSubprotocol = expectedSubprotocol();
if (expectedSubprotocol != null && !expectedSubprotocol.isEmpty()) {
headers.add(Names.SEC_WEBSOCKET_PROTOCOL, expectedSubprotocol);
}
Expand Down Expand Up @@ -250,7 +250,7 @@ public void finishHandshake(Channel channel, FullHttpResponse response) {
ChannelPipeline p = channel.pipeline();
p.remove(HttpRequestEncoder.class);
p.get(HttpResponseDecoder.class).replace(
"ws-decoder", new WebSocket00FrameDecoder(getMaxFramePayloadLength()));
"ws-decoder", new WebSocket00FrameDecoder(maxFramePayloadLength()));
}

private static String insertRandomCharacters(String key) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public WebSocketClientHandshaker07(URI webSocketURL, WebSocketVersion version, S
@Override
public ChannelFuture handshake(Channel channel, final ChannelPromise promise) {
// Get path
URI wsURL = getWebSocketUrl();
URI wsURL = uri();
String path = wsURL.getPath();
if (wsURL.getQuery() != null && !wsURL.getQuery().isEmpty()) {
path = wsURL.getPath() + '?' + wsURL.getQuery();
Expand Down Expand Up @@ -141,7 +141,7 @@ public ChannelFuture handshake(Channel channel, final ChannelPromise promise) {
}
headers.add(Names.SEC_WEBSOCKET_ORIGIN, originValue);

String expectedSubprotocol = getExpectedSubprotocol();
String expectedSubprotocol = expectedSubprotocol();
if (expectedSubprotocol != null && !expectedSubprotocol.isEmpty()) {
headers.add(Names.SEC_WEBSOCKET_PROTOCOL, expectedSubprotocol);
}
Expand Down Expand Up @@ -224,6 +224,6 @@ public void finishHandshake(Channel channel, FullHttpResponse response) {
ChannelPipeline p = channel.pipeline();
p.get(HttpResponseDecoder.class).replace(
"ws-decoder",
new WebSocket07FrameDecoder(false, allowExtensions, getMaxFramePayloadLength()));
new WebSocket07FrameDecoder(false, allowExtensions, maxFramePayloadLength()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public WebSocketClientHandshaker08(URI webSocketURL, WebSocketVersion version, S
@Override
public ChannelFuture handshake(Channel channel, final ChannelPromise promise) {
// Get path
URI wsURL = getWebSocketUrl();
URI wsURL = uri();
String path = wsURL.getPath();
if (wsURL.getQuery() != null && !wsURL.getQuery().isEmpty()) {
path = wsURL.getPath() + '?' + wsURL.getQuery();
Expand Down Expand Up @@ -141,7 +141,7 @@ public ChannelFuture handshake(Channel channel, final ChannelPromise promise) {
}
headers.add(Names.SEC_WEBSOCKET_ORIGIN, originValue);

String expectedSubprotocol = getExpectedSubprotocol();
String expectedSubprotocol = expectedSubprotocol();
if (expectedSubprotocol != null && !expectedSubprotocol.isEmpty()) {
headers.add(Names.SEC_WEBSOCKET_PROTOCOL, expectedSubprotocol);
}
Expand Down Expand Up @@ -225,6 +225,6 @@ public void finishHandshake(Channel channel, FullHttpResponse response) {
p.remove(HttpRequestEncoder.class);
p.get(HttpResponseDecoder.class).replace(
"ws-decoder",
new WebSocket08FrameDecoder(false, allowExtensions, getMaxFramePayloadLength()));
new WebSocket08FrameDecoder(false, allowExtensions, maxFramePayloadLength()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public WebSocketClientHandshaker13(URI webSocketURL, WebSocketVersion version, S
@Override
public ChannelFuture handshake(Channel channel, final ChannelPromise promise) {
// Get path
URI wsURL = getWebSocketUrl();
URI wsURL = uri();
String path = wsURL.getPath();
if (wsURL.getQuery() != null && !wsURL.getQuery().isEmpty()) {
path = wsURL.getPath() + '?' + wsURL.getQuery();
Expand Down Expand Up @@ -141,7 +141,7 @@ public ChannelFuture handshake(Channel channel, final ChannelPromise promise) {
}
headers.add(Names.SEC_WEBSOCKET_ORIGIN, originValue);

String expectedSubprotocol = getExpectedSubprotocol();
String expectedSubprotocol = expectedSubprotocol();
if (expectedSubprotocol != null && !expectedSubprotocol.isEmpty()) {
headers.add(Names.SEC_WEBSOCKET_PROTOCOL, expectedSubprotocol);
}
Expand Down Expand Up @@ -224,6 +224,6 @@ public void finishHandshake(Channel channel, FullHttpResponse response) {
p.remove(HttpRequestEncoder.class);
p.get(HttpResponseDecoder.class).replace(
"ws-decoder",
new WebSocket13FrameDecoder(false, allowExtensions, getMaxFramePayloadLength()));
new WebSocket13FrameDecoder(false, allowExtensions, maxFramePayloadLength()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public abstract class WebSocketServerHandshaker {

private static final String[] EMPTY_ARRAY = new String[0];

private final String webSocketUrl;
private final String uri;

private final String[] subprotocols;

Expand All @@ -47,7 +47,7 @@ public abstract class WebSocketServerHandshaker {
*
* @param version
* the protocol version
* @param webSocketUrl
* @param uri
* URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be
* sent to this URL.
* @param subprotocols
Expand All @@ -56,10 +56,10 @@ public abstract class WebSocketServerHandshaker {
* Maximum length of a frame's payload
*/
protected WebSocketServerHandshaker(
WebSocketVersion version, String webSocketUrl, String subprotocols,
WebSocketVersion version, String uri, String subprotocols,
int maxFramePayloadLength) {
this.version = version;
this.webSocketUrl = webSocketUrl;
this.uri = uri;
if (subprotocols != null) {
String[] subprotocolArray = StringUtil.split(subprotocols, ',');
for (int i = 0; i < subprotocolArray.length; i++) {
Expand All @@ -75,14 +75,14 @@ protected WebSocketServerHandshaker(
/**
* Returns the URL of the web socket
*/
public String getWebSocketUrl() {
return webSocketUrl;
public String uri() {
return uri;
}

/**
* Returns the CSV of supported sub protocols
*/
public Set<String> getSubprotocols() {
public Set<String> subprotocols() {
Set<String> ret = new LinkedHashSet<String>();
Collections.addAll(ret, subprotocols);
return ret;
Expand All @@ -91,7 +91,7 @@ public Set<String> getSubprotocols() {
/**
* Returns the version of the specification being supported
*/
public WebSocketVersion getVersion() {
public WebSocketVersion version() {
return version;
}

Expand All @@ -100,7 +100,7 @@ public WebSocketVersion getVersion() {
*
* @return The maximum length for a frame's payload
*/
public int getMaxFramePayloadLength() {
public int maxFramePayloadLength() {
return maxFramePayloadLength;
}

Expand Down Expand Up @@ -191,7 +191,7 @@ protected String selectSubprotocol(String requestedSubprotocols) {
* This is only available AFTER <tt>handshake()</tt> has been called.
* </p>
*/
public String getSelectedSubprotocol() {
public String selectedSubprotocol() {
return selectedSubprotocol;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public ChannelFuture handshake(Channel channel, FullHttpRequest req, ChannelProm
if (isHixie76) {
// New handshake method with a challenge:
res.headers().add(SEC_WEBSOCKET_ORIGIN, req.headers().get(ORIGIN));
res.headers().add(SEC_WEBSOCKET_LOCATION, getWebSocketUrl());
res.headers().add(SEC_WEBSOCKET_LOCATION, uri());
String subprotocols = req.headers().get(SEC_WEBSOCKET_PROTOCOL);
if (subprotocols != null) {
String selectedSubprotocol = selectSubprotocol(subprotocols);
Expand Down Expand Up @@ -172,7 +172,7 @@ public ChannelFuture handshake(Channel channel, FullHttpRequest req, ChannelProm
} else {
// Old Hixie 75 handshake method with no challenge:
res.headers().add(WEBSOCKET_ORIGIN, req.headers().get(ORIGIN));
res.headers().add(WEBSOCKET_LOCATION, getWebSocketUrl());
res.headers().add(WEBSOCKET_LOCATION, uri());
String protocol = req.headers().get(WEBSOCKET_PROTOCOL);
if (protocol != null) {
res.headers().add(WEBSOCKET_PROTOCOL, selectSubprotocol(protocol));
Expand All @@ -189,7 +189,7 @@ public void operationComplete(ChannelFuture future) {
p.remove(HttpObjectAggregator.class);
}
p.get(HttpRequestDecoder.class).replace("wsdecoder",
new WebSocket00FrameDecoder(getMaxFramePayloadLength()));
new WebSocket00FrameDecoder(maxFramePayloadLength()));

p.replace(HttpResponseEncoder.class, "wsencoder", new WebSocket00FrameEncoder());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public void operationComplete(ChannelFuture future) {
}

p.get(HttpRequestDecoder.class).replace("wsdecoder",
new WebSocket07FrameDecoder(true, allowExtensions, getMaxFramePayloadLength()));
new WebSocket07FrameDecoder(true, allowExtensions, maxFramePayloadLength()));
p.replace(HttpResponseEncoder.class, "wsencoder", new WebSocket07FrameEncoder(false));
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public void operationComplete(ChannelFuture future) {
}

p.get(HttpRequestDecoder.class).replace("wsdecoder",
new WebSocket08FrameDecoder(true, allowExtensions, getMaxFramePayloadLength()));
new WebSocket08FrameDecoder(true, allowExtensions, maxFramePayloadLength()));
p.replace(HttpResponseEncoder.class, "wsencoder", new WebSocket08FrameEncoder(false));
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public void operationComplete(ChannelFuture future) {
}

p.get(HttpRequestDecoder.class).replace("wsdecoder",
new WebSocket13FrameDecoder(true, allowExtensions, getMaxFramePayloadLength()));
new WebSocket13FrameDecoder(true, allowExtensions, maxFramePayloadLength()));
p.replace(HttpResponseEncoder.class, "wsencoder", new WebSocket13FrameEncoder(false));
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private boolean initPipeline(ChannelHandlerContext ctx) {
throw new IllegalStateException("SslHandler is needed for SPDY");
}

SelectedProtocol protocol = getProtocol(handler.getEngine());
SelectedProtocol protocol = getProtocol(handler.engine());
switch (protocol) {
case None:
// Not done with choosing the protocol, so just return here for now,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,8 @@ public void messageReceived(ChannelHandlerContext ctx, TextWebSocketFrame msg) t
content = "processed: " + msg.text();
}

public String getContent() {
String getContent() {
return content;
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public SocksAuthRequest(String username, String password) {
*
* @return username that needs to be authenticated
*/
public String getUsername() {
public String username() {
return username;
}

Expand All @@ -68,7 +68,7 @@ public String getUsername() {
*
* @return password that needs to be validated
*/
public String getPassword() {
public String password() {
return password;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public SocksAuthResponse(AuthStatus authStatus) {
*
* @return The {@link AuthStatus} of this {@link SocksAuthResponse}
*/
public AuthStatus getAuthStatus() {
public AuthStatus authStatus() {
return authStatus;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public SocksCmdRequest(CmdType cmdType, AddressType addressType, String host, in
*
* @return The {@link CmdType} of this {@link SocksCmdRequest}
*/
public CmdType getCmdType() {
public CmdType cmdType() {
return cmdType;
}

Expand All @@ -86,7 +86,7 @@ public CmdType getCmdType() {
*
* @return The {@link AddressType} of this {@link SocksCmdRequest}
*/
public AddressType getAddressType() {
public AddressType addressType() {
return addressType;
}

Expand All @@ -95,7 +95,7 @@ public AddressType getAddressType() {
*
* @return host that is used as a parameter in {@link CmdType}
*/
public String getHost() {
public String host() {
return IDN.toUnicode(host);
}

Expand All @@ -104,13 +104,13 @@ public String getHost() {
*
* @return port that is used as a parameter in {@link CmdType}
*/
public int getPort() {
public int port() {
return port;
}

@Override
public void encodeAsByteBuf(ByteBuf byteBuf) {
byteBuf.writeByte(getProtocolVersion().getByteValue());
byteBuf.writeByte(protocolVersion().getByteValue());
byteBuf.writeByte(cmdType.getByteValue());
byteBuf.writeByte(0x00);
byteBuf.writeByte(addressType.getByteValue());
Expand Down
Loading

0 comments on commit 4472fe9

Please sign in to comment.