-
Notifications
You must be signed in to change notification settings - Fork 107
Expand file tree
/
Copy pathNamedPipeSocketAddress.java
More file actions
37 lines (30 loc) · 1.08 KB
/
NamedPipeSocketAddress.java
File metadata and controls
37 lines (30 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.timgroup.statsd;
import java.net.SocketAddress;
public class NamedPipeSocketAddress extends SocketAddress {
private static final String NAMED_PIPE_PREFIX = "\\\\.\\pipe\\";
private final String pipe;
public NamedPipeSocketAddress(String pipeName) {
this.pipe = normalizePipeName(pipeName);
}
public String getPipe() {
return pipe;
}
/** Return true if object is a NamedPipeSocketAddress referring to the same path. */
public boolean equals(Object object) {
if (object instanceof NamedPipeSocketAddress) {
return pipe.equals(((NamedPipeSocketAddress) object).pipe);
}
return false;
}
/** A normalized version of the pipe name that includes the `\\.\pipe\` prefix */
static String normalizePipeName(String pipeName) {
if (pipeName.startsWith(NAMED_PIPE_PREFIX)) {
return pipeName;
} else {
return NAMED_PIPE_PREFIX + pipeName;
}
}
static boolean isNamedPipe(String address) {
return address.startsWith(NAMED_PIPE_PREFIX);
}
}