org.n52.security.common.ip
Class IP4AddressMask
java.lang.Object
org.n52.security.common.ip.IP4AddressMask
- All Implemented Interfaces:
- IPAddressMask, IPRange
public class IP4AddressMask
- extends Object
- implements IPAddressMask
Represents an IP address mask that consists of an IPv4 address and a subnet mask. The subnet mask is a number of bits
that defines the network prefix length, i.e. a number between 0 and 32 vor IP4 addresses.
- Author:
- jdr
IP4AddressMask
public IP4AddressMask(Inet4Address address,
int mask)
- Creates a new IP4 address mask.
- Parameters:
address
- Base IP4 address of the IP address mask.mask
- subnet mask length to be applied. Must be a value between 0 and 32.
getMask
public byte[] getMask()
- Specified by:
getMask
in interface IPAddressMask
getAddress
public InetAddress getAddress()
- Specified by:
getAddress
in interface IPAddressMask
toString
public String toString()
- Mask as a String in the form of "
190.10.1.0/24
".
- Overrides:
toString
in class Object
- See Also:
Object.toString()
contains
public boolean contains(InetAddress address)
- Description copied from interface:
IPRange
- Checks whether a given IP address is part of this IP address range.
- Specified by:
contains
in interface IPRange
- Parameters:
address
- the address to test.
- Returns:
true
if the specified address is in the range, false
otherwise.
first
public InetAddress first()
- Specified by:
first
in interface IPRange
- Returns:
- IP address that is the upper border of the range.
last
public InetAddress last()
- Specified by:
last
in interface IPRange
- Returns:
- IP address that is the lower border of the range.
hashCode
public int hashCode()
- Overrides:
hashCode
in class Object
equals
public boolean equals(Object obj)
- Overrides:
equals
in class Object
Copyright © 2004–2014 52north.org. All rights reserved.