Class NetworkAddress
java.lang.Object
space.arim.libertybans.api.NetworkAddress
Lighter alternative to
InetAddress specialised for handling the raw address,
and not anything related to hostnames, etc.- Author:
- A248
-
Method Summary
Modifier and TypeMethodDescriptionbooleanbyte[]Gets the raw address bytes of this network addressinthashCode()static NetworkAddressof(byte[] address) Creates from raw address bytes.static NetworkAddressof(InetAddress address) Creates from aInetAddressConverts this network address to an equivalentInetAddresstoString()Returns a textual representation of this network address
-
Method Details
-
of
Creates from aInetAddress- Parameters:
address- the inet address- Returns:
- the network address
- Throws:
NullPointerException- ifaddressis null
-
of
Creates from raw address bytes. For IPv4 addresses, this should be 4 bytes long, for IPv6, 16 bytes.
Similar toInetAddress.getByAddress(byte[])- Parameters:
address- the raw address bytes, in network byte order- Returns:
- the network address
- Throws:
IllegalArgumentException- if the address bytes array is of illegal lengthNullPointerException- ifaddressis null
-
getRawAddress
public byte[] getRawAddress()Gets the raw address bytes of this network address- Returns:
- the raw address
-
toInetAddress
Converts this network address to an equivalentInetAddress- Returns:
- the inet address
-
hashCode
-
equals
-
toString
-