com.mindbright.util
public final class Util extends java.lang.Object
Constructor and Description |
---|
Util() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
byteArrayFromHexString(java.lang.String in)
Convert an hex-string to byte array "0001a0" -> {0x00, 0x01, 0xa0}
|
static java.lang.String |
getHost(java.lang.String address)
Extracts the host part of an address string.
|
static int |
getPort(java.lang.String address,
int def)
Extracts the host part of an address string.
|
static boolean |
isLink(java.io.File f) |
static java.lang.Object[] |
parseForwardSpec(java.lang.String spec,
java.lang.Object local)
Parses a port forward spec of the following format:
/plugin/local_host:local_port:remote_host:remote_port
Where /plugin/ and local_host: are
optional. |
public static java.lang.String getHost(java.lang.String address)
host:port
where the ":port" part is optional. The host part is either a
name or an IPv4 address. The host may also be an IPv6 literal
address enclosed in brackets ([]
).address
- the string to extract data frompublic static int getPort(java.lang.String address, int def)
host:port
where the ":port" part is optional. The host part is either a
name or an IPv4 address. The host may also be an IPv6 literal
address enclosed in brackets ([]
).address
- the string to extract data fromdef
- default port number to return if the address does not
contain any port definition.public static java.lang.Object[] parseForwardSpec(java.lang.String spec, java.lang.Object local) throws java.lang.IllegalArgumentException
/plugin/local_host:local_port:remote_host:remote_port
Where /plugin/
and local_host:
are
optional.
local_host and remote_host may be names or literal IPv4
addreses. They can also be literal IPv6 addresses enclosed in
([]
).
spec
- the port forward speclocal
- defaukt local listenber addressjava.lang.IllegalArgumentException
public static byte[] byteArrayFromHexString(java.lang.String in)
in
- a hexadecimal stringpublic static boolean isLink(java.io.File f)